sepiasend Sign in

blog / product

Webhooks: know what happened to each email

By Tamas Kalman · · 4 min read

Your server hears about each email: sent, delivered, bounced, complained, suppressed or failed. The request is signed the same way Resend signs one, so an app that already checks Resend webhooks keeps that code. Field by field, the reference is Webhooks for Cloudflare Email Sending.

Which events are there?

Six. Leave events out of the API call, or leave every box ticked in the dashboard, and you get all of them. Name a shorter list and you get only those.

eventwhen it arrives
email.sentat once, when Cloudflare accepts the email
email.failedat once, when Cloudflare refuses it
email.delivered5 to 10 minutes later, when the recipient's server takes it
email.bounced5 to 10 minutes later, when that server rejects it. data.bounce.message says why
email.suppressed5 to 10 minutes later, when Cloudflare does not send it, for example because the address is already suppressed
email.complainedwhen Cloudflare reports that the recipient marked it as spam

Delivered, bounced and suppressed come from Cloudflare's sending log. A complaint is not in that log, so it cannot be polled out of it. Cloudflare pushes it. Opens and clicks are not events: Sepiasend does not track them. Resend's own list is wider (clicks, delays, and suppression added or removed); the six above are the ones Sepiasend sends. Resend's names and definitions are in its event types.

How do I add one?

  1. In the dashboard under webhooks, with the API, or through the MCP server, add an https endpoint.
  2. Copy the whsec_ signing secret. It is shown once.
  3. Verify each request with resend.webhooks.verify() on the raw body, then handle the event type.
curl -X POST https://api.sepiasend.com/webhooks \
  -H "Authorization: Bearer $SEPIASEND_KEY" -H "Content-Type: application/json" \
  -d '{"endpoint": "https://app.example.com/webhooks/email", "events": ["email.bounced", "email.complained"]}'

The answer is { "object": "webhook", "id": "...", "signing_secret": "whsec_..." }. Any key with full access can add one. The same call works from Claude, ChatGPT or another MCP client as create_webhook.

How do I verify it?

Use the raw body. A framework that parses the JSON and stringifies it again will break the signature, which is the same rule Resend documents for its own webhooks.

import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);
const event = resend.webhooks.verify({
  payload: rawBody,
  headers: {
    id: req.headers['svix-id'],
    timestamp: req.headers['svix-timestamp'],
    signature: req.headers['svix-signature'],
  },
  webhookSecret: process.env.SEPIASEND_WEBHOOK_SECRET,
});

If your server does not answer with a success status, Sepiasend tries the same delivery again and keeps the same svix-id, so you can drop the repeat. The retry schedule is on the reference page.

What happens when someone hits spam?

This is the event that was missing, and the reason for it is practical: an app that unsubscribes on email.complained never hears about the complaint if the event does not exist. Cloudflare does suppress the address, so a later send fails, but the first webhook your app was waiting for never came.

Cloudflare will not post that complaint to Sepiasend. It publishes message.complained onto a queue in your Cloudflare account. While at least one of your webhooks includes email.complained, Sepiasend keeps a queue and a Worker there, both named sepiasend-complaints, and one subscription per sending domain. The Worker posts the complaint to Sepiasend, and Sepiasend signs it and sends email.complained to your endpoint. You can see that Worker in your Cloudflare account and delete it; the next pass creates it again while a webhook still asks for the event.

A domain you turn on later gets a subscription too. Delete the last webhook that includes the event, and the subscriptions, the Worker and the queue are removed. If you never ask for complaints, none of that is created.

The first time, sign in to Cloudflare again and approve Queues and Workers Scripts. Until you do, the webhook is saved, the other events still arrive, and the webhooks page says what to approve. An account that uses an API token instead of sign-in needs Queues Write and Workers Scripts Write on that token.

subject may be empty, because Cloudflare's complaint event does not include one. When Sepiasend sent the email, data.email_id is the id the send call returned. If the complaint does not name that email, the event still arrives, with the id Cloudflare sent. Cloudflare also suppresses the address, with no expiry, so a later send to it is email.suppressed. The emails page keeps the status from the sending log, which for a delivered message that was later marked as spam is still delivered.

One complaint is three queue operations (write, read, delete) when the body is under 64 KB. The Workers Paid plan you already need to send includes the first million operations a month, then $0.40 per million, and the first 10,000 queues. Complaints alone stay inside that, so this queue costs $0. Cloudflare's numbers are on its Queues pricing page. The event itself is Email Sending's event subscriptions: one subscription per sending domain, and the queue lives in the account that sends.

Which plans include webhooks?

Every plan, including Free. Plans differ by how many emails you can send in a month, not by whether events arrive. Bounces and complaints are the two worth acting on: stop sending to an address that bounced, and treat a complaint as the person asking you to stop. More on what you still control is in will it land in spam?

Questions

What webhook events does Sepiasend send?

Six: email.sent, email.delivered, email.bounced, email.complained, email.suppressed and email.failed. Leave the event list empty and you get all six. Name the ones you want and you get only those.

Can I verify Sepiasend webhooks with the Resend SDK?

Yes. The body and the svix-id, svix-timestamp and svix-signature headers match Resend's, signed with the whsec_ secret you get when you add the webhook. resend.webhooks.verify() accepts the raw body unchanged.

How fast do the webhooks arrive?

email.sent and email.failed arrive as soon as Cloudflare answers the send. email.complained arrives when Cloudflare reports that the recipient marked the email as spam. email.delivered, email.bounced and email.suppressed are read from Cloudflare's log and arrive 5 to 10 minutes after the event, each once.

What happens when someone marks an email as spam?

You get email.complained, if a webhook includes that event. The subject may be empty. Cloudflare also suppresses the address, so a later send to it is email.suppressed. The emails list still shows the status from the sending log, usually delivered.

What does Sepiasend put in my Cloudflare account for complaints?

Only while a webhook includes email.complained: a queue and a Worker, both named sepiasend-complaints, and one subscription per sending domain. They are removed when no webhook includes that event. The first time, sign in to Cloudflare again and approve Queues and Workers Scripts. The webhook is saved either way.

Do webhooks cost extra?

No. Webhooks are on every plan, Free included. A spam complaint uses three queue operations on the Workers Paid plan you already need to send. Cloudflare includes the first million operations a month, so complaints alone cost $0.

Previous post: draft mode

Try Sepiasend Event reference