Webhooks
A webhook is an address of yours that gets a signed request when something happens to an email.
Add an endpoint
Give a public https:// address that takes a POST, and the events you want. Without events the endpoint gets every event. An IP address, localhost and private names are refused with webhook_url.
curl -X POST "$OPENSEND_API_URL/v1/webhooks" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/hooks/mail", "events": [ "email.delivered", "email.bounced" ]}'The answer holds the secret that signs every request to this endpoint. It is shown this once, so store it now.
{ "object": "webhook", "id": "wh_02", "url": "https://example.com/hooks/mail", "events": [ "email.delivered", "email.bounced" ], "status": "enabled", "format": "native", "lastDeliveryAt": null, "lastStatus": null, "createdAt": "2026-11-27T09:30:00.000Z", "secret": "whsec_08d12dfda708a7ae4540215fe3779b10"}What your endpoint gets
Each event is one POST with a JSON body and these headers.
content-type: application/jsonuser-agent: OpenSend-Webhooks/1opensend-signature: t=1795771800,v1=80db0d952157c00a6643299af13e738f4e2943f1f747cab20abb93272c91ef4fopensend-event: email.deliveredopensend-delivery: evt_07:wh_01opensend-signature: the time and the signature of the request.opensend-event: the type of the event.opensend-delivery: the id of this delivery. It is the same on every retry, so use it to ignore a repeat.
The body has the id of the event, its type, when it happened, and data. For an email event data holds the id of the email, its sender, recipients, subject and tags, and a detail.
{ "id": "evt_07", "type": "email.delivered", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_12", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "250 2.0.0 OK", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}Check the signature
Anyone can post to a public address, so check that a request is yours before you trust it. The SDK does it in one call, on the raw body exactly as it arrived.
import { OPENSEND_SIGNATURE_HEADER, OpenSendError, verifyWebhook } from '@open-send/opensend' export default { async fetch(request: Request): Promise<Response> { const payload = await request.text() try { const event = await verifyWebhook({ payload, signature: request.headers.get(OPENSEND_SIGNATURE_HEADER), secret: process.env.WEBHOOK_SECRET ?? '', }) if (event.type === 'email.bounced') { console.log(event.data.emailId, event.data.detail) } return new Response('ok') } catch (error) { if (error instanceof OpenSendError) return new Response(error.message, { status: 400 }) throw error } },}verifyWebhook returns the event, or throws with the code invalid_signature. It also refuses a request older than five minutes, so a captured request cannot be replayed later. toleranceSeconds changes that window.
Without the SDK, check it by hand.
- Read
tandv1from the header, which looks liket=1795771800,v1=1ba91f.... - Join
t, a dot and the raw body:1795771800.{"id":"evt_07",...}. - Compute the HMAC-SHA256 of that text with your secret as the key, as lowercase hex.
- Compare it with
v1in constant time, and refuse the request whentis more than five minutes away from now.
Answers and retries
Answer with any 2xx status within 5 seconds. Anything else counts as a failure, and so does a redirect: it is not followed.
A failed delivery is tried again after 1 min, 5 min, 30 min, 2 h, 8 h. After 6 tries it is marked failed and left alone.
Every delivery is kept for 30 days with its state, the status your endpoint answered with, and what went wrong.
curl "$OPENSEND_API_URL/v1/webhooks/wh_01/deliveries" \ -H "Authorization: Bearer $OPENSEND_API_KEY"Try it out
Post one signed sample event to an endpoint, and get back what the endpoint answered.
curl -X POST "$OPENSEND_API_URL/v1/webhooks/wh_01/test" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'To stop an endpoint without losing it, set its status to disabled.
curl -X PATCH "$OPENSEND_API_URL/v1/webhooks/wh_01" \ -H "Authorization: Bearer $OPENSEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "status": "disabled"}'Every event
email.sentThe email left for the receiving mail server.{ "id": "evt_06", "type": "email.sent", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_11", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.deliveredThe receiving mail server took the email.detailis what it answered.{ "id": "evt_07", "type": "email.delivered", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_12", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "250 2.0.0 OK", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.delayedThe receiving mail server asked to try again later.detailis what it answered.{ "id": "evt_08", "type": "email.delayed", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_13", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "451 4.7.1 Try again later.", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.bouncedThe receiving mail server refused the email for good.detailis its reason.{ "id": "evt_09", "type": "email.bounced", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_14", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "550 5.1.1 The email account does not exist.", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.openedThe recipient opened the email. Sent when open tracking is on for the domain.{ "id": "evt_10", "type": "email.opened", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_15", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.clickedThe recipient followed a link.detailis the link. Sent when click tracking is on for the domain.{ "id": "evt_11", "type": "email.clicked", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_16", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "https://example.com/receipts/november", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.complainedThe recipient marked the email as spam.{ "id": "evt_12", "type": "email.complained", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_17", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.failedThe email could not be sent at all.detailsays why.{ "id": "evt_13", "type": "email.failed", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_18", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "The message was refused before it left.", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.receivedAn email arrived on one of your domains.data.idis the id of the received email.{ "id": "evt_14", "type": "email.received", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "id": "in_02", "from": "grace@customer.example", "to": "support@mail.example.com", "subject": "A question about my invoice" }}email.scheduledAn email was scheduled, or moved to a new time.detailis the time it is due.{ "id": "evt_04", "type": "email.scheduled", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_10", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "2026-12-04T09:00:00.000Z", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}email.canceledA scheduled email was canceled before it was sent.{ "id": "evt_05", "type": "email.canceled", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "emailId": "em_10", "from": "Acme <hello@mail.example.com>", "to": [ "ada@example.com" ], "subject": "Your receipt for November", "tags": { "category": "receipt" }, "detail": "Cancelled before it was sent.", "createdAt": "2026-11-27T09:30:00.000Z", "templateId": null, "broadcastId": null, "mode": "live" }}automation.enteredA person entered an automation.data.runIdis the id of their run.{ "id": "evt_run_04_entered", "type": "automation.entered", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "automationId": "auto_01", "automation": "Tell the CRM", "runId": "run_04", "email": "ada@example.com", "contactId": "con_486cf92a1e02a43d335e2ff1", "source": "manual", "status": "running", "reason": null }}automation.finishedA run ended.data.statussays how, anddata.reasonwhy when it ended early.{ "id": "evt_run_04_finished", "type": "automation.finished", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "automationId": "auto_01", "automation": "Tell the CRM", "runId": "run_04", "email": "ada@example.com", "contactId": "con_486cf92a1e02a43d335e2ff1", "source": "manual", "status": "completed", "reason": null }}automation.stepA webhook step of an automation ran.data.stepnames it anddata.datais what started the run.{ "id": "evt_run_04_tell_crm", "type": "automation.step", "createdAt": "2026-11-27T09:30:00.000Z", "data": { "automationId": "auto_01", "automation": "Tell the CRM", "runId": "run_04", "stepId": "tell_crm", "step": "Tell the CRM", "email": "ada@example.com", "contactId": "con_486cf92a1e02a43d335e2ff1", "source": "manual", "data": { "plan": "pro" } }}