Formatting a request
Like most Sonar APIs, the POST Create Webhook API accepts a JSON request body. In this case, the request body should include a webhook
object that contains the other required parameters: active
, settings
, url
, http_method
, and name
. For example:
{
"webhook": {
"name": "webhook to capture customer state changes",
"active": "true",
"settings": {
"customer_state_changed": "true"
},
"url": "https://endpoint.com/catch-a-hook",
"http_method": "POST"
}
}
The settings
parameter
settings
parameterThe settings
parameter, within the webhook
object, in the request body specifies the event(s) that should trigger a webhook. Refer to Custom Webhooks for examples of the webhook payload for each event type.
The settings
parameter is a JSON object containing key:value pairs. To subscribe to an event, include the event name as the key and include "true" (as a string) as the value. For example:
"settings": {
"new_assigned_message": "true",
"new_unassigned_message": "true"
}
It is not necessary to include events you don't want to subscribe to in the POST request. You can omit an event from the settings
object
Events | Accepted Values | Description |
---|---|---|
"new_assigned_message" | "true", "false" | Triggers webhook when a message comes from an assigned customer |
"new_unassigned_message" | "true", "false" | Triggers webhook when a message comes from an unassigned customer |
"outbound_message" | "true", "false" | Triggers webhook when a user sends a message to a customer |
"customer_subscribed" | "true", "false" | Triggers webhook when a customer gets subscribed |
"customer_unsubscribed" | "true", "false" | Triggers webhook when a customer gets unsubscribed |
"user_assignment" | "true", "false" | Triggers webhook when a customer is assigned to a user |
"customer_created" | "true", "false" | Triggers webhook when a new customer record is created |
"tag_added_to_message" | "true", "false" | Triggers webhook when a user adds a tag to a message |
"tag_removed_from_message" | "true", "false" | Triggers webhook when a user removes a tag from a message |
"customer_double_opted_in" | "true", "false" | Triggers webhook when a customer sends a message that matches the opt-in keyword configured in the your account's Double Opt-In settings. |
"customer_state_changed" | "true", "false" | Triggers webhook on several events which change the state of the customer record: close, unassign, assign, create, unsubscribe, subscribe, and snooze. |
To see examples of the payload delivered by a webhook see the Webhook Payloads section on the Custom Webhooks page.