Skip to Content
WhatsApp API by Retention Stack

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"]}'
FieldRequiredNotes
webhookUrlYesWhere events are POSTed
eventsNoDefaults to ["message"]
hmacKeyNoSecret used to sign each delivery
retriesNo{ "policy": "constant" | "linear" | "exponential", "delaySeconds": 2, "attempts": 3 }. Default: exponential, 2 seconds, 3 attempts.
customHeadersNo[{ "name": "X-Source", "value": "whatsapp" }], added to every delivery

Events

The common ones:

EventWhen
messageA message arrives
message.ackDelivery state of a sent message changes (sent, delivered, read)
session.statusThe 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 2xx quickly 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 an X-Webhook-Hmac header (HMAC of the raw body) and an X-Webhook-Hmac-Algorithm header 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.

Was this page helpful?

On this page