Introduction
Webhooks allow your application to receive real-time notifications when events occur in your EnviaAI account. Instead of polling our API, webhooks push data to your server instantly.Setting Up Webhooks
1. Create a Webhook Endpoint
Your server needs an endpoint to receive webhook events. This endpoint must:- Accept POST requests
- Return a 2xx status code quickly (within 5 seconds)
- Be publicly accessible via HTTPS
2. Configure Your Webhook
Configure your webhook URL in the dashboard or via API:3. Verify Webhook Signatures
All webhook requests include a signature header for verification:Webhook Events
Message Events
message.received
message.received
Triggered when a new message is received.
message.sent
message.sent
Triggered when your message is sent to WhatsApp.
message.delivered
message.delivered
Triggered when your message is delivered to the recipient.
message.read
message.read
Triggered when the recipient reads your message.
message.failed
message.failed
Triggered when message delivery fails.
Instance Events
instance.connected
instance.connected
Triggered when an instance connects to WhatsApp.
instance.disconnected
instance.disconnected
Triggered when an instance disconnects from WhatsApp.
instance.qr_updated
instance.qr_updated
Triggered when a new QR code is generated.
Webhook Configuration
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/webhooks | Create a new webhook |
| GET | /v1/webhooks | List all webhooks |
| GET | /v1/webhooks/{id} | Get webhook details |
| PUT | /v1/webhooks/{id} | Update a webhook |
| DELETE | /v1/webhooks/{id} | Delete a webhook |
Webhook Object
Retry Policy
If your endpoint fails to respond with a 2xx status code, we’ll retry the webhook:| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | 30 seconds |
| 3 | 2 minutes |
| 4 | 10 minutes |
| 5 | 1 hour |
| 6 | 6 hours |
Best Practices
Respond Quickly
Return a 2xx response within 5 seconds. Process events asynchronously.
Verify Signatures
Always verify the webhook signature to ensure authenticity.
Handle Duplicates
Implement idempotency using the
messageId or eventId.Log Everything
Log all webhook events for debugging and auditing.