Skip to content

Webhooks

José Ignacio Amelivia Santiago edited this page May 27, 2021 · 1 revision

List all webhooks

List all webhook endpoints reference on the official TravelPerk documentation.

This function will list all webhook subscriptions.

webhooks = travelperk.webhooks().webhooks().all()

Create a webhook

Create a webhook endpoints reference on the official TravelPerk documentation.

Given the attributes for a new webhook, this function will create a webhook that will subscribe to one or more events.

webhook = travelperk.webhooks().webhooks().create(
  'webhookName',
  'webhookUrl',
  'webhookSecret',
  ['webhookEvent1', 'wehookEvent2']
)

Retrieve a webhook

Retrieve a webhook endpoints reference on the official TravelPerk documentation.

Given a webhook id this function will get the details for an specific webhook.

webhook = travelperk.webhooks().webhooks().get('webhook-id')

Update a webhook

Update a webhook endpoints reference on the official TravelPerk documentation.

Given an id and the attributes to update for a webhook, this function will update the webhook and set the attributes passed.

webhook = travelperk.webhooks().webhooks().modify('webhook-id')
  .set_name('newName') # Update the name
  .set_enabled(False) # And disable the webhook
  .save()

Test a webhook

Test a webhook endpoints reference on the official TravelPerk documentation.

Given a webhook id this function will perform a test call to the endpoint url.

webhook = travelperk.webhooks().webhooks().test('webhook-id')

Delete a webhook

Delete a webhook endpoints reference on the official TravelPerk documentation.

Given a webhook id this function will remove the webhook.

webhook = travelperk.webhooks().webhooks().delete('webhook-id')