Webhooks
Receive a signed event for every delivery, bounce and complaint. Set up an endpoint, verify signatures, handle retries and rotate the signing secret.
A webhook sends your application a signed POST for each event you subscribe to: an email
delivered, delayed, bounced or complained about, or a domain whose status changed. Webhooks
are how your application learns the result of an email without asking the API.
Set up an endpoint
-
Add a route to your application that accepts
POSTrequests, for examplehttps://acme.com/webhooks/exx. It must be reachable from the internet over a public address; exx.sh refuses URLs with credentials in them or a private IP address. -
Create the webhook in the dashboard under Webhooks, or with
POST /webhooks, choosing the events you want:curl -X POST https://api.exx.sh/webhooks \ -H "Authorization: Bearer $EXX_API_KEY" \ -H "Content-Type: application/json" \ -d '{"endpoint": "https://acme.com/webhooks/exx", "events": ["email.delivered", "email.bounced", "email.complained"]}' -
Store the signing secret (
whsec_...) from the answer in your application's environment. Your route verifies every delivery with it, as shown below. -
Send an email and watch the events arrive. The dashboard lists each delivery with its answer, and can replay it.
Events
| Event | When |
|---|---|
email.sent | The message is accepted and queued for its recipients; a scheduled one when its time comes and it goes out. |
email.scheduled | The message waits for its scheduled_at; sent again when you reschedule it. |
email.delivered | A recipient's server accepted it (one event per recipient). |
email.delivery_delayed | A recipient's server deferred it (sent once, on the first deferral); exx.sh keeps trying. |
email.bounced | A recipient's server refused it, now or later (bounce.type: Permanent or Temporary). |
email.complained | The recipient marked it as spam (feedback loops). |
email.failed | A permanent failure that is not a bounce: no MX, expired, or refused by policy (failed.reason). |
email.suppressed | The recipient is on the suppression list, so nothing was sent. |
email.opened, email.clicked | Optional tracking: the first open or first click per link, then one more for the first human hit if a machine came first. Payloads add first and machine. |
domain.created, domain.updated, domain.deleted | A domain changed (its status, for example). |
contact.created, contact.updated, contact.deleted | A contact was added, changed (a field, its subscription, a property or a segment) or deleted. Contacts added by an import send none, and deleting a property, a segment or an audience sends no contact.updated for the contacts it touched. |
email.received | Mail arrived at your project's address or one of its receiving domains: its metadata; fetch the content as shown in receiving email. |
Separate topic events are not emitted or accepted; a contact's topic choice sends
contact.updated. Broadcast mail carries broadcast_id on its email events, with no
separate broadcast.* event. See tracking
for machine hits and the limits of open measurements.
Only some domains
A project that sends from several domains can give each its own webhook. List the domains
in domains when you create or update the webhook (an exx.sh addition; Resend has none):
curl -X POST https://api.exx.sh/webhooks \
-H "Authorization: Bearer $EXX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"endpoint": "https://acme.com/webhooks/marketing", "events": ["email.delivered", "email.bounced"], "domains": ["news.acme.com"]}'The webhook then receives the email.* events of emails sent from those domains and the
domain.* events about them. Events about the whole project, such as the contact.*
events and exx.project.paused, reach it always. Each name must be a domain of the project (how many a
webhook can list is in Handle events). An unknown name is refused with
its position:
`domains[1]`: `acme.co` is not a domain of this projectWithout domains, or with null or an empty list, the webhook receives the events of
every domain. PATCH /webhooks/{id} with "domains": null removes the filter; a PATCH
without domains keeps it.
If you delete a listed domain, it stays in the webhook's domains, so the list never turns
into "every domain". The webhook still gets the domain.deleted event and the last events
of emails already sent from it, then nothing new. Sending that list back in a PATCH is
refused, naming the deleted domain: remove it from the list. Adding the domain again
creates a new domain, so list it again.
Payload
{
"type": "email.delivered",
"created_at": "2026-11-01T10:00:00.000Z",
"data": {
"created_at": "2026-11-01T09:59:58.000Z",
"email_id": "0192f1a2-3b4c-7d5e-8f60-123456789abc",
"message_id": "<0192f1a2-3b4c-7d5e-8f60-123456789abc@acme.com>",
"from": "Acme <hello@acme.com>",
"to": ["delivered@example.com"],
"subject": "Your sign-in link",
"tags": { "category": "sign_in" }
}
}to holds the recipients the event is about. email.bounced adds
bounce: { message, type, subType, diagnosticCode[] } with the remote server's exact reply.
email.scheduled, email.failed and email.suppressed carry no message_id. The body has
no scheduled_at: read it from GET /emails/{id}.
Verify each delivery
Every delivery carries svix-id, svix-timestamp and svix-signature headers (Standard
Webhooks). Verify them against the raw body before you parse it:
import { Exx, WebhookVerificationError } from "@exx.sh/sdk";
const exx = new Exx(process.env.EXX_API_KEY);
// A fetch-style handler (Bun, Deno, Workers, Next.js route handlers).
export async function POST(request: Request): Promise<Response> {
try {
const event = await exx.webhooks.verify({
payload: await request.text(), // the raw body, before any JSON parsing
headers: request.headers,
webhookSecret: process.env.EXX_WEBHOOK_SECRET ?? "",
});
console.log(event);
return new Response(null, { status: 204 });
} catch (e) {
if (e instanceof WebhookVerificationError) return new Response(null, { status: 400 });
throw e;
}
}Verification fails when the body was parsed and serialized again, so read the raw bytes first. The SDKs refuse an empty secret, so a missing environment variable cannot accept forged events.
Handle events
Answer with any 2xx quickly and do the work afterwards, for example in a background job.
A delivery that takes too long counts as failed and is sent again.
The same event can arrive more than once, after a retry or a replay. Its svix-id stays the
same every time, so store the ids you have processed and skip an id you have seen.
Events about one email can arrive in any order. Use each event's created_at, not its
arrival, when you record the latest state of a recipient.
- Each attempt waits up to 15s for a
2xxanswer. - Signatures older or newer than 5m should be refused (the SDKs do).
- After a rotation the previous secret keeps signing for 24h.
- An endpoint that fails without a break for 5d, or answers
410, is disabled. A project has at most 20 endpoints. - A webhook's domain filter lists at most 50 domains.
Retries
A delivery that does not get a 2xx is retried on this schedule (the same as Resend's):
| Attempt | Wait before it | Since the event |
|---|---|---|
| 1 | immediately | 0 min |
| 2 | 5s | 0 min |
| 3 | 5m | 5 min |
| 4 | 30m | 35 min |
| 5 | 2h | 2 h 35 min |
| 6 | 5h | 7 h 35 min |
| 7 | 10h | 17 h 35 min |
| 8 | 10h | 27 h 35 min |
Delivery log and replay
exx.sh keeps a log of every delivery and every attempt to send it. Resend has no API for
this; it is an exx.sh addition. List a webhook's deliveries, newest first, with
GET /webhooks/{id}/deliveries. Filter
by status (pending, delivered or failed) and event_type, and page with limit
(1 to 100, default 20) and after or before:
curl "https://api.exx.sh/webhooks/$WEBHOOK_ID/deliveries?status=failed&limit=50" \
-H "Authorization: Bearer $EXX_API_KEY"GET /webhooks/{id}/deliveries/{delivery_id}
returns one delivery with the exact JSON body sent (payload) and its attempts, oldest
first. Each attempt has its HTTP status, duration_ms and the start of your endpoint's
answer (response_excerpt). When no answer came, status is null and error says why,
for example timed out.
Once your handler is fixed, send a finished delivery again with
POST /webhooks/{id}/deliveries/{delivery_id}/replay:
curl -X POST "https://api.exx.sh/webhooks/$WEBHOOK_ID/deliveries/$DELIVERY_ID/replay" \
-H "Authorization: Bearer $EXX_API_KEY"A replay starts from the first attempt and keeps the delivery's svix-id: a handler that
skips the ids it has processed also skips the replay of an event it already handled. The
svix-timestamp is new. A delivery that
is still being sent, or waiting for its next retry, cannot be replayed yet (409 exx_delivery_pending): the retries are already sending it. Neither can a delivery of a
disabled webhook (409 exx_webhook_disabled): enable the webhook first.
Rotate the signing secret
POST /webhooks/{id}/signing-secret/rotate
or the dashboard creates a new secret. The previous secret keeps signing as well for a while
(above), so deploy the new secret to your application within that time.
Common questions
Why do I get several email.delivered events for one email?
Events are per recipient. An email to three recipients gives three email.delivered
events, and each event's to names the recipient it is about.
How do I test webhooks on my machine?
Expose your local server with a tunnel such as ngrok or cloudflared, create a webhook
with the tunnel's URL, and send an email. Replay deliveries from the dashboard while you
work on the handler.
Why was my webhook disabled?
GET /webhooks/{id} says why in disabled_reason (an exx.sh addition; status stays
enabled or disabled as in Resend):
disabled_reason | Why |
|---|---|
endpoint_gone | Your endpoint answered that it is gone (the status in Handle events), which means "stop sending". |
failing | Every delivery failed without a break for the time in Handle events. failing_since shows when the run of failures began, so you can see a webhook heading there. |
manual | Someone disabled it with PATCH /webhooks/{id}. |
exx.sh also alerts the organization's owners and admins when it disables a webhook, by
email and in the dashboard's bell (alerts). Fix the endpoint,
then enable the webhook again with PATCH /webhooks/{id} and "status": "enabled". That
clears disabled_reason and failing_since and sends the deliveries that were waiting.
Events that happened while the webhook was disabled were not queued for it; replay the
ones you need from the delivery log.
What happens if my endpoint is down?
exx.sh retries each delivery on the schedule above. An endpoint that keeps failing is
disabled after the time in the list above. Enable it again once it works (PATCH /webhooks/{id} with "status": "enabled") and replay the deliveries it missed.
DMARC reports
Have exx.sh receive your domain's DMARC aggregate reports and read who sends mail as your domain, which of it passes DMARC, and what receivers did with the rest.
Receiving email
Receive mail at your project's address or on your own domain, get an email.received webhook, then read the message, its attachments and the raw file through the API.