Configure and Manage Webhooks
mainWebhooks allow you to receive WhatsApp events via POST requests to your own server. You can configure multiple webhooks per session, each subscribing to specific events.
Setup and Management
- Create Session with Webhooks: When connecting a session, include a
webhooksarray in the body. Use"events": ["all"]to receive every event. - Add a Webhook:
POST /api/whatsapp/sessions/{sessionId}/webhooks - Remove a Webhook:
DELETE /api/whatsapp/sessions/{sessionId}/webhooks - Update All Webhooks:
PATCH /api/whatsapp/sessions/{sessionId}/config
Webhook Payload Format
{
"event": "message",
"sessionId": "mysession",
"metadata": { "userId": "123" },
"data": { "id": "ABC123", "text": "Hello!" },
"timestamp": "2024-01-15T10:30:00.000Z"
}Webhook Headers
Content-Type: application/jsonX-Webhook-Source: chatery-whatsapp-apiX-Session-Id: <sessionId>X-Webhook-Event: <eventName>
Available Events
connection.update(connected, disconnected)message(new message received)message.sent(message sent confirmation)- Or use
"all"to subscribe to everything.
# Add a webhook to an existing session
curl -X POST http://localhost:3000/api/whatsapp/sessions/mysession/webhooks \
-H "Content-Type: application/json" \
-d '{
"url": "https://new-webhook.com/endpoint",
"events": ["message", "connection.update"]
}'