Webhooks
A webhook sends an HTTP POST to your server whenever something happens on a session: a message arrives, a message is sent or read, or a session connects. Use it to feed a CRM, run a bot, or trigger an n8n/Zapier/Make flow.

Adding a webhook
Webhooks → Add webhook (admins only):
- URL: your endpoint,
http://orhttps://. - Session: one session, or All sessions.
- Events: any of the four below.
Each webhook gets its own signing secret (whsec_…) to verify requests. Use the switch to pause a webhook without deleting it; events that happen while it's paused are not sent. Click Send test to send a webhook.test event.
Events
| Event | When |
|---|---|
message.received | A message arrives. Photos, videos, audio and documents are downloaded first and linked in media. |
message.sent | A message is sent, from the API, the inbox or the phone itself. |
message.status | A message you sent is delivered, read or played. |
session.status | A session is connecting, connected or disconnected. |
Payload
Every request has the same envelope:
{
"event": "message.received",
"session": "sales",
"timestamp": "2026-12-01T10:21:00.000Z",
"data": { }
}{
"id": "3EB0C4F1A2",
"chat": "6281234567890@s.whatsapp.net",
"chat_alt": null,
"from": "6281234567890@s.whatsapp.net",
"from_alt": null,
"from_me": false,
"is_group": false,
"push_name": "Emma Wilson",
"type": "image",
"text": "Here is the photo",
"media": { "type": "image", "file": "3EB0C4F1A2.jpg", "url": "/media/3EB0C4F1A2.jpg" },
"timestamp": 1764584460
}{
"id": "3EB0C4F1A2",
"chat": "6281234567890@s.whatsapp.net",
"from_me": true,
"status": "read"
}{ "status": "connected" }Fields of a message:
| Field | |
|---|---|
chat | Where the message was sent: a contact (…@s.whatsapp.net) or a group (…@g.us). Reply to this. |
from | Who sent it. In groups this is the member, otherwise the same as chat. |
chat_alt, from_alt | Newer WhatsApp accounts may appear as …@lid ids. When they do, these carry the phone-number form if WhatsApp provides it. |
type | text, image, video, audio, document, sticker, location, contact, pollCreation, … |
text | The text or caption, or null. |
media | For incoming media: the file saved in the media/ folder, downloadable at https://YOUR_SERVER{url}. null otherwise. |
timestamp | Unix seconds. |
status in message.status is one of server, delivered, read, played (voice notes) or error.
Verifying requests
Every request carries these headers:
| Header | |
|---|---|
x-wag-event | The event name. |
x-wag-delivery | A unique delivery ID, the same across retries. Use it to ignore duplicates. |
x-wag-signature | sha256= + the HMAC-SHA256 of the raw request body, keyed with the webhook's signing secret. |
Compute the HMAC over the body exactly as received, before parsing JSON:
import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.WAG_SECRET; // whsec_…
app.post("/webhooks/whatsapp", express.raw({ type: "application/json" }), (req, res) => {
const expected = "sha256=" + crypto.createHmac("sha256", SECRET).update(req.body).digest("hex");
const given = req.get("x-wag-signature") ?? "";
if (given.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))) {
return res.sendStatus(401);
}
const { event, session, data } = JSON.parse(req.body);
console.log(event, session, data);
res.sendStatus(200);
});
app.listen(3000);import hashlib, hmac, os
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["WAG_SECRET"].encode() # whsec_…
@app.post("/webhooks/whatsapp")
def whatsapp():
expected = "sha256=" + hmac.new(SECRET, request.get_data(), hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, request.headers.get("x-wag-signature", "")):
abort(401)
payload = request.get_json()
print(payload["event"], payload["session"], payload["data"])
return "", 200<?php
$secret = getenv('WAG_SECRET'); // whsec_…
$body = file_get_contents('php://input');
$expected = 'sha256=' . hash_hmac('sha256', $body, $secret);
if (!hash_equals($expected, $_SERVER['HTTP_X_WAG_SIGNATURE'] ?? '')) {
http_response_code(401);
exit;
}
$payload = json_decode($body, true);
error_log($payload['event'] . ' ' . $payload['session']);
http_response_code(200);Retries and the delivery log
Reply with any 2xx status within 10 seconds. Otherwise the delivery is retried after 10 s, 30 s, 2 min, 10 min and 30 min (about 40 minutes in total) before it's marked as failed. Deliveries survive restarts.
Click Deliveries on a webhook to see the last 50 requests with their payload, response status and body, and Resend any of them. Deliveries are kept for 7 days.

Developing a webhook?
The Events monitor shows the same payloads live in the browser, without any receiver.
Legacy webhook (v4)
The v4 global webhook still works for existing setups. Set WEBHOOK_BASE_URL and the gateway posts, without signatures or retries:
{WEBHOOK_BASE_URL}/sessionwith{ "session", "status" }on every status change;{WEBHOOK_BASE_URL}/messagewith{ "session", "from", "from_alt", "message", "media": { "image", "video", "document", "audio" } }for incoming messages.
The key header carries the KEY environment variable. New integrations should use the webhooks above.