Delivered, bounced, or complained events are not reflected in your internal email state.
Examples for common stacks. Adapt them to your provider contract and framework.
app.post('/webhooks/resend', express.json(), async (req, res) => {
// Apply the authentication contract configured for this Resend endpoint.
const event = req.body;
const eventType = event.type; // e.g. 'email.delivered'
const emailId = event.data?.email_id;
if (!eventType || !emailId) return res.status(400).send('Invalid payload');
// Idempotency — Resend may retry
if (await isEmailEventProcessed(emailId, eventType)) {
return res.status(200).json({ duplicate: true });
}
switch (eventType) {
case 'email.delivered':
await markEmailDelivered(emailId);
break;
case 'email.bounced':
await markEmailBounced(emailId, event.data.bounce_type);
break;
case 'email.complained':
await suppressEmailAddress(event.data.email);
break;
default:
console.log('Unhandled Resend event:', eventType);
}
res.status(200).json({ received: true });
});Provider event timeline → request capture → route handler branch → persistence verification.
Works with webhooks and other async event systems (including AI callbacks). Instead of guessing, inspecting the exact payload and headers can help debug faster.
Try the free webhook testerWas this page helpful?
Your feedback helps us improve the docs.