Skip to main content

What are Webhooks?

Webhooks allow Evolution API to send real-time notifications to your application when events occur in WhatsApp. Instead of polling for updates, your application receives HTTP POST requests with event data as it happens. Evolution API provides:
  • 40+ event types covering messages, contacts, groups, and connection status
  • Automatic retry logic with exponential backoff
  • Custom headers for authentication
  • Event filtering to receive only the events you need
  • Global and per-instance webhook configurations
Webhooks are the recommended way to build responsive WhatsApp applications. They ensure zero message loss and real-time user experiences.

Webhook Configuration

Global Webhooks

Configure webhooks for all instances via environment variables:
When WEBHOOK_BY_EVENTS=true, each event is sent to a unique URL:
  • Messages: https://your-app.com/webhook/messages-upsert
  • Contacts: https://your-app.com/webhook/contacts-upsert
  • Connection: https://your-app.com/webhook/connection-update

Per-Instance Webhooks

Configure webhooks when creating an instance:

Update Existing Instance Webhook

Available Events

Evolution API supports over 40 webhook events. Here are the most important ones:

Instance Events

Message Events

Contact Events

Chat Events

Group Events

Other Events

Configure Events in .env

Disable high-volume events like MESSAGES_SET, CONTACTS_SET, and CHATS_SET in production to reduce webhook traffic. These events fire during initial sync and can send thousands of payloads.

Webhook Payload Structure

All webhook requests follow this structure:

Message Received Example

Connection Update Example

QR Code Updated Example

Webhook Authentication

Secure your webhook endpoint using custom headers:

Bearer Token Authentication

In your webhook handler:

JWT Authentication

Evolution API can automatically generate JWT tokens for each request:
From the source code (src/api/integrations/event/webhook/webhook.controller.ts:80):
Verify in your handler:

Retry Logic and Error Handling

Evolution API includes sophisticated retry logic to ensure reliable webhook delivery.

Retry Configuration

How Retry Works

From src/api/integrations/event/webhook/webhook.controller.ts:203:
With default settings, Evolution API will retry for up to 30+ minutes before giving up:
  • Attempt 1: Wait 5s
  • Attempt 2: Wait 10s
  • Attempt 3: Wait 20s
  • Attempt 10: Wait 300s (5 min)

Error Webhooks

Receive notifications when errors occur:

Implementing a Webhook Handler

Best Practices

Your webhook endpoint should return 200 OK as quickly as possible:
If you return an error status, Evolution API will retry the webhook, potentially causing duplicates.
Handle duplicate webhooks gracefully using message IDs:
Only enable events you actually use to reduce webhook traffic:
Avoid enabling MESSAGES_SET, CONTACTS_SET, and CHATS_SET unless you need historical sync.
For high-volume webhooks, use a queue to prevent blocking:
Validate webhooks are from your Evolution API:
Track webhook delivery and errors:

Testing Webhooks

Using ngrok for Local Development

1

Install ngrok

2

Start Your Webhook Server

3

Expose with ngrok

Copy the HTTPS URL:
4

Configure Webhook

5

Test Events

Send a test message to your WhatsApp and watch webhooks arrive in real-time.

Webhook Testing Tools

  • Webhook.site - Inspect webhook payloads without code
  • RequestBin - Collect and debug webhooks
  • Postman - Mock webhook servers for testing

Next Steps

Instances

Learn how to create and manage instances

Authentication

Secure your API with authentication

Multi-Tenant

Build multi-tenant applications

Message Events

Explore message API endpoints