Webhooks Overview & Quickstart
Receive incoming messages, delivery reports, and real-time WhatsApp events on your application backend via secure HTTP Webhooks.
Event-Driven Real-Time Delivery
The Wahide Webhook Engine automatically streams incoming 1-on-1 WhatsApp messages, delivery receipts, and device status updates directly to your backend endpoint in high-speed, zero-heap JSON format.
1. How Wahide Webhooks Work
When an event occurs on your connected WhatsApp devices (inbound message, status delivery tick, device disconnect, or QR stream), the Wahide engine immediately processes the event through a resilient, event-driven pipeline:
1. **Zero-Heap Event Filtering**: Unnecessary noisy events (groups, stories, channel newsletters) are filtered out to protect your server from overload.
2. **Standardized JSON Envelope**: The event data, device identifier, sender details, and timestamps are packaged into a structured schema.
3. **Asynchronous HTTP POST Delivery**: Wahide dispatches an HTTP POST request to the webhook URL configured in your dashboard.
4. **Instant Acknowledgment**: Your server acknowledges receipt by returning an HTTP `200 OK` response within 8 seconds.
Public HTTPS Endpoint & n8n / AI Bot Integration
Your webhook URL must be publicly accessible over valid HTTPS. For local development, use tunneling solutions such as Cloudflare Tunnels or Ngrok.
š” **Building with n8n or AI Agents (OpenAI/Claude)?** Check out our dedicated [n8n AI Chatbot & Automation Guide](/docs/webhooks/n8n) with a ready-to-import zero-timeout workflow template.
2. Security & Header Verification
To verify that incoming requests genuinely originate from Wahide and protect your endpoint from spoofing or replay attacks, Wahide includes standard HTTP authentication headers on every request:
Mandatory Server Validation
Always verify that the secret key in the `X-Wahide-Secret` header matches your configured Webhook Secret before processing payloads.
HTTP Request Headers from Wahide
POST /api/webhook/whatsapp HTTP/1.1
Host: api.your-business.com
Content-Type: application/json
User-Agent: Wahide-WhatsApp-Webhook-Engine/2.0
X-Wahide-Secret: whsec_live_9f8e7d6c5b4a3210fedcba9876543210
X-Wahide-Delivery-ID: 01JPLAN0000000000000000099
X-Wahide-Event: message.received
X-Wahide-Device-ID: 01JPLAN0000000000000000001
X-Wahide-Timestamp: 17258450003. Automatic Retry Policy, Circuit Breaker & DLQ
Wahide employs an enterprise-grade delivery resilience pipeline to ensure zero dropped messages:
- **Circuit Breaker Protection**: If a destination endpoint experiences 5 consecutive failures (timeout or 5xx error), the circuit trips to **OPEN** state for 30 seconds. Outbound requests are immediately dropped with HTTP 503 without holding connection sockets or worker threads.
- **Jittered Exponential Backoff**: Retries are attempted up to **5 times** with increasing intervals (3s, 6s, 12s, 24s, 48s plus random jitter to prevent thundering-herd issues).
- **Dead Letter Queue (DLQ)**: If all 5 attempts fail, the failed event is preserved in the in-memory DLQ with strict per-tenant bounds (up to 200 items), allowing inspection and manual replay.
4. Granular Event Subscriptions Catalog
Wahide allows you to subscribe strictly to events your application needs, eliminating unnecessary server load. Click on any event below to view its dedicated payload schema, parameter table, and language code examples:
- [ā” Event: message.received](/docs/webhooks/events/message-received) (*Default ON*): Inbound 1-on-1 customer messages, including direct streaming of photos and PDF documents from Cloudflare R2.
- [ā” Event: message.ack](/docs/webhooks/events/message-ack) (*Optional*): Real-time delivery receipt checkmarks (Sent to server, Delivered double-check, Read blue tick).
- [ā” Event: message.sent](/docs/webhooks/events/message-sent) (*Optional*): Outbound dispatch confirmation from device to WhatsApp network.
- [ā” Event: device.status](/docs/webhooks/events/device-status) (*Default ON*): Device connection lifecycle updates (ONLINE, OFFLINE, HIBERNATED, LOGGED_OUT).
- [ā” Event: device.qr](/docs/webhooks/events/device-qr) (*Optional*): Live streaming Base64 QR code frames for custom web pairing interfaces.
5. Multi-Device Routing: Tenant Webhook vs Device Webhook
Wahide provides a flexible **2-Tier Hierarchical Routing** architecture designed to support both centralized automation platforms (such as n8n, Make, and Zapier) and complex multi-department enterprise setups:
### 1. The Two Webhook Tiers Explained
- **Tenant Webhook (Default / Workspace Level)**:
- Configured at **Dashboard Settings (`/settings`) ā Webhook Integration**.
- Authenticated with `X-Wahide-Secret: whsec_live_<32 hex>`.
- Acts as the central mailbox: **All WhatsApp devices in your workspace automatically route here by default**.
- **Device Webhook (Specific Hardware Override)**:
- Configured at **Device Details (`/devices`) ā Override Webhook**.
- Authenticated with `X-Wahide-Secret: whsec_dev_<32 hex>`.
- When set, incoming traffic for that specific phone number bypasses the tenant webhook and routes directly to a dedicated system (e.g. Accounting ERP, Freshdesk, or CRM).
### 2. How Wahide Selects Where to Deliver Events
```
[Incoming WhatsApp Message on Device A]
ā
ā¼
Does Device A have a custom Webhook URL set?
ā
āāāāāāāāāāāā“āāāāāāāāāāā
ā¼ (YES) ā¼ (NO / Empty)
[Route to Device URL] [Route to Workspace Default URL]
(Secret: whsec_dev_...) (Secret: whsec_live_...)
```
### 3. Which Webhook Should You Use?
| Business Use-Case | Recommended Webhook | Rationale |
|---|---|---|
| **n8n / Make / AI Chatbot** | **Tenant Webhook (`/settings`)** | Wahide includes `device_id` inside the JSON payload. A single n8n workflow can handle all devices and route dynamically using Switch or IF nodes. |
| **Single Backend API** | **Tenant Webhook (`/settings`)** | Zero maintenance: adding new WhatsApp devices requires no webhook reconfiguration. |
| **Multi-Department Enterprise** | **Device Webhook (`/devices`)** | When Customer Support uses n8n, but the Finance team requires payment receipts delivered to an internal on-premise ERP. |
### 4. Granular Event Inheritance
If you specify a custom Webhook URL on a device but leave its subscribed events empty, the device automatically inherits the workspace event whitelist. If you check specific events on the device, only those selected events will be delivered to that device's URL.
Best Practice for Automation (n8n / Make / Zapier)
For 95% of use-cases, configure only the **Tenant Webhook in `/settings`** and leave the webhook fields in `/devices` empty. One centralized receiver handles all incoming WhatsApp lines seamlessly.
6. Media Attachment Pipeline (Cloudflare R2)
Customer photos (JPEG, PNG, WebP) and PDF documents (up to 1 MB) are automatically decrypted in-memory and streamed directly to Cloudflare R2 object storage:
- **$0 Egress Bandwidth**: Direct downloads via Cloudflare global edge CDN at zero bandwidth cost.
- **Pre-Download Inspection**: Files larger than 1 MB or unsupported types (video, voice notes) are safely dropped before consuming gateway bandwidth, delivering a `media_error` diagnostic code.
- **Auto-Purge Lifecycle**: Media objects reside under the `tmp/` prefix and are automatically deleted after 7 days.
7. Receiver Server Boilerplate (All Languages)
Select your backend language below to view a production-ready webhook receiver boilerplate featuring header verification, text handling, media attachment downloading, and instant HTTP 200 OK acknowledgments.
Webhook Receiver Boilerplate & Simulation
request.sh
curl -X POST "http://localhost:3000/api/webhook/whatsapp" \
-H "Content-Type: application/json" \
-H "X-Wahide-Secret: whsec_live_9f8e7d6c5b4a3210fedcba9876543210" \
-d '{
"event": "message.received",
"device_id": "01JPLAN0000000000000000001",
"timestamp": 1725845000,
"data": {
"message_id": "3EB0A1B2C3D4E5F6",
"sender": "6281234567890",
"sender_jid": "6281234567890@s.whatsapp.net",
"push_name": "John Doe",
"text": "Please check the attached payment receipt",
"has_media": true,
"media": {
"type": "image",
"url": "https://pub-r2.wahide.com/tmp/whatsapp-media/01JPLAN000/2026/09/01JPLANXYZ123456.jpg",
"file_name": "payment_receipt.jpg",
"mime_type": "image/jpeg",
"file_size": 245120
},
"timestamp": 1725844998
}
}'On this page