Questions · Published 2026-11-29 · Updated 2026-11-29 · AgentiSend
Resend webhooks
Resend webhooks are HTTPS POST requests, signed with a whsec_ secret, that report an email, domain, contact, or inbox event to your endpoint.
Verify that signature against the raw body, answer 200, and only then read type and data. Every Resend detail below was read on 2026-11-28 from Resend's webhook introduction, event types, verify webhooks, create a webhook, retries and replays, email.received, email.bounced, the bounce types guide, the create, rotate and retrieve received email API pages, the CLI reference, resend 6.41.0 on npm, resend 2.56.2 on PyPI, resend-cli 2.30.1, standardwebhooks 1.1.1, and resend-mcp 2.31.0.
We make AgentiSend, a separate email API. The last section says what a handler written for Resend reads when the endpoint is registered here. It does not make this page Resend's documentation, and it does not make us Resend's support.
Create the endpoint
Resend's create guide has five steps. The short version:
- Add a route that accepts POST. On a successful delivery, answer HTTP 200. Their create page says a 200 is the signal that the event was delivered.
- In the Webhooks dashboard, choose Add Webhook, paste an HTTPS URL, and select the events. The same call over the API is
POST https://api.resend.com/webhookswithendpointandevents. The response isobject,id, andsigning_secret(whsec_plus the secret). - Cause one event you subscribed to (send a message, create a contact, or create a domain) and read the JSON your route received.
- Deploy the route.
- Register the production URL the same way.
curl -X POST 'https://api.resend.com/webhooks' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{"endpoint":"https://example.com/handler","events":["email.sent"]}'That curl is the sample on Resend's create-webhook API page. The Node call next to it is resend.webhooks.create({ endpoint, events }) in resend 6.41.0. Python is resend.Webhooks.create(params=...) in resend 2.56.2. The CLI is resend webhooks create --endpoint https://example.com/webhook --events email.sent email.delivered.
resend-mcp 2.31.0 registers ten webhook tools: create-webhook, list-webhooks, get-webhook, update-webhook, remove-webhook, list-webhook-events, get-webhook-event, replay-webhook-event, rotate-webhook-signing-secret, and list-webhook-event-attempts. get-webhook's description says the reply includes the signing secret. Install of that server is on Resend MCP server in Claude Code. The route list for the REST API is on Resend API docs.
Event types
The event-types page on 2026-11-28 lists 37 names. The same 37 are the WebhookEvent union in resend-python 2.56.2 and the enum in resend-mcp 2.31.0 src/tools/webhooks.ts.
| Group | Events |
|---|---|
| Email (11) | email.sent, email.scheduled, email.delivered, email.delivery_delayed, email.complained, email.bounced, email.opened, email.clicked, email.received, email.failed, email.suppressed |
| Domain (3) | domain.created, domain.updated, domain.deleted |
| Contact (4) | contact.created, contact.updated, contact.deleted, contact.topics.updated |
| Suppression (2) | suppression.added, suppression.removed |
| Topic (3) | topic.created, topic.updated, topic.deleted |
| Inbox (14) | inbox.created, inbox.updated, inbox.deleted, inbox.thread.created, inbox.thread.folder.updated, inbox.thread.assigned, inbox.thread.unassigned, inbox.thread.labels.updated, inbox.email.received, inbox.email.sent, inbox.draft.created, inbox.draft.updated, inbox.draft.sent, inbox.draft.deleted |
Two limits written on that page: a CSV contact import does not emit contact.created, and an inbox event's thread, email, draft, and inbox objects are loaded when the webhook is sent, not when the change happened, so two quick changes can both show the second state. Inbox email and draft leave out html and text.
email.sent fires when the API request succeeded and Resend will try to deliver. email.delivered fires when the recipient's mail server accepted it. email.delivery_delayed is a temporary delivery problem (their example is a full mailbox). email.bounced is described there as a permanent rejection. The bounce-types guide, a different page, names three bounce.type values: Permanent, Transient, and Undetermined. The sample payload on the bounced-event page uses "type": "Permanent". email.failed is a send that never went out (invalid recipient, API key, domain, quota). email.suppressed is Resend refusing an address already on the suppression list.
The payload
Every event is one JSON object with type, created_at, and data. This is the bounced sample from the create-webhook page, shortened only by dropping broadcast_id and template_id, which that sample includes when they apply:
{
"type": "email.bounced",
"created_at": "2026-11-22T23:41:12.126Z",
"data": {
"created_at": "2026-11-22T23:41:11.894Z",
"email_id": "56761188-7520-42d8-8898-ff6fc54ce618",
"message_id": "<111-222-333@email.example.com>",
"from": "Acme <onboarding@resend.dev>",
"to": ["delivered@resend.dev"],
"subject": "Sending this example",
"bounce": {
"message": "The recipient's email address is on the suppression list because it has a recent history of producing hard bounces.",
"subType": "Suppressed",
"type": "Permanent"
},
"tags": { "category": "confirm_email" }
}
}to is an array. bounce.diagnosticCode is an array of SMTP lines (the bounced-event page's example is smtp; 550 5.5.0 Requested action not taken: mailbox unavailable). message_id is omitted on email.scheduled, email.failed, and email.suppressed, because those fire before the message is sent.
A handler should ignore keys it does not know. New fields show up in data without a version bump.
The signing secret
The secret is on the webhook details page in the dashboard. Create, retrieve, and list also return signing_secret in the body (verify-webhooks page, 2026-11-28). It starts with whsec_. Store it where the route can read it. The verify examples use the name RESEND_WEBHOOK_SECRET.
Rotating is POST https://api.resend.com/webhooks/{id}/signing-secret/rotate, or resend.webhooks.rotateSigningSecret(id) in the Node SDK, or resend.Webhooks.rotate_signing_secret(webhook_id=...) in Python, or resend webhooks rotate-signing-secret <id>. Resend's rotate page says that for 24 hours the payload is signed with both the new secret and the previous one, so either verifies, and after that only the new one does. The signature header can carry more than one v1, value, separated by spaces. Check each of them.
Verify the signature
Three headers arrive on every delivery: svix-id, svix-timestamp, and svix-signature. The signed content is the id, a dot, the timestamp, a dot, and the raw body bytes. The key is the base64 decode of the secret with the whsec_ prefix removed. The signature is base64 HMAC-SHA256, prefixed with v1,.
Use the raw body. Resend's verify page says a framework that parses JSON and stringifies it again changes bytes and the check fails. Reject a timestamp more than five minutes from your clock: standardwebhooks 1.1.1, which resend 6.41.0 depends on, sets WEBHOOK_TOLERANCE_IN_SECONDS to 5 * 60, and resend-python 2.56.2 sets DEFAULT_WEBHOOK_TOLERANCE_SECONDS to 300.
The Node SDK wraps that check. headers.id is the svix-id value, and the SDK passes it to standardwebhooks as webhook-id (the same value under the Standard Webhooks name):
import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
export async function POST(req) {
const payload = await req.text();
try {
const event = resend.webhooks.verify({
payload,
headers: {
id: req.headers.get('svix-id'),
timestamp: req.headers.get('svix-timestamp'),
signature: req.headers.get('svix-signature'),
},
webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
});
return new Response(JSON.stringify({ received: true, type: event.type }), { status: 200 });
} catch {
return new Response('Invalid webhook', { status: 400 });
}
}The same check with no SDK, which is what resend-python implements and what the function below does. verifyResendWebhook throws if the timestamp or the signature does not match, and returns the parsed event when it does.
import { createHmac, timingSafeEqual } from 'node:crypto';
const TOLERANCE_SECONDS = 300;
export function verifyResendWebhook(secret, headers, rawBody, nowSeconds = Date.now() / 1000) {
const id = headers['svix-id'];
const timestamp = headers['svix-timestamp'];
const signature = headers['svix-signature'];
if (!id || !timestamp || !signature) throw new Error('Missing svix headers.');
const ts = Number(timestamp);
if (!Number.isFinite(ts)) throw new Error('Invalid svix-timestamp.');
if (Math.abs(nowSeconds - ts) > TOLERANCE_SECONDS) throw new Error('Timestamp outside tolerance.');
const key = Buffer.from(secret.startsWith('whsec_') ? secret.slice('whsec_'.length) : secret, 'base64');
const expected = createHmac('sha256', key).update(`${id}.${timestamp}.${rawBody}`).digest('base64');
const match = signature.split(' ').some((part) => {
const value = part.split(',')[1];
if (!value || part.split(',')[0] !== 'v1') return false;
const provided = Buffer.from(value);
const wanted = Buffer.from(expected);
return provided.length === wanted.length && timingSafeEqual(provided, wanted);
});
if (!match) throw new Error('No matching signature.');
return JSON.parse(rawBody);
}Python, the call the official FastAPI example in resend-examples uses, with resend 2.56.2:
import os
import resend
from fastapi import FastAPI, HTTPException, Request
app = FastAPI()
resend.api_key = os.environ["RESEND_API_KEY"]
@app.post("/webhook")
async def handle_webhook(request: Request):
payload = (await request.body()).decode()
svix_id = request.headers.get("svix-id")
svix_timestamp = request.headers.get("svix-timestamp")
svix_signature = request.headers.get("svix-signature")
if not all([svix_id, svix_timestamp, svix_signature]):
raise HTTPException(status_code=400, detail="Missing webhook headers")
try:
event = resend.Webhooks.verify({
"payload": payload,
"headers": {"id": svix_id, "timestamp": svix_timestamp, "signature": svix_signature},
"webhook_secret": os.environ["RESEND_WEBHOOK_SECRET"],
})
except Exception:
raise HTTPException(status_code=400, detail="Invalid webhook")
return {"received": True, "type": event["type"]}The standard-library version of that check, so a service that does not install resend or svix still verifies the same bytes:
import base64
import hmac
import json
import time
from hashlib import sha256
TOLERANCE_SECONDS = 300
def verify_resend_webhook(secret, headers, raw_body, now_seconds=None):
msg_id = headers.get("svix-id")
timestamp = headers.get("svix-timestamp")
signature = headers.get("svix-signature")
if not msg_id or not timestamp or not signature:
raise ValueError("Missing svix headers.")
ts = int(timestamp)
now = int(time.time() if now_seconds is None else now_seconds)
if abs(now - ts) > TOLERANCE_SECONDS:
raise ValueError("Timestamp outside tolerance.")
key = base64.b64decode(secret[6:] if secret.startswith("whsec_") else secret)
signed = f"{msg_id}.{timestamp}.{raw_body}".encode()
expected = base64.b64encode(hmac.new(key, signed, sha256).digest()).decode()
for part in signature.split(" "):
version, _, value = part.partition(",")
if version == "v1" and value and hmac.compare_digest(expected, value):
return json.loads(raw_body)
raise ValueError("No matching signature.")Resend's verify page also shows import { Webhook } from 'svix' after npm install svix. npm listed svix at 2.11.1 on 2026-11-28. The Node SDK does not import that package. It imports standardwebhooks 1.1.1. Both libraries accept the svix-* headers. Deduplicate on svix-id: Resend's create page says delivery is at-least-once, and a retry of the same event keeps that id.
A worked branch after the check:
const event = verifyResendWebhook(secret, headers, rawBody);
if (event.type === 'email.bounced' && event.data.bounce?.type === 'Permanent') {
// event.data.to is an array. event.data.email_id is the message.
}
if (event.type === 'email.received') {
// The body is not in the webhook. Fetch it with the email_id.
}Answer 200 as soon as the event is stored. Doing the work inside the request makes a slow handler look like a failed delivery, and a failed delivery is retried.
Test locally
Resend's CLI page documents resend webhooks listen. It starts a server, registers a temporary webhook, streams events, and removes that webhook on exit. Install the CLI from the same page: npm install -g resend-cli (package resend-cli 2.30.1, binary resend), brew install resend/cli/resend, or the shell script at https://resend.com/install.sh.
resend webhooks listen \
--url https://hostname.tailnet-name.ts.net \
--events email.received \
--forward-to http://localhost:3000/webhook--url is required and is a public URL, such as a Tailscale Funnel URL. --events defaults to all. --forward-to is optional and forwards the payload with the original Svix headers. --port defaults to 4318. Their create page also names a tunnel (ngrok, or VS Code port forwarding) when you would rather point the dashboard at your machine yourself. After the tunnel is up, send a message or create a contact and confirm the route printed the event.
Inbound: email.received
email.received fires when Resend receives a message. The payload has type, created_at, and data with email_id, from, to, cc, bcc, subject, message_id, attachments (id, filename, content_type, content_disposition, content_id), and received_for (addresses from the for clause of Received headers). from on a received event is the bare address. The display name stays on the retrieve call, under headers.from.
The webhook does not include the body, the headers, or the attachment bytes. Resend's received-event page says to call the received-email API or the attachments API. The retrieve sample is:
curl -X GET 'https://api.resend.com/emails/receiving/4ef9a417-02e9-4d39-ad75-9611e0fcc33c' \
-H 'Authorization: Bearer re_xxxxxxxxx'inbox.email.received is a different event. It fires when an inbound message is added to an inbox thread, and the inbox section of the event-types page says the body is left out there too.
Retries, replays, and where the POST comes from
If the endpoint does not answer 200, Resend retries. The schedule on the retries page, each wait starting after the previous attempt failed:
- Immediately
- 5 seconds
- 5 minutes
- 30 minutes
- 2 hours
- 5 hours
- 10 hours
- 10 hours again
An attempt that fails three times and then succeeds is, in their example, about 35 minutes and 5 seconds after the first try. Removing or disabling the endpoint stops further attempts. If the endpoint keeps failing, Resend disables it and emails the team. Re-enable it on the Webhooks page. The store-webhooks page says automatic retries cover up to 24 hours, and older events are replayed from the dashboard.
Replay, from the same retries page: open Webhooks, open the endpoint, open the message, click Replay. Both failed and succeeded messages can be replayed. Use that to backfill after an outage or to reprocess with a new handler.
Events are not ordered. An email.opened can arrive before email.delivered for the same message. Sort on created_at when the order matters.
If you allowlist the source, the create page lists these addresses:
| Address |
|---|
44.228.126.217 |
50.112.21.217 |
52.24.126.164 |
54.148.139.208 |
2600:1f24:64:8000::/52 |
What a Resend handler reads on AgentiSend
This section is AgentiSend, not Resend. The handler above keeps working when the endpoint is created with payload_format set to resend and Svix headers turned on. The field-by-field guide is Webhooks. The signature steps for our own header are How do I verify a webhook signature?.
| Resend, read 2026-11-28 | AgentiSend | |
|---|---|---|
| Create body | endpoint, events | endpoint or url (url wins if both are sent), events, optional payload_format, optional svix_compat |
| Secret on create | signing_secret, also returned by retrieve and list | secret and signing_secret, the same value, on POST /webhooks only. GET /webhooks does not return it |
| Signature headers | svix-id, svix-timestamp, svix-signature | Those three when svix_compat is on. x-agentisend-signature is always sent |
| Body a Resend handler reads | type, created_at, data.email_id, data.to, data.bounce.type, data.bounce.subType | The same fields when payload_format is resend |
| Success | HTTP 200 | Any 2xx |
| Retries | The eight-step schedule above | 10 attempts. The waits are 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, 10 hours, 24 hours, 48 hours |
| Timestamp window | 5 minutes in standardwebhooks 1.1.1 and in resend-python 2.56.2 | 5 minutes |
| Secret rotation | 24 hours, both secrets verify | 24 hours, both secrets verify, via POST /webhooks/{id}/rotate-secret |
Sending endpoint and not url, and not setting svix_compat, turns the Svix headers on. Sending url leaves them off unless you pass svix_compat: true. The MCP tool create_webhook takes url, so pass svix_compat: true and payload_format: "resend" or the existing verifier will not see the headers it checks. Our five x-agentisend-* headers are still sent either way. During the grace window a delivery is signed with both secrets.
payload_format: "resend" is the body only. A message that aged out of the queue is delivered as email.bounced with bounce.type Transient, not as email.failed. email.received can also include extracted_text and extracted_html when those were produced. A handler that ignores unknown keys still reads type and data.email_id. One that refuses unknown keys will see those two.
The received body is not fetched from https://api.resend.com. It is GET /emails/receiving/{id}. Receiving setup is Inbound email.
{
"url": "https://example.com/handler",
"events": ["email.bounced", "email.received"],
"svix_compat": true,
"payload_format": "resend"
}curl -sS -X POST https://api.agentisend.com/webhooks \
-H "Authorization: Bearer $AGENTISEND_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"url":"https://yourapp.com/hooks/agentisend","events":["email.delivered","email.bounced"]}'201
{
"created_at": "2026-09-04T09:14:00.000Z",
"disabled": false,
"endpoint": "example",
"events": [],
"id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"last_24h": {
"failed": -9007199254740991,
"last_failure_reason": "example",
"last_success_at": "2026-09-04T09:14:00.000Z",
"pending": -9007199254740991,
"succeeded": -9007199254740991
},
"last_delivery_status": "pending",
"object": "webhook",
"payload_format": "native",
"secret": "example",
"signing_secret": "example",
"status": "enabled",
"svix_compat": false,
"updated_at": "2026-09-04T09:14:00.000Z",
"url": "example"
}curl -sS -X POST https://api.agentisend.com/webhooks/9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42/rotate-secret \
-H "Authorization: Bearer $AGENTISEND_API_KEY" \
-H "Idempotency-Key: $(uuidgen)"200
{
"id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"object": "webhook",
"previous_secret_expires_at": "2026-09-04T09:14:00.000Z",
"rotated_at": "2026-09-04T09:14:00.000Z",
"secret": "example",
"signing_secret": "example"
}Replay a stored event with POST /webhooks/{id}/replay. The steps, including a dry run that returns a count and sends nothing, are How do I replay webhook events?.
Local deliveries of an endpoint that already exists:
npx @agentisend/sdk-node webhooks listen --secret whsec_… --forward-to http://localhost:3000/webhookThat command checks the signature and drops a delivery that does not verify. It does not register a temporary endpoint for you. Resend's resend webhooks listen does.
The webhook operations as a group are on AgentiSend API docs. Registering one from an agent is create_webhook on the AgentiSend MCP server.
FAQ
Where do I find the Resend webhook secret?
On the webhook's page in the Resend dashboard, and in the signing_secret field of the create, retrieve, and list responses. It starts with whsec_.
How do I verify a Resend webhook signature?
Read the svix-id, svix-timestamp, and svix-signature headers, and recompute HMAC-SHA256 over the id, a dot, the timestamp, a dot, and the raw body. The key is the base64-decoded secret after whsec_. Compare each space-separated v1 value in constant time, and reject a timestamp more than five minutes off.
How do I test Resend webhooks on localhost?
Run resend webhooks listen with a public url flag and forward-to pointed at your local route, or put a tunnel in front of that route and add the tunnel URL in the dashboard. Cause one real event. The route has to answer 200.
Does the Resend email.received webhook include the body?
No. It includes metadata and attachment descriptors. The body, headers, and attachment bytes come from the received-email API and the attachments API.
What if my endpoint does not answer 200?
Resend retries on the schedule above, then disables an endpoint that keeps failing and emails the team. A successful delivery can still be replayed from the dashboard. Dedupe on the svix-id header, because a retry of the same event uses the same id.
Do Resend webhook events arrive in order?
No. Sort on the created_at field if you need sent before delivered before opened.