WhatsApp API webhooks
SheetWA WhatsApp API webhooks POST a signed JSON event to your server when a customer writes, a message is delivered, a template is reviewed or a broadcast ends.
Add an endpoint#
- 1
Open Webhooks
In the SheetWA dashboard, open the API keys page, then Webhooks.
- 2
Add your URL
Use an HTTPS URL with a public host name. A workspace can have up to 5 endpoints.
- 3
Copy the signing secret
Each endpoint has its own secret starting with
whsec_. It is shown when you create the endpoint and when you roll the secret, so store it on your server then. - 4
Send a test event
Click Send test event. Your endpoint gets a
webhook.testevent, and the delivery shows in the dashboard.
Events#
Every event's data carries the ids you need to look things up with the API. All ids are strings or null, phones are E.164 with the plus sign or null, and times are ISO 8601.
message.received
When it is sent: A customer sent a WhatsApp message to the workspace's number.
message.status
When it is sent: A message the workspace sent was sent, delivered, read or failed.
template.status
When it is sent: Meta approved, rejected, paused or disabled a message template.
broadcast.completed
When it is sent: A broadcast finished sending to all its recipients.
contact.unsubscribed
When it is sent: A contact was unsubscribed and will get no more broadcasts.
webhook.test
When it is sent: Someone clicked Send test event in the dashboard.
| Event | When it is sent |
|---|---|
| message.received | A customer sent a WhatsApp message to the workspace's number. |
| message.status | A message the workspace sent was sent, delivered, read or failed. |
| template.status | Meta approved, rejected, paused or disabled a message template. |
| broadcast.completed | A broadcast finished sending to all its recipients. |
| contact.unsubscribed | A contact was unsubscribed and will get no more broadcasts. |
| webhook.test | Someone clicked Send test event in the dashboard. |
message.received
A customer's message is stored for the first time.
message_id
Type: string or null
What it is: The message.
chat_id
Type: string or null
What it is: The inbox chat it belongs to.
contact_id
Type: string or null
What it is: The contact who sent it.
phone
Type: string or null
What it is: The sender's phone in E.164 with the plus sign.
profile_name
Type: string or null
What it is: The sender's WhatsApp profile name.
message_type
Type: string
What it is: The kind of message, such as text.
text
Type: string or null
What it is: The message text.
received_at
Type: string (ISO 8601)
What it is: When the message arrived.
| Field | Type | What it is |
|---|---|---|
| message_id | string or null | The message. |
| chat_id | string or null | The inbox chat it belongs to. |
| contact_id | string or null | The contact who sent it. |
| phone | string or null | The sender's phone in E.164 with the plus sign. |
| profile_name | string or null | The sender's WhatsApp profile name. |
| message_type | string | The kind of message, such as text. |
| text | string or null | The message text. |
| received_at | string (ISO 8601) | When the message arrived. |
message.status
A sent message's status moves forward to sent, delivered or read, or to failed. Each step is sent once.
message_id
Type: string or null
What it is: The message. Can be null when the status arrives before the message is stored.
whatsapp_message_id
Type: string
What it is: WhatsApp's id for the message.
status
Type: "sent" | "delivered" | "read" | "failed"
What it is: The new status.
phone
Type: string or null
What it is: The recipient's phone in E.164 with the plus sign.
broadcast_id
Type: string or null
What it is: The broadcast it was part of, or null for a single send.
error_code
Type: string or null
What it is: Only on failed: the failure code.
error_message
Type: string or null
What it is: Only on failed: what the failure means.
status_at
Type: string (ISO 8601)
What it is: When the status changed.
| Field | Type | What it is |
|---|---|---|
| message_id | string or null | The message. Can be null when the status arrives before the message is stored. |
| whatsapp_message_id | string | WhatsApp's id for the message. |
| status | "sent" | "delivered" | "read" | "failed" | The new status. |
| phone | string or null | The recipient's phone in E.164 with the plus sign. |
| broadcast_id | string or null | The broadcast it was part of, or null for a single send. |
| error_code | string or null | Only on failed: the failure code. |
| error_message | string or null | Only on failed: what the failure means. |
| status_at | string (ISO 8601) | When the status changed. |
template.status
Meta moved a template to APPROVED, REJECTED, PAUSED or DISABLED.
template_name
Type: string or null
What it is: The template's name.
language_code
Type: string or null
What it is: The template's language code.
status
Type: "APPROVED" | "REJECTED" | "PAUSED" | "DISABLED"
What it is: The new status.
rejection_reason
Type: string or null
What it is: Only on REJECTED: Meta's reason.
| Field | Type | What it is |
|---|---|---|
| template_name | string or null | The template's name. |
| language_code | string or null | The template's language code. |
| status | "APPROVED" | "REJECTED" | "PAUSED" | "DISABLED" | The new status. |
| rejection_reason | string or null | Only on REJECTED: Meta's reason. |
broadcast.completed
A broadcast finished sending.
broadcast_id
Type: string or null
What it is: The broadcast.
name
Type: string or null
What it is: The broadcast's name.
total
Type: integer or null
What it is: Recipients in the broadcast.
sent
Type: integer
What it is: Messages sent.
failed
Type: integer
What it is: Messages that failed.
skipped
Type: integer or null
What it is: Recipients skipped.
completed_at
Type: string (ISO 8601)
What it is: When sending finished.
| Field | Type | What it is |
|---|---|---|
| broadcast_id | string or null | The broadcast. |
| name | string or null | The broadcast's name. |
| total | integer or null | Recipients in the broadcast. |
| sent | integer | Messages sent. |
| failed | integer | Messages that failed. |
| skipped | integer or null | Recipients skipped. |
| completed_at | string (ISO 8601) | When sending finished. |
Delivered and read counts keep moving after this event. Read them from GET /v1/broadcasts/{broadcast_id}/stats.
contact.unsubscribed
A contact was unsubscribed.
contact_id
Type: string or null
What it is: The contact, or null for an automatic unsubscribe after a bounce.
phone
Type: string or null
What it is: The contact's phone in E.164 with the plus sign.
unsubscribed_by
Type: "contact" | "admin" | "system"
What it is: Who unsubscribed them.
reason
Type: string or null
What it is: The stop keyword the contact sent, meta:marketing_opt_out, bounce:<code>, or null.
| Field | Type | What it is |
|---|---|---|
| contact_id | string or null | The contact, or null for an automatic unsubscribe after a bounce. |
| phone | string or null | The contact's phone in E.164 with the plus sign. |
| unsubscribed_by | "contact" | "admin" | "system" | Who unsubscribed them. |
| reason | string or null | The stop keyword the contact sent, meta:marketing_opt_out, bounce:<code>, or null. |
Unsubscribes from a bulk file upload send no event.
webhook.test
Someone clicked Send test event in the dashboard.
message
Type: string
What it is: A line saying this is a test event.
events
Type: string[]
What it is: The event types SheetWA sends.
| Field | Type | What it is |
|---|---|---|
| message | string | A line saying this is a test event. |
| events | string[] | The event types SheetWA sends. |
Payload#
Each event is a POST with a JSON body: the event type, a timestamp in ISO 8601, and the event's data.
{
"type": "message.received",
"timestamp": "2026-11-26T09:30:12.000Z",
"data": {
"message_id": "MESSAGE_ID",
"chat_id": "CHAT_ID",
"contact_id": "CONTACT_ID",
"phone": "+919876543210",
"profile_name": "Asha",
"message_type": "text",
"text": "Is my order on its way?",
"received_at": "2026-11-26T09:30:11.000Z"
}
}Headers#
SheetWA follows the Standard Webhooks spec. Every call carries three headers:
webhook-id
What it holds: The event's id. It is the same on every retry, so use it to drop repeats.
webhook-timestamp
What it holds: When this attempt was sent, in unix seconds.
webhook-signature
What it holds: v1, a comma, then a base64 signature. It can hold several, separated by spaces.
| Header | What it holds |
|---|---|
| webhook-id | The event's id. It is the same on every retry, so use it to drop repeats. |
| webhook-timestamp | When this attempt was sent, in unix seconds. |
| webhook-signature | v1, a comma, then a base64 signature. It can hold several, separated by spaces. |
Verify the signature#
- 1
Decode the secret
Take the part of the secret after
whsec_and base64-decode it. That is the HMAC key. - 2
Build the signed text
Join
webhook-id, a dot,webhook-timestamp, a dot, then the raw body exactly as it arrived. - 3
Compare
Compute HMAC-SHA256 of that text, base64-encode it, and compare it in constant time with each
v1,value inwebhook-signature. One match is enough. - 4
Check the time
Refuse the call if
webhook-timestampis more than 5 minutes old.
Verify the raw body
Parsing the JSON and turning it back into text changes the bytes and breaks the signature. Read the body as raw bytes, verify, then parse.
import crypto from "node:crypto";
import express from "express";
const secret = Buffer.from(process.env.SHEETWA_WEBHOOK_SECRET.replace(/^whsec_/, ""), "base64");
function verify(rawBody, headers) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
const signatures = headers["webhook-signature"];
if (!id || !timestamp || !signatures) return false;
// Refuse attempts more than 5 minutes away from now, so an old call cannot be replayed.
const sent = Number(timestamp);
if (!Number.isFinite(sent) || Math.abs(Date.now() / 1000 - sent) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(`${id}.${timestamp}.`).update(rawBody).digest();
return signatures.split(" ").some((signature) => {
const [version, value] = signature.split(",");
if (version !== "v1" || !value) return false;
const given = Buffer.from(value, "base64");
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}
const app = express();
// express.raw keeps the body as the exact bytes SheetWA signed.
app.post("/webhooks/sheetwa", express.raw({ type: "application/json" }), (req, res) => {
if (!verify(req.body, req.headers)) return res.status(400).end();
const event = JSON.parse(req.body.toString("utf8"));
// Skip event.type you do not handle, and webhook-id values you have seen before.
console.log(req.headers["webhook-id"], event.type, event.data);
res.status(204).end();
});
app.listen(3000);Answer quickly#
- Answer with any 2xx status within 15 seconds. Do slow work after you answer, for example from a queue.
- Redirects are not followed, so give the final URL.
- Any other answer, or none within 15 seconds, counts as a failed attempt.
Retries#
A failed event is tried up to 10 times. Each retry waits this long after the attempt before it:
1
Wait: At once
2
Wait: 5 seconds
3
Wait: 5 minutes
4
Wait: 30 minutes
5
Wait: 2 hours
6
Wait: 5 hours
7
Wait: 10 hours
8
Wait: 14 hours
9
Wait: 20 hours
10
Wait: 24 hours
| Attempt | Wait |
|---|---|
| 1 | At once |
| 2 | 5 seconds |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
| 6 | 5 hours |
| 7 | 10 hours |
| 8 | 14 hours |
| 9 | 20 hours |
| 10 | 24 hours |
- An endpoint that answers 410 is switched off.
- An endpoint that fails every attempt for 5 days is switched off.
- Switch an endpoint back on in the dashboard once it is fixed.
- The dashboard shows each endpoint's latest deliveries, with a button to resend one.
Replay protection#
- Only act on a call whose signature matches.
- Refuse a call whose
webhook-timestampis more than 5 minutes old, so a copied call cannot be sent again later. - Store the
webhook-idof every event you handle and skip one you have seen. Retries reuse the id, and so would a replayed copy.
Prefer a library? The Standard Webhooks libraries verify SheetWA's calls as they are.