After sending
More ways to use this page
Webhooks
A webhook is an HTTPS URL of yours that Sendora posts events to as they happen: a delivery, a bounce, a complaint, a received message. This page shows how to register one, check that each request comes from Sendora, and recover the deliveries that failed.
Rules for your endpoint
- Verify the signature against the raw body before you parse it. The steps are below.
- Answer with any 2xx status, then do your work. Any other status fails the attempt, a redirect included, and so does no answer within the timeout on Limits.
- Expect the same delivery more than once, and key your handling on its
id. - Expect deliveries out of order. Sendora attempts them in order for each webhook, but a retried delivery can arrive after later ones. To order a message’s events, compare their
occurredAt.
Register
POST /v1/webhookscurl -X POST https://api.sendora.se/v1/webhooks \
-H "Authorization: Bearer $SENDORA_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.se/hooks/sendora",
"events": [
"delivered",
"bounced",
"deferred",
"spam_complaint"
]
}'import { Sendora } from '@sendora/sdk';
const sendora = new Sendora({
token: process.env.SENDORA_API_TOKEN,
});
const { webhookId, secret } =
await sendora.webhooks.create({
url: 'https://example.se/hooks/sendora',
events: [
'delivered',
'bounced',
'deferred',
'spam_complaint',
],
});
console.log(webhookId);
console.log(secret); // shown this once: store it beside the tokenimport os
from sendora import Sendora
sendora = Sendora(os.environ["SENDORA_API_TOKEN"])
webhook = sendora.webhooks.create(
url="https://example.se/hooks/sendora",
events=[
"delivered",
"bounced",
"deferred",
"spam_complaint",
],
)
print(webhook.webhook_id)
# Shown this once: store it beside the token.
print(webhook.secret)<?php
use Sendora\Sendora;
// The key comes from SENDORA_API_TOKEN.
$sendora = new Sendora();
$webhook = $sendora->webhooks->create(
url: 'https://example.se/hooks/sendora',
events: [
'delivered',
'bounced',
'deferred',
'spam_complaint',
],
);
echo $webhook->webhookId, "\n";
// Shown this once: store it beside the token.
echo $webhook->secret, "\n";import se.sendora.Sendora;
import se.sendora.model.CreateWebhookRequest;
import se.sendora.model.CreatedWebhook;
import se.sendora.model.WebhookEventName;
class CreateWebhook {
public static void main(String[] args) {
CreateWebhookRequest request =
CreateWebhookRequest.builder()
.url("https://example.se/hooks/sendora")
.events(
WebhookEventName.DELIVERED,
WebhookEventName.BOUNCED,
WebhookEventName.DEFERRED,
WebhookEventName.SPAM_COMPLAINT)
.build();
// The server key comes from SENDORA_API_TOKEN.
try (var sendora = Sendora.fromEnv()) {
CreatedWebhook webhook =
sendora.webhooks().create(request);
System.out.println(webhook.webhookId());
// Shown this once: store it beside the token.
System.out.println(webhook.secret());
}
}
}Response
{
"webhookId": "7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70",
"url": "https://example.se/hooks/sendora",
"events": [
"delivered",
"bounced",
"deferred",
"spam_complaint"
],
"streamId": null,
"enabled": true,
"inboundContent": "full",
"createdAt": "2026-09-15T12:00:00.000Z",
"secrets": [
{
"secretId": "4a5b6c7d-8e9f-4a0b-8c1d-2e3f4a5b6c7d",
"createdAt": "2026-09-15T12:00:00.000Z"
}
],
"secret": "whsec_9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a"
}The response includes secret once: the webhook’s first signing secret. Store it with your other secrets.
- The URL must use HTTPS and point to a public host. If it resolves to a private address, each delivery fails at once and becomes dead, without retries.
- A server has one webhook per URL. Registering a URL again fails with
webhook_, which includes the existing webhook’s id.exists - Leave out
eventsto receive every event exceptopenedandclicked, sotracking_is among them. Name those two to receive them, since one recipient can cause many of them.opted_ out - A webhook’s events cannot be changed. Instead, remove the webhook and create it again, which gives it a new secret. Events in between are not delivered.
- A webhook keeps the events it was created with. One created before an event existed gets that event only once you create it again.
- With
streamId, the webhook receives the message events of that one stream. Cap events belong to no stream, so they reach the webhook either way. inboundContentdecides how much of a received message theinboundevent carries, as Inbound explains.
You can switch a webhook off in the dashboard. While it is off, its enabled is false, Sendora queues no events for it, and its pending deliveries become dead.
Events
Each delivery is one event, posted as JSON. The body has the event’s name in event, the delivery’s id and attempt, and the event’s own fields. Webhook events lists every field of every event, with an example of each. Each event’s name below links to its fields.
| Event | Sent when |
|---|---|
delivered | The receiving server accepted the message for the recipient. |
bounced | The receiving server refused the message, or Sendora gave up retrying. After a hard bounce, the recipient is on the stream’s suppression list. |
deferred | The receiving server asked Sendora to try later. Sendora keeps trying, so several may follow. |
spam_ | The recipient reported the message as spam. The recipient is suppressed. |
unsubscribed | The recipient unsubscribed from a broadcast stream and is suppressed on it. The event comes a minute after the click, since the recipient can undo it for that long. |
opened | The pixel of a tracked copy loaded, for a person or a machine. Only a webhook that names this event gets it. |
clicked | A tracked link was followed, for a person or a machine. Only a webhook that names this event gets it. |
tracking_ | The recipient asked not to be tracked, and is on the server’s not-tracked list. |
cap_ | The server or the account has used most of its monthly cap, at the share on Limits. |
cap_ | A send was refused because the monthly cap is used up. |
inbound | A message arrived on an inbound stream. |
inbound_ | The account has received most of its monthly cap on received mail, at the share on Limits. |
inbound_ | Received mail reached the account’s monthly cap. Mail to the account is refused for now, so senders retry, until the month ends or the cap is raised. |
Only Sendora support can lift a spam complaint or an unsubscribe, as Suppressions explains. When you get unsubscribed, take the recipient off your own list too.
A message event has test set to true when the message was on a test server. Its events were simulated, and nothing was sent.
tracking_ goes on every account, since a recipient can ask not to be tracked from untracked mail too. Unlike opened and clicked, it reaches a webhook that leaves out events. No event goes when the recipient asks from mail that has left the log, or after an erasure, since it could name nobody.
opened and clicked go only for mail that is tracked. Each one carries the labels on Messages and events, which say whether a person or a machine caused it. A recipient’s opens and clicks past the number on Limits send no event. A clicked event’s details is null once the message’s text and HTML have gone, so a replay after that has no URL either.
Verify the signature
Every request carries Sendora-Signature: t=<unix seconds>,v1=<hex>[,v1=<hex>]. To verify it:
- Read
tand everyv1from the header. There is onev1for each live secret of the webhook, the newest first. - Compute an HMAC-SHA256 of
<t>in hex. Its key is your whole secret,.<raw body> whsec_included. - Compare it with each
v1in constant time. One match is enough. - Refuse the request if
tis more than five minutes from your clock, so a captured request cannot be replayed.
Only then parse the body. Sendora signs each attempt as it sends it, so a retry or a replay carries a new t and passes step 4.
The sample shows the steps in shell, and the one call that does all four in each SDK:
# Sendora-Signature: t=<unix seconds>,v1=<hex>[,v1=<hex>]
# One v1 per live secret of the webhook, the newest first; each is
# HMAC-SHA256 with that secret over "<t>.<raw body>".
expected=$(printf '%s.%s' "$T" "$RAW_BODY" | openssl dgst -sha256 -hmac "$SENDORA_WEBHOOK_SECRET" | sed 's/^.* //')
# Compare in constant time in your language, refuse a t more than five minutes from your clock, then parse the body.
# One matching v1 is enough; $V1S holds every v1 of the header, one per line.
printf '%s\n' "$V1S" | grep -qx "$expected" && echo "signed by Sendora"import { verifyWebhook } from '@sendora/sdk';
/*
* A route handler for any framework that hands you a Fetch Request:
* Next.js, Hono, SvelteKit, Cloudflare Workers. With Express or Fastify,
* keep the raw body and pass it and the header the same way.
*/
export async function POST(
request: Request,
): Promise<Response> {
const event = await verifyWebhook({
secret: process.env.SENDORA_WEBHOOK_SECRET,
signature: request.headers.get('sendora-signature'),
body: await request.text(),
});
if (event.event === 'bounced' && event.details.hard) {
console.log(
`${event.recipient} is undeliverable: ${event.details.classification ?? 'unknown'}`,
);
}
return new Response(null, { status: 204 });
}import os
from collections.abc import Mapping
from sendora import (
BouncedEvent,
WebhookVerificationError,
verify_webhook,
)
# A handler for any framework: give it the raw body
# exactly as it arrived and the request's headers.
def receive(
body: bytes, headers: Mapping[str, str]
) -> int:
# Header names ignore case, and a plain dict does not.
lowered = {
name.lower(): value
for name, value in headers.items()
}
try:
event = verify_webhook(
body,
signature=lowered.get("sendora-signature"),
secret=os.environ["SENDORA_WEBHOOK_SECRET"],
)
except WebhookVerificationError:
return 400
if (
isinstance(event, BouncedEvent)
and event.details.hard
):
print(
f"{event.recipient} is undeliverable: "
f"{event.details.classification or 'unknown'}"
)
return 204<?php
use Sendora\Events\BouncedEvent;
use Sendora\Exception\WebhookVerificationException;
use Sendora\WebhookVerifier;
// A receiver in plain PHP. In Symfony or Laravel, pass
// $request->getContent() and the header the same way.
$header = $_SERVER['HTTP_SENDORA_SIGNATURE'] ?? null;
try {
$event = WebhookVerifier::verify(
(string) file_get_contents('php://input'),
signature: is_string($header) ? $header : null,
secret: (string) getenv('SENDORA_WEBHOOK_SECRET'),
);
} catch (WebhookVerificationException) {
http_response_code(400);
exit;
}
if (
$event instanceof BouncedEvent
&& $event->details->hard
) {
error_log(sprintf(
'%s is undeliverable: %s',
$event->recipient,
$event->details->classification ?? 'unknown',
));
}
http_response_code(204);import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException;
import java.net.InetSocketAddress;
import se.sendora.WebhookVerifier;
import se.sendora.exception.WebhookVerificationException;
import se.sendora.model.BouncedEvent;
import se.sendora.model.WebhookEvent;
// A receiver on the JDK's own server. In Spring or
// Jakarta REST, take the body as a byte[] and pass it
// and the header to verify() the same way.
class ReceiveWebhooks {
public static void main(String[] args)
throws IOException {
// Fails here, at startup, if the secret is unset.
WebhookVerifier verifier =
WebhookVerifier.of(
System.getenv("SENDORA_WEBHOOK_SECRET"));
int port =
Integer.parseInt(
System.getenv().getOrDefault("PORT", "8080"));
// Sendora posts only to HTTPS, so a proxy or a
// tunnel in front serves this. If the proxy is on
// another host or container, use 0.0.0.0.
HttpServer server =
HttpServer.create(
new InetSocketAddress("localhost", port), 0);
server.createContext(
"/hooks/sendora",
exchange -> {
try (exchange) {
int status = receive(verifier, exchange);
exchange.sendResponseHeaders(status, -1);
}
});
server.start();
System.out.println(
"Listening on port "
+ server.getAddress().getPort());
}
static int receive(
WebhookVerifier verifier, HttpExchange exchange)
throws IOException {
// The body exactly as it arrived, before anything
// parses it.
byte[] body =
exchange.getRequestBody().readAllBytes();
String signature =
exchange
.getRequestHeaders()
.getFirst("Sendora-Signature");
WebhookEvent event;
try {
event = verifier.verify(body, signature);
} catch (WebhookVerificationException error) {
return 400;
}
if (event instanceof BouncedEvent bounced
&& bounced.details().hard()) {
System.out.printf(
"%s is undeliverable: %s%n",
bounced.recipient(),
bounced
.details()
.classification()
.orElse("unknown"));
}
return 204;
}
}verifyWebhook returns the event, typed by its event field, so details has the right type. An event newer than your release of the SDK comes as an unknown event, with its name in name and the payload in data, rather than an error. It throws stale_ when the signature is more than five minutes old, and invalid_ when no signature in the header matches. Set toleranceSeconds to allow another age. With a client at hand, sendora does the same from a Fetch Request in one call. The Next.js and Express guides show each in an app, as the next section says.
verify_ returns the event as a class of its own, such as BouncedEvent, so its details are typed. An event newer than your release of the SDK comes as an UnknownEvent, with the payload in data, rather than an error. It raises WebhookVerificationError with stale_ when the signature is more than five minutes old, and with invalid_ when no signature in the header matches. Pass tolerance, in seconds, to allow another age.
The raw body is request in Flask and await request in FastAPI. In Django, read it with request, since request refuses a body over DATA_, 2.5 MB by default. An inbound event with its content can be larger, as Limits shows.
Pass the body and request to receive, and answer with the status it returns. In Flask, pass dict(, since type checkers do not take Werkzeug’s headers as a Mapping. Exempt the Django view from the CSRF check with csrf_, since Sendora sends no CSRF token. The Django guide shows such a view in an app, as the next section says.
WebhookVerifier::verify() returns the event as a class of its own, such as BouncedEvent, so its details are typed. An event newer than your release of the SDK comes as an UnknownEvent, with the payload in data, rather than an error. It throws a WebhookVerificationException with stale_ when the signature is more than five minutes old, and with invalid_ when no signature in the header matches. Pass tolerance:, in seconds, to allow another age.
The raw body is file_ in plain PHP, and $request->getContent() in Symfony and Laravel. The header is $_SERVER['HTTP_, or $request->headers->get( in either framework. An inbound event with its content can be larger than nginx’s default client_ of 1 MB, as Limits shows, so raise it for the webhook’s route.
In Laravel and Symfony, the package’s route or the SDK’s request parser does all of this, as the next section says. A Laravel route of your own needs an exemption from CSRF protection, since Sendora sends no CSRF token.
WebhookVerifier makes a verifier, and its verify( returns the event as a class of its own, such as BouncedEvent, so its details() are typed. An event newer than your release of the SDK comes as an UnknownEvent, with the payload in toJson(), rather than an error. It throws a WebhookVerificationException with stale_ when the signature is more than five minutes old, and with invalid_ when no signature in the header matches. withTolerance( returns a verifier that allows another age.
Take the raw body as bytes, since a body decoded with another charset fails the check. In Spring MVC, take it as @RequestBody byte[] body, and the header with @RequestHeader(. In Jakarta REST, take a byte[] parameter, and the header with @HeaderParam(. On the JDK’s own server, read exchange, as the sample does. An inbound event with its content can be larger than many servers take by default, as Limits shows, so raise the limit for the webhook’s route.
If your Spring app uses Spring Security, exempt the route from its CSRF protection, since Sendora sends no CSRF token.
Receive in a framework
Each framework’s guide checks every delivery the framework’s way:
- Django: a view exempt from the CSRF check hands
requestto.read() verify_.webhook - Express:
expresskeeps the raw body for.raw() verifyWebhook, on a router mounted beforeexpress..json() - Laravel: the Laravel package’s route checks each delivery and fires a Laravel event for it.
- Next.js: a route handler hands its request to
sendora..webhooks .receive - Symfony: the PHP SDK’s request parser turns each delivery into a remote event.
Roll the secret
A webhook can have two live secrets at once, so you can replace one without a gap:
- Create a new secret. From then on, every delivery is signed with both.
POST /v1/webhooks/{webhookId}/secretscurl -X POST https://api.sendora.se/v1/webhooks/{webhookId}/secrets \
-H "Authorization: Bearer $SENDORA_API_TOKEN"import { Sendora } from '@sendora/sdk';
const sendora = new Sendora({
token: process.env.SENDORA_API_TOKEN,
});
const rolled = await sendora.webhooks.createSecret(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
);
console.log(rolled.secretId, rolled.secret);import os
from sendora import Sendora
sendora = Sendora(os.environ["SENDORA_API_TOKEN"])
rolled = sendora.webhooks.create_secret(
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70"
)
print(rolled.secret_id, rolled.secret)<?php
use Sendora\Sendora;
// The key comes from SENDORA_API_TOKEN.
$sendora = new Sendora();
$rolled = $sendora->webhooks->createSecret(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
);
echo $rolled->secretId, ' ', $rolled->secret, "\n";import se.sendora.Sendora;
import se.sendora.model.CreatedWebhookSecret;
class CreateWebhookSecret {
public static void main(String[] args) {
String webhookId =
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70";
// The server key comes from SENDORA_API_TOKEN.
try (var sendora = Sendora.fromEnv()) {
CreatedWebhookSecret rolled =
sendora.webhooks().createSecret(webhookId);
System.out.printf(
"%s %s%n", rolled.secretId(), rolled.secret());
}
}
}Response
{
"secretId": "5b6c7d8e-9f0a-4b1c-8d2e-3f4a5b6c7d8e",
"createdAt": "2026-09-20T12:00:00.000Z",
"secret": "whsec_0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f"
}- Move your receiver to the new secret. Deliveries verify with either one meanwhile.
- Delete the old secret by its id, which the webhook’s
secretslists.
DELETE /v1/webhooks/{webhookId}/secrets/{secretId}curl -X DELETE https://api.sendora.se/v1/webhooks/{webhookId}/secrets/{secretId} \
-H "Authorization: Bearer $SENDORA_API_TOKEN"import { Sendora } from '@sendora/sdk';
const sendora = new Sendora({
token: process.env.SENDORA_API_TOKEN,
});
await sendora.webhooks.deleteSecret(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
'4a5b6c7d-8e9f-4a0b-8c1d-2e3f4a5b6c7d',
);import os
from sendora import Sendora
sendora = Sendora(os.environ["SENDORA_API_TOKEN"])
sendora.webhooks.delete_secret(
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70",
"4a5b6c7d-8e9f-4a0b-8c1d-2e3f4a5b6c7d",
)<?php
use Sendora\Sendora;
// The key comes from SENDORA_API_TOKEN.
$sendora = new Sendora();
$sendora->webhooks->deleteSecret(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
'4a5b6c7d-8e9f-4a0b-8c1d-2e3f4a5b6c7d',
);import se.sendora.Sendora;
class DeleteWebhookSecret {
public static void main(String[] args) {
String webhookId =
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70";
String secretId =
"4a5b6c7d-8e9f-4a0b-8c1d-2e3f4a5b6c7d";
// The server key comes from SENDORA_API_TOKEN.
try (var sendora = Sendora.fromEnv()) {
sendora
.webhooks()
.deleteSecret(webhookId, secretId);
}
}
}A third live secret fails with secret_. Deleting the last live secret fails with last_, so every delivery carries a signature. You can also roll the secret on the webhook’s page in the dashboard, under the server’s Webhooks tab.
Retries, dead letters and replay
Sendora retries a failed attempt with growing delays, for about a day, on the schedule on Limits. After the last retry, the delivery is dead. It stays listed until you replay it.
GET /v1/webhooks/{webhookId}/deliveries?status=dead&limit=50curl 'https://api.sendora.se/v1/webhooks/{webhookId}/deliveries?status=dead&limit=50' \
-H "Authorization: Bearer $SENDORA_API_TOKEN"import { Sendora } from '@sendora/sdk';
const sendora = new Sendora({
token: process.env.SENDORA_API_TOKEN,
});
const { deliveries } = await sendora.webhooks.deliveries(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
{
status: 'dead',
limit: 50,
},
);
for (const delivery of deliveries) {
console.log(
delivery.deliveryId,
delivery.event,
delivery.attempts,
delivery.lastError,
);
}import os
from sendora import Sendora
sendora = Sendora(os.environ["SENDORA_API_TOKEN"])
page = sendora.webhooks.deliveries(
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70",
status="dead",
limit=50,
)
for delivery in page.deliveries:
print(
delivery.delivery_id,
delivery.event,
delivery.attempts,
delivery.last_error,
)<?php
use Sendora\Sendora;
// The key comes from SENDORA_API_TOKEN.
$sendora = new Sendora();
$page = $sendora->webhooks->deliveries(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
status: 'dead',
limit: 50,
);
foreach ($page->deliveries as $delivery) {
printf(
"%s %s %d %s\n",
$delivery->deliveryId,
$delivery->event,
$delivery->attempts,
$delivery->lastError,
);
}import se.sendora.Sendora;
import se.sendora.model.DeliveryPage;
import se.sendora.model.DeliveryQuery;
import se.sendora.model.DeliveryStatus;
class ListDeadDeliveries {
public static void main(String[] args) {
String webhookId =
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70";
DeliveryQuery dead =
DeliveryQuery.builder()
.status(DeliveryStatus.DEAD)
.limit(50)
.build();
// The server key comes from SENDORA_API_TOKEN.
try (var sendora = Sendora.fromEnv()) {
DeliveryPage page =
sendora.webhooks().deliveries(webhookId, dead);
for (var delivery : page.deliveries()) {
System.out.printf(
"%s %s %d %s%n",
delivery.deliveryId(),
delivery.eventAsString(),
delivery.attempts(),
delivery.lastError().orElse(""));
}
}
}
}Response
{
"deliveries": [
{
"deliveryId": "9e8d7c6b-5a4f-4e3d-9c2b-1a0f9e8d7c60",
"event": "bounced",
"messageId": "5f432ffd-c005-499b-aa3a-5b8a088ea20e",
"inboundMessageId": null,
"status": "dead",
"attempts": 9,
"nextAttemptAt": null,
"lastStatusCode": 503,
"lastError": "http_503",
"deliveredAt": null,
"createdAt": "2026-09-14T12:00:02.000Z"
}
],
"next": null
}A replay queues a delivery again, whatever its state, with the same id and event. Its attempt keeps counting. The reference has the call.
Remove
DELETE /v1/webhooks/{webhookId}curl -X DELETE https://api.sendora.se/v1/webhooks/{webhookId} \
-H "Authorization: Bearer $SENDORA_API_TOKEN"import { Sendora } from '@sendora/sdk';
const sendora = new Sendora({
token: process.env.SENDORA_API_TOKEN,
});
await sendora.webhooks.delete(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
);import os
from sendora import Sendora
sendora = Sendora(os.environ["SENDORA_API_TOKEN"])
sendora.webhooks.delete(
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70"
)<?php
use Sendora\Sendora;
// The key comes from SENDORA_API_TOKEN.
$sendora = new Sendora();
$sendora->webhooks->delete(
'7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70',
);import se.sendora.Sendora;
class DeleteWebhook {
public static void main(String[] args) {
String webhookId =
"7c1e4d2a-0b9f-4a3e-8d6c-5e2f1a9b8c70";
// The server key comes from SENDORA_API_TOKEN.
try (var sendora = Sendora.fromEnv()) {
sendora.webhooks().delete(webhookId);
}
}
}Deliveries still pending for the webhook are dropped with it.