Webhooks
Webhooks can notify teams when a certain event takes place in regard to templates and notifications. Set Notification webhooks on Sendbird Dashboard for your server to receive HTTP POST requests from the Sendbird server in JSON format, which contain information on all events within your Sendbird application.
Set up webhooks
To listen to events, set up webhooks on the dashboard first as follows:
- Log in the Sendbird Dashboard.
- Navigate to Settings > Business Messaging > Webhooks and turn on the feature.
- Enter the webhook URL for the Sendbird server to send a request and choose the events you wish to subscribe to.
Settings | Description |
---|---|
URL | Specifies the URL that Sendbird can send the the payload to. |
Events | Selects webhook events to listen to. |
List of webhook events
The following table lists the webhook events that you can subscribe to.
Event | Description |
---|---|
notification:send_realtime | Notifies you when a request is made for a real-time notification. |
notification:send_batch | Notifies you when a request is made for a batch notification. |
notification:template_create | Notifies you when a template is created. |
notification:template_archive | Notifies you when a template is archived. |
notification:template_unarchive | Notifies you when a template is unarchived. |
notification:template_edit | Notifies you when a template is edited. |
notification:template_approval_update | Notifies you when the approval status of a channel’s template has changed. |
Note: See the Payload section below for more information on the payload format.
Authentication headers
HTTP POST
requests from the Sendbird server include the following headers.
Note: Upon selection, the Sendbird server will dispatch webhook events in JSON format to your specified server. This occurs whenever a real-time or batch notification is triggered. Including template variables can be enabled by request, allowing all webhooks to include these variables, as detailed in the payload format below.
x-sendbird-signature
x-sendbird-signature
is used as a request header to ensure that the source of the request comes from the Sendbird server and the request is not altered by external influences. Based on both the POST
request body and your API token, the value of x-sendbird-signature
is generated through the SHA-256
encryption on the the Sendbird server side.
To verify the request on your server side, create a comparison value exactly the same way as the Sendbird server does, and then check if the result is equal to the value of the x-sendbird-signature
.
Note: Always use the master API token to generate and validate the signature because secondary API tokens won't work. You can find the master API token on the dashboard.
Note: The
x-signature
request header can be used for verification. However, when the request body contains non-ASCII characters such as emojis, the encrypted value on your server side and the value ofx-signature
generated from the Sendbird server are always different. For this reason,x-signature
could be deprecated in the near future. Therefore, we recommend that you usex-sendbird-signature
instead.
Payload
The following is the payload sample for notifications and templates: