Configuration
You can configure webhooks globally (for all instances) or per-instance. Configure webhooks through environment variables or the API.Global Webhook Settings
Set these environment variables to enable global webhooks:.env
WEBHOOK_GLOBAL_WEBHOOK_BY_EVENTS=true, events are sent to:
https://your-domain.com/webhook/qrcode-updatedhttps://your-domain.com/webhook/messages-upsert- etc.
Request Configuration
Configure webhook request behavior:.env
Retry Configuration
Evolution API implements intelligent retry logic with exponential backoff:.env
The retry mechanism uses exponential backoff: each retry waits longer than the previous one. Jitter adds randomness to prevent thundering herd problems.
Available Events
Configure which events trigger webhook notifications:- Instance Events
- Message Events
- Contact Events
- Chat & Group Events
- Other Events
.env
Per-Instance Configuration
Configure webhooks for a specific instance via API:Configuration Options
enabled
enabled
Set to
true to enable webhooks for this instance.url
url
Your webhook endpoint URL. Must start with
http:// or https://.byEvents
byEvents
When
true, appends the event name to the URL:false: All events go tohttps://your-domain.com/webhooktrue: Events go tohttps://your-domain.com/webhook/event-name
base64
base64
When
true, media files are sent as base64-encoded strings in the payload.headers
headers
Custom HTTP headers to include in webhook requests. Useful for authentication.
events
events
Array of event names to receive. Leave empty or omit to receive all events.
Authentication
JWT Authentication
You can use JWT tokens for webhook authentication. Add ajwt_key header:
- Generate a JWT token signed with your secret key
- Add it as
Authorization: Bearer <token>header - Token expires after 10 minutes
Validating JWT Tokens
Webhook Payload Structure
All webhook requests include the following structure:Example Payloads
MESSAGES_UPSERT - New Message
MESSAGES_UPSERT - New Message
QRCODE_UPDATED - QR Code
QRCODE_UPDATED - QR Code
CONNECTION_UPDATE - Connection Status
CONNECTION_UPDATE - Connection Status
Best Practices
Respond Quickly
Your webhook endpoint should respond with HTTP 200-299 within the timeout period. Process data asynchronously if needed.
Handle Retries Gracefully
Implement idempotency in your webhook handler. Use the message ID or event timestamp to avoid processing duplicates.
Secure Your Endpoint
- Use HTTPS for your webhook URL
- Validate JWT tokens or custom headers
- Whitelist Evolution API’s IP addresses if possible
Troubleshooting
Webhooks not being received
Webhooks not being received
- Check that
WEBHOOK_GLOBAL_ENABLED=trueor instance webhook is enabled - Verify your URL is accessible from the internet
- Check the specific event is enabled in configuration
- Review Evolution API logs for delivery errors
- Ensure your endpoint responds with HTTP 200-299
Duplicate events
Duplicate events
This is normal behavior when retries occur. Implement idempotency using message IDs or timestamps to handle duplicates.
Events arriving out of order
Events arriving out of order
Network delays can cause events to arrive out of order. Use the
date_time and messageTimestamp fields to order events correctly.Large payload errors
Large payload errors
If you’re receiving media files, consider:
- Setting
base64: falseto receive media URLs instead of base64 data - Increasing
WEBHOOK_REQUEST_TIMEOUT_MSfor large payloads - Downloading media asynchronously from URLs