Webhooks
Receive messages, delivery receipts and session status.
Register a URL per session (use HTTPS in production):
curl -X POST https://wp-rapidapi.retentionstack.agency/v1/sessions/SESSION_NAME/webhooks \
-H "Authorization: Bearer ak_live_YOUR_ACCOUNT_KEY" -H "Content-Type: application/json" \
-d '{"webhookUrl": "https://your-server.example/webhooks/whatsapp", "events": ["message", "message.ack", "session.status"]}'| Field | Required | Notes |
|---|---|---|
webhookUrl | Yes | Where events are POSTed |
events | No | Defaults to ["message"] |
hmacKey | No | Secret used to sign each delivery |
retries | No | { "policy": "constant" | "linear" | "exponential", "delaySeconds": 2, "attempts": 3 }. Default: exponential, 2 seconds, 3 attempts. |
customHeaders | No | [{ "name": "X-Source", "value": "whatsapp" }], added to every delivery |
Events
The common ones:
| Event | When |
|---|---|
message | A message arrives |
message.ack | Delivery state of a sent message changes (sent, delivered, read) |
session.status | The session status changes, for example to WORKING or PASSKEY_REQUIRED |
Also accepted: message.any, message.reaction, message.waiting, message.revoked, message.edited, chat.archive, group.join, group.leave, group.v2.join, group.v2.leave, group.v2.update, group.v2.participants, presence.update, poll.vote, poll.vote.failed, call.received, call.accepted, call.rejected, label.upsert, label.deleted, label.chat.added, label.chat.deleted. An unknown event name returns 400 with the supported list.
Each delivery is a JSON body with event, session and payload.
Handling deliveries
- Return
2xxquickly and do the work afterwards. Failed deliveries are retried. - Retries mean the same event can arrive twice: deduplicate on the message ID.
- If you set
hmacKey, each delivery carries anX-Webhook-Hmacheader (HMAC of the raw body) and anX-Webhook-Hmac-Algorithmheader naming the hash. Recompute it with your key and compare before trusting the body.
Removing a webhook
Send DELETE to the same path with the same webhookUrl in the JSON body. An unknown URL returns 404; other webhooks on the session stay registered.