Create a webhook endpoint
POST /v1/webhooks
Adds a webhook endpoint that Soosh sends events to, signed with a new secret.
Needs webhooks:write.
Over the API the secret is returned only here and when you rotate it, so store it now. People who can edit webhooks can also see it in the app.
url string Required
An https:// URL on the internet. It can’t have a username or password, or point to an internal or private address.
events array of strings Required
Any of message.received message.sent message.status contact.created contact.updated contact.deleted template.status chat.assigned chat.closed chat.reopened broadcast.status. At least 1 item.
description string
A note to tell your endpoints apart.
Up to 500 characters.
headers object
Custom headers sent with every request. You can set at most 10. Names are 1 to 64 letters, digits or hyphens. Values are up to 1024 characters, with no line breaks. The API returns every value as ********.
A map; each value is a string.
Headers
Section titled “Headers”Idempotency-Key string
Send one so a retry doesn’t create the endpoint twice. See Retrying safely.
1 to 255 characters.
Choosing the events
Section titled “Choosing the events”A key needs the read scope of every event the endpoint subscribes to: messages:read for message.*, contacts:read for contact.*, templates:read for template.* and broadcasts:read for broadcast.*. The API has no read-only chat scope, so chat.* events need chats:write.
Every event is listed in Webhook events.
Headers you can't set
Section titled “Headers you can't set”Host, Content-Length, Content-Type, Content-Encoding, Transfer-Encoding, TE, Trailer, Connection, Keep-Alive, Upgrade, Expect, User-Agent, Proxy-* and Webhook-*.
After you create it
Section titled “After you create it”Check each request’s signature with the secret. See Verify webhooks.
Returns
Section titled “Returns”201 The endpoint, with its secret.
id string · uuid
url string
Where Soosh sends the events.
description string
Up to 500 characters.
events array of strings
Any of message.received message.sent message.status contact.created contact.updated contact.deleted template.status chat.assigned chat.closed chat.reopened broadcast.status.
headers object
Custom headers sent with every request, by name. Values are never
returned: each reads ********.
A map; each value is a string. Up to 10 keys.
status string
active; paused while the endpoint keeps failing (Soosh tries
again by itself at paused_until, and events wait meanwhile); or
disabled when it’s turned off.
disabled_reason string · nullable
Why Soosh turned the endpoint off: failing after a day of
nothing but failures; no_secret when it has no signing secret
(nothing is ever sent unsigned: rotate the secret, then turn it
back on). An endpoint a key created belongs to that
key, and moves to its replacement when the key is rotated; it is
turned off when the key is revoked (key_revoked), expires
without a replacement (key_expired), or loses webhooks:write
or the read scope of an event it sends (key_scopes). null
otherwise, including when a person turned it off. Turn it back on
with enabled: true; deliveries that were waiting are still sent
if you do within a day of it being turned off.
paused_until string · date-time · nullable
When a paused endpoint is tried again; null unless status is paused.
previous_secret_expires_at string · date-time · nullable
During a rotation, when the old secret stops signing; null otherwise.
created_at string · date-time
updated_at string · date-time
secret string
The signing secret (whsec_ and base64), shown this once.
The HMAC key is the base64-decoded part after whsec_.
Errors
Section titled “Errors”Besides the ones every request can get:
scope_missingThe key lacks the read scope of an event the endpoint subscribes to. error.details.scope says which.invalid_fieldThe url, a header or the events break a rule: for example an http:// URL, a private address, more than 10 headers or an unknown event.idempotency_mismatchThe Idempotency-Key was used before for a different request, or by another of your API keys.