Webhooks
Events pushed to your endpoint, signed, retried and in order per e-mail.
On this page
npx @sypnia/mail webhooks create https://laespiga.co/api/mail-events --events delivered,bounced,complainedEach event is a POST with a JSON body:
{
"id": "evt_01JD…",
"type": "bounced",
"createdAt": "2026-11-17T14:03:22Z",
"email": { "id": "em_01JD…", "to": "ana@example.com", "from": "pedidos@laespiga.co", "subject": "Tu pedido #1042 está listo", "tags": { "kind": "order-ready" } },
"bounce": { "kind": "hard", "code": "5.1.1", "message": "The email account that you tried to reach does not exist." }
}Checking the signature
Each request carries sypnia-signature: t=<unix>,v1=<hmac-sha256> over <t>.<body> with the webhook’s secret. verifyWebhook(request, secret) from @sypnia/mail/server checks it and refuses requests older than 5 minutes.
Delivery
- Your endpoint must answer
2xxwithin 10 seconds. - Failures are retried with backoff for 24 hours; after that the event stays in the log, marked undelivered, and
mail webhooks replaysends it again. - Events of one e-mail arrive in order; events of different e-mails can arrive in any order. Use
idto ignore duplicates. - A webhook that fails for 3 days in a row is paused and you are notified.
With Sypnia Run, a function in the same project can be the webhook without a public URL: --target run://mail-events.