Subscribing to Webhook Events
The following guide provides step-by-step instructions for getting started with webhooks, covering the essentials of event subscription management. To learn about publishing webhook events, see our Publishing Webhook Events guide.
Follow the steps below to start subscribing to webhook events in your app.
Call GetSubscriptions or GetSubscriptionById to get a list of existing subscriptions for the app. See the following examples responses below:
Use the GetPublisherEvents endpoint to retrieve all events by topic.
Parameter | Description |
---|---|
topic | The topic name. Possible values:
|
Call CreateSubscription to add your webhook notification URL and the events you wish to subscribe to. Refer to the table below for the CreateSubscription schema:
Parameter | Description |
---|---|
description | The description of the subscription. Example: "Subscription for user state change events". |
topic* | The topic from which to receive events. Pattern: ^[a-zA-Z0-9\._\-]+$. Example: participant. Enum: [participant, entity, container]. |
events | List of events. A max of 20 events are allowed at a time in a subscription at creation. |
isActive | Indicates whether this subscription configuration is active. Default: true. |
customAttr | Indicates if the subscription includes custom attributes. Default: false. |
webhook* | Contains url and signatureKey. |
webhook.url* | The URL on which notifications will be sent. Example: https://example.com/webhook. |
webhook.signatureKey* | The HMAC authentication secret key in base64 encoded format. Example: base64encodedSignature. |
The following example CreateSubscription request includes the following:
- Creates a subscription for the OrderCreated and OrderStatusUpdated events published with the app:1f36d53c-fcc4-42d2-a753-33044f5c5f77 appId.
- The topic field specifies which Kafka topic the events will read from.
- When events occur, the app will send payloads to the specified webhook URL https://your-app.com/order-webhooks for handling.
Here is a sample response for the createSubscription request:
You can update existing webhook subscriptions by calling UpdateSubscriptions, which allows developers to modify the following subscription parameters:
- Description
- Events
- Active status
- Webhook URL
- Signature key
- Custom attributes
Refer to the table below for the UpdateSubscriptionsE schema:
Parameter | Description |
---|---|
description | The description of the subscription. Example: "Subscription for user state change events". |
topic | The topic from which to receive events. Pattern: ^[a-zA-Z0-9\._\-]+$. Example: participant. Enum: [participant, entity, container]. |
events | List of events. A max of 20 events are allowed at a time in a subscription at creation. |
isActive | Indicates whether this subscription configuration is active. Default: true. |
customAttr | Indicates if the subscription includes custom attributes. Default: false. |
webhook | Contains url and signatureKey. |
webhook.url | The URL on which notifications will be sent. Example: https://example.com/webhook. |
webhook.signatureKey | The HMAC authentication secret key in base64 encoded format. Example: base64encodedSignature. |
Here is a sample UpdateSubscription request:
The example UpdateSubscription request updated the following:
- description: Updated subscription description
- events: Updated list of 2 events
- isActive: Sets status to active
- customAttr: Enables custom attributes
- webhook.url: Updated webhook URL
- webhook.signatureKey: New base64 encoded HMAC key
To add or remove specific subscription events, call PatchSubscriptionsEvents.
Refer to the table below for the updateSubscriptionEvents schema:
Parameter | Data Type | Description |
---|---|---|
action | string | Specifies the action to be performed on the events. Options: add, remove. |
events | array | A list of event names to be added or removed. Max 20 events can be handled in one API call. Example: ["event1", "event2"]. |
Here is a sample updateSubscriptionEvents request:
The example would add 3 new events (OrderDispatched, OrderDelivered, and PaymentCaptured) events.
To remove events, you would use the remove action instead.