Create a webhook subscription

Create a webhook subscription

post

To start receiving notifications via webhooks, the first step is to create a subscription. A webhook subscription specifies the destination URL for events and defines how they should be filtered. During setup, you can select which events to send to the specified URL. You can create multiple webhook subscriptions to route different types of events to various URLs as needed. Event filters are applied using AND operators, meaning that all specified criteria must be met for an event to be sent. If you want to handle multiple interactionTypes, you’ll need to create separate webhook subscriptions for each.

Authorizations
HTTPRequired

Uses the Authorization header: 'AccessKey ' followed by your access key token (e.g., 'Authorization: AccessKey AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIj')

Path parameters
workspaceIdstring · uuidRequired

The ID for the workspace.

Example: b4e02c85-c6d2-4b15-8885-e09671799c61
Body
servicestring · enumRequired

The service that the webhook is subscribed to. For example, to get events regarding channels, the service would be channels.

Possible values:
eventstringRequired

The event name identifies the webhook event, such as sms.outbound for notifications about SMS messages being sent.

Example: sms.outbound
templatestringOptional
urlstringRequired

The URL of the webhook is used to send events to the webhook. The URL must be a valid URL that respects the established pattern and is accessible from the internet.

Example: https://example.com/webhookPattern: ^https://([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(/[^\s]*)?$
signingKeystringOptional

The signing key for the webhook and can be used to verify the authenticity of the webhook.

Example: KeV+/HGoIQrxuE5YPCRR6AuQOJveldYNNhbVi1i22qk=
Responses
chevron-right
201

The webhook subscription was created successfully.

application/json
idstring · uuidRequired

The unique identifier for the webhook subscription. This identifier is used to reference the webhook subscription in other API calls.

organizationIdstring · uuidRequiredExample: cb28a94e-8557-4394-80ea-5bbd2170d434
workspaceIdstring · uuidRequiredExample: b4e02c85-c6d2-4b15-8885-e09671799c61
servicestring · enumRequired

The service that the webhook is subscribed to. For example, to get events regarding channels, the service would be channels.

Possible values:
eventstringRequired

The event name identifies the webhook event, such as sms.outbound for notifications about SMS messages being sent.

Example: sms.outbound
templatestringOptional

Used for our Exit APIs for Twilio and Sinch. More information can be found here for Twilio and here for Sinch.

Example: twilio
urlstringRequired

The URL of the webhook is used to send events to the webhook. The URL must be a valid URL that respects the established pattern and is accessible from the internet.

Example: https://example.com/webhookPattern: ^https://([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}(/[^\s]*)?$
signingKeystringOptional

The signing key for the webhook and can be used to verify the authenticity of the webhook.

Example: KeV+/HGoIQrxuE5YPCRR6AuQOJveldYNNhbVi1i22qk=
statusstring · enumRequiredPossible values:
statusReasonstringOptional

A human-readable explanation for the current status of the webhook subscription.

createdAtstring · date-timeOptional
updatedAtstring · date-timeOptional
post
/workspaces/{workspaceId}/webhook-subscriptions

To know more about how to use signingKeys, please refer to the section Verifying a webhook.


Examples

Let's establish some of our data that will be used in the following examples:

  • Workspace ID: a1405560-c8d3-4b1a-877d-3f449ad95352

  • AccessKey: abcd

Creating a subscription for events of a specific channel

In this example, we're sending event notifications for each sent message by the specified channel. To know more about valid events for each platform (e.g. SMS, E-mail), please refer to this documentation.

Creating a webhook subscription and filtering events based on interaction type

This will send notification events to the specified webhook URL when an e-mail sent by the specified channel is opened by end-customers. To know more about all supported interactions, refer to this documentation.

Creating a webhook subscription without filtering

This will send notification events to the specified webhook URL for all email interactions. To know more about all supported interactions, refer to this documentation.

Last updated

Was this helpful?