Overview
Resend webhooks notify your application when events occur, such as:- Emails being sent, delivered, or bounced
- Contacts being created, updated, or deleted
- Domains being created, updated, or deleted
Webhook Events
Resend supports the following webhook events:Email Events
string
Triggered when an email is successfully accepted for delivery
string
Triggered when an email is successfully delivered to the recipient’s mail server
string
Triggered when email delivery is temporarily delayed
string
Triggered when a recipient marks an email as spam
string
Triggered when an email bounces (hard or soft bounce)
string
Triggered when a recipient opens an email (requires open tracking)
string
Triggered when a recipient clicks a link in an email (requires click tracking)
string
Triggered when an inbound email is received
string
Triggered when email sending fails
Contact Events
string
Triggered when a new contact is created
string
Triggered when a contact is updated
string
Triggered when a contact is deleted
Domain Events
string
Triggered when a new domain is created
string
Triggered when a domain is updated
string
Triggered when a domain is deleted
Creating a Webhook
Create a webhook to start receiving events at your endpoint.Retrieving a Webhook
Get details about a specific webhook.Get Webhook
Listing Webhooks
Retrieve all webhooks in your account with optional pagination.Updating a Webhook
Update webhook configuration including endpoint, events, and status.Deleting a Webhook
Remove a webhook from your account.Delete Webhook
Receiving and Verifying Webhooks
Webhooks are sent as POST requests to your endpoint. Always verify webhook signatures to ensure they’re from Resend.Webhook Headers
Resend includes three important headers with each webhook:string
Unique identifier for the webhook message
string
Unix timestamp when the webhook was sent
string
HMAC-SHA256 signature for verifying authenticity
Verification Method
The SDK provides aVerify method that implements HMAC-SHA256 signature verification:
Webhook Receiver
How Verification Works
TheVerify method implements the following security checks:
1
Timestamp Validation
Verifies the webhook timestamp is within 5 minutes to prevent replay attacks.
2
Signature Construction
Constructs the signed content from the webhook data:
3
HMAC-SHA256 Calculation
Computes the expected signature using your webhook secret:
4
Constant-Time Comparison
Safely compares signatures to prevent timing attacks:
Complete HTTP Server Example
Here’s a complete example of a webhook receiver server:Webhook Server
Event Payload Examples
Here are examples of webhook payloads for different events:email.sent
email.sent
email.delivered
email.delivered
email.bounced
email.bounced
contact.created
contact.created
Error Handling
Robust Webhook Verification
Best Practices
Always Verify Signatures
Never process webhooks without verifying their signature to prevent spoofing attacks.
Use HTTPS Endpoints
Always use HTTPS endpoints for webhooks to ensure data is encrypted in transit.
Respond Quickly
Return a 200 OK response immediately and process events asynchronously.
Handle Retries
Implement idempotency to handle duplicate webhook deliveries gracefully.
Store Signing Secrets Securely
Store webhook secrets in environment variables or secret management systems.
Monitor Webhook Health
Log webhook events and set up alerts for verification failures.
Testing Webhooks
1
Use ngrok for Local Testing
Expose your local server to the internet:Then create a webhook with the ngrok URL:
2
Send Test Emails
Trigger webhook events by sending test emails:
3
Monitor Logs
Watch your server logs to see webhook events arriving:
Next Steps
Email Events
Learn about sending emails and triggering events
Broadcasts
Send campaigns and receive broadcast events
Webhook Example
View the complete webhook receiver example
API Reference
View the complete Webhooks API reference