Prompt
How do I set up webhooks for delivered, bounced, and opened emails?
Latest observation
Nov 21, 2026
OpenAI APIWeb search: off
To set up webhooks for email events like delivered, bounced, and opened, you generally need to do three things:
- Create an HTTPS endpoint on your server to receive webhook POST requests.
- Register that endpoint with your email provider’s webhook/event settings.
- Verify and handle the incoming events in your app.
1) Create a webhook endpoint
Your app needs a public URL that can accept POST requests, for example:
https://yourdomain.com/webhooks/email-events
This endpoint should:
- Return a
2xxresponse quickly - Parse JSON payloads
- Verify the sender/signature if your provider supports it
- Handle retries safely (idempotently)
2) Subscribe to the right events
In your email service dashboard or API, enable events such as:
deliveredbouncedopened
Some providers may also offer:
deferredcomplainedclickedunsubscribed
3) Process the event payload
Your webhook handler should inspect the event type and act accordingly.
Example logic:
- delivered → mark message as delivered
- bounced → mark address as invalid / delivery failed
- opened → log engagement/open tracking
Example webhook handler
Here’s a simple Node.js/Express example:
import express from "express";
const app = express();
app.use(express.json());
app.post("/webhooks/email-events", (req, res) => {
const event = req.body;
switch (event.event || event.type) {
case "delivered":
console.log("Delivered:", event);
break;
case "bounced":
console.log("Bounced:", event);
break;
case "opened":
console.log("Opened:", event);
break;
default:
console.log("Other event:", event);
}
res.sendStatus(200);
});
app.listen(3000, () => console.log("Listening on port 3000"));
Important considerations
- Use HTTPS for your webhook URL.
- Verify authenticity with HMAC signatures or provider-specific headers.
- Deduplicate events because providers may retry deliveries.
- Test with provider tools or by sending test emails.
If you’re using a specific provider
The exact setup depends on your email service, for example:
- SendGrid
- Mailgun
- Postmark
- Amazon SES
- Resend
- SMTP2GO
If you tell me which provider you’re using, I can give you the exact setup steps and a ready-to-use example.