Set up a webhook
Have Soosh tell your system the moment a message arrives, a contact changes or a chat is handed over.
Before you start
Section titled “Before you start”- A role that can create and edit webhooks: owner, admin or manager
- An
https://address on your server that accepts aPOSTwith a JSON body and answers with a2xxstatus within 10 seconds
Add the webhook
Section titled “Add the webhook”-
Go to Settings > Webhooks (opens Soosh in a new tab) and click Create webhook.
-
In Name, enter what it’s for, like Order system.
-
In Webhook URL, enter your address.
-
Under Events, tick what to hear about, like Message received and Contact created. Tick at least one. Events marked Not in your plan can’t be ticked. Webhook events lists them all.
-
Optional: under Custom headers (optional), add any headers your server needs, like an
Authorizationtoken. -
Click Create.
-
Soosh shows the webhook’s signing secret. Click Copy secret (or tick I’ve copied the secret), keep it with your server’s other secrets, and click Done. Done works once you’ve done one of the two.
-
Click Test webhook.
The test sends an event of type webhook.test. Soosh says Test sent., or
what went wrong, like your address answering with an error. If you changed the
page, save first: the test uses the saved webhook. You can send 10 test events a
minute.
Use the secret to check that each request came from Soosh. See Verify webhooks.
Send each number’s messages to the right system
Section titled “Send each number’s messages to the right system”If your workspace has several WhatsApp numbers, this webhook hears about all of them. Two webhooks subscribed to Message received each receive both your sales and support messages.
After checking the signature, have your server use data.number_id to send
message events to the right system. Keep the number’s ID rather than its
name, so renaming it does not change your routing. See
Use several numbers with the API for an
incoming message and reply example.
Show or replace the signing secret
Section titled “Show or replace the signing secret”The webhook’s page keeps its signing secret under Signing secret. Anyone who can edit webhooks can show it again.
- Go to Settings > Webhooks (opens Soosh in a new tab) and click the webhook.
- Under Signing secret, click Show secret to see it again, or Rotate secret to make a new one.
- If you rotate, under Old secret keeps working for choose Now, 1 hour, 24 hours or 7 days, then click Rotate secret.
- Click Copy secret and put the new secret on your server.
Until the old secret stops, every request carries two signatures, so your server can switch over without missing an event.
See what Soosh sent
Section titled “See what Soosh sent”Each webhook lists what Soosh sent to it, with the answer your server gave. Use it to find a failed delivery, and to send it again.
- Go to Settings > Webhooks (opens Soosh in a new tab) and click the webhook.
- Find Deliveries. Each row has a Time, the Event, a Status, the Answer your server gave (None if it didn’t answer), the Attempts and the Duration.
- Optional: to see only some deliveries, choose an event instead of All events, or a state instead of Any state.
- Click a row. The Delivery window shows the Request body and your server’s last answer.
- Click Resend to send that event again.
A delivery is Waiting, Sending, Retrying (with when the next try is due), Delivered or Failed. While the webhook is paused, the next try is when the pause ends; while it’s turned off, a delivery says Waits until the webhook is back on. If your role can’t see the chats, contacts, templates or campaigns an event is about, the Request body isn’t shown to you.
Soosh keeps delivered events for 3 days and failed ones for 30. You only see Resend if your role can create and edit webhooks.
To send again every event that failed recently, click Replay failed,
choose how far back under Failed in the last (up to 7 days), and click
Replay failed. One replay sends up to 10,000 events, oldest first, and you
can replay once a minute. A resent or replayed event keeps its
webhook-id.
If your server keeps failing
Section titled “If your server keeps failing”Soosh tries a failed delivery again for about 2 days (see the schedule). After 10 failures in a row it pauses the webhook, shows Paused, and tries again a little later. After a day of nothing but failures it turns the webhook off, shows Turned off, and emails the people who manage webhooks.
Fix your server, then click Turn back on. Events waiting for it are kept for one day from when it was turned off, so if you turn it back on within a day they’re still sent.
Webhooks made with an API key
Section titled “Webhooks made with an API key”A webhook made through the API (see Create a webhook endpoint) belongs to the key that made it, and follows
it: rotating the key moves the webhook to the new key. Soosh turns the webhook
off, shows Turned off with the reason, and emails the people who manage
webhooks when the key is revoked, expires without a replacement, or loses the
webhooks:write scope or the read scope of an event the webhook sends. If you
still want it, click Turn back on: the webhook is then yours, not the
key’s.
Change a webhook’s URL
Section titled “Change a webhook’s URL”Custom header values are never shown, and they’re only sent where they were set. When you point a webhook at another server (a different scheme, host or port), enter each header’s value again, or remove the header, before you save.
To stop a webhook yourself without deleting it, turn off Send events and click Save. Events already waiting are kept for a day.