Webhooks Guide
Real-time event notifications for your email infrastructure
Event Types
email.delivered
Triggered when an email successfully reaches the recipient's mail server.
email.bounced
Triggered when an email fails to deliver. Includes bounce type and code.
email.complained
Triggered when a recipient marks your email as spam. Critical to track.
email.opened
Triggered when the recipient opens your email (via tracking pixel).
email.clicked
Triggered when the recipient clicks a link in your email.
Setting Up Webhooks
1. Create a Webhook Endpoint
Your endpoint must:
- Accept POST requests
- Return 200 OK within 10 seconds
- Accept JSON body
- Verify webhook signature
2. Register Your Endpoint
3. Verify Webhook Signature
Handling Webhooks
PHP Example
⚠️ Process Async
Don't process webhooks synchronously. Queue the webhook event and process from queue. If your processing takes too long, the webhook will timeout and retry.
Retry Behavior
If your endpoint returns non-200 or times out, CloudMails retries with exponential backoff:
- 1st retry: 1 minute
- 2nd retry: 5 minutes
- 3rd retry: 30 minutes
- 4th retry: 2 hours
- 5th retry: 24 hours
✓ Idempotent Handling
Implement idempotent handlers. Webhooks may arrive multiple times. Use message_id to deduplicate.