Webhooks
anymail sends a signed POST request with a JSON body to your URL when an event happens in your workspace. After this page you can receive an event, verify its signature and handle retries.
Two ways to receive events#
| Workspace webhook | Subscriptions | |
|---|---|---|
| Set up in | Settings, Integrations, Webhooks | POST /api/v1/hooks |
| Number of URLs | One for the workspace | Many, each for one event |
| Choice of events | None. It receives every event in its column below. | One event per subscription. |
Both use the same delivery format, the same signature and the same retries. The workspace webhook also has a Send test event button that delivers an event of type test.
Events#
The type field of the payload and the X-Seegnals-Event header carry the event name. The header names are part of the protocol and keep their original prefix.
| Event | Fires when | Workspace webhook | Subscription |
|---|---|---|---|
sent |
anymail sent a message. | Yes | |
replied |
A prospect replied. | Yes | as new_reply |
bounced |
A message bounced. The enrolment of the prospect stopped. | Yes | as bounce |
unsubscribed |
A prospect used the one-click unsubscribe link. | Yes | as unsubscribe |
clicked |
A prospect clicked a tracked link. | Yes | as link_clicked |
positive_reply |
A reply was classified as interested. | Yes | |
prospect_interested |
A reply was classified as interested, by the classifier or by a person. | Yes | Yes |
prospect_maybe_later |
A reply was classified as neutral (maybe later). | Yes | Yes |
prospect_not_interested |
A reply was classified as not interested. | Yes | Yes |
prospect_autoreplied |
A reply was recognised as an autoresponder, such as an out of office message. | Yes | Yes |
campaign_paused |
A campaign changed to paused, by a person, the API or the engine. |
Yes | Yes |
campaign_completed |
A campaign changed to completed. |
Yes | Yes |
email_opened |
A tracked message was opened. | Yes | |
prospect_added |
A prospect was created, in the app, by an import or through the API. | Yes | |
offer_opened |
A recipient opened an offer for the first time. Visits from known bots and link scanners are filtered out. | Yes | Yes |
offer_returned |
A recipient came back to an offer for a second or later visit. | Yes | Yes |
offer_read |
A recipient read an offer to the end, the read status of offers. It fires once per offer. |
Yes | Yes |
offer_temperature_changed |
The engagement level of an offer changed. The first calculation for a new offer sends nothing. | Yes | Yes |
The classification events fire on every change of the class, so a correction by a person sends a new event. positive_reply and prospect_interested overlap. Subscribe to one of them.
email_opened and prospect_added are subscription only. Opens are unreliable, because Apple Mail Privacy Protection loads the tracking pixel without a person opening the message, and an import of 10,000 prospects would mean 10,000 deliveries. Subscribe to them only when you want them. There is no event for a delivery, because SMTP does not report one.
Opens and clicks are tracked only when the tracking domain of the workspace is verified. See Domains.
Request#
Each delivery is a POST with these headers.
| Header | Value |
|---|---|
Content-Type |
application/json |
User-Agent |
Seegnals-Webhook/1 |
X-Seegnals-Event |
The event name. |
X-Seegnals-Delivery |
The id of this delivery. A retry of the same delivery keeps the same id. |
X-Seegnals-Signature |
t=<unix seconds>,v1=<hex HMAC-SHA256> |
Payload#
{
"id": "10000000-0000-0000-0000-000000000002",
"type": "replied",
"occurred_at": "2026-09-03T10:00:00Z",
"workspace_id": "00000000-0000-0000-0000-000000000001",
"prospect_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"prospect_email": "ada@example.com",
"campaign_id": "3f2b1c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"campaign_name": "Q3 outbound",
"metadata": {
"replyId": "20000000-0000-0000-0000-000000000001",
"from": "ada@example.com"
}
}
| Field | Notes |
|---|---|
id |
The id of the event. |
type |
The event name. |
occurred_at |
ISO 8601 in UTC with a Z suffix. |
workspace_id |
The workspace. |
prospect_id, prospect_email |
The prospect. |
campaign_id, campaign_name |
The campaign. Both can be null. |
For campaign_paused and campaign_completed, prospect_id and prospect_email are null.
| metadata | Event details. The keys depend on the type. |
Keys you can find in metadata:
| Type | Keys |
|---|---|
sent |
step, messageId |
replied |
replyId, from |
bounced |
step, error |
unsubscribed |
via |
clicked, link_clicked |
url, messageId, via |
email_opened |
messageId and the details of the tracking event |
positive_reply, prospect_interested, prospect_maybe_later, prospect_not_interested, prospect_autoreplied |
replyId |
campaign_paused, campaign_completed |
status, reason (the pause reason, or null) |
prospect_added |
None. campaign_id is null. |
offer_opened, offer_returned |
offerSendId, visitIndex, via |
offer_read |
offerSendId, offerName, totalActiveSeconds, sections |
offer_temperature_changed |
offerSendId, offerName, from, to (hot, warm, neutral, cooling or cold), reason |
The clicked payload never contains the tracking token.
Signing secret#
anymail signs each delivery with the signing secret of the workspace. It has the form whsec_….
- In Settings, Integrations, Webhooks, select Reveal signing secret. Rotate secret creates a new one.
- A workspace that starts with a subscription from the API gets a secret with the first subscription.
- anymail never sends an unsigned delivery. Without a secret, the delivery is rejected.
Verify the signature#
The signature is an HMAC-SHA256 of the string <t>.<raw body>, where t is the timestamp from the header and the body is the exact bytes of the request. The key is the signing secret. The header carries the result as lower-case hex after v1=.
- Read the raw request body. Do not parse it and serialise it again, because that can change key order and number formatting.
- Split the header into
tandv1, compute the HMAC oft + "." + bodyand compare it withv1in constant time. - Reject the request when
tis more than 300 seconds away from your clock. This is your protection against a replayed request, because anymail cannot know that somebody sent a captured request again.
For a longer walkthrough, read Verify a webhook HMAC signature.
Node#
import { createHmac, timingSafeEqual } from "node:crypto";
const TOLERANCE_SECONDS = 300;
export function verifyAnymailSignature(secret, header, rawBody) {
const parts = Object.fromEntries(
header.split(",").map((part) => part.trim().split("=", 2))
);
const timestamp = Number(parts.t);
const given = parts.v1;
if (!Number.isInteger(timestamp) || !given) return false;
const age = Math.abs(Math.floor(Date.now() / 1000) - timestamp);
if (age > TOLERANCE_SECONDS) return false;
const expected = createHmac("sha256", secret)
.update(`${timestamp}.${rawBody}`)
.digest("hex");
const a = Buffer.from(expected, "utf8");
const b = Buffer.from(given.toLowerCase(), "utf8");
return a.length === b.length && timingSafeEqual(a, b);
}
With Express, take the raw body with express.raw({ type: "application/json" }) and pass req.body.toString("utf8") as rawBody.
Python#
import hashlib
import hmac
import time
TOLERANCE_SECONDS = 300
def verify_anymail_signature(secret: str, header: str, raw_body: bytes) -> bool:
parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p)
try:
timestamp = int(parts["t"])
given = parts["v1"].lower()
except (KeyError, ValueError):
return False
if abs(int(time.time()) - timestamp) > TOLERANCE_SECONDS:
return False
expected = hmac.new(
secret.encode("utf-8"),
f"{timestamp}.".encode("utf-8") + raw_body,
hashlib.sha256,
).hexdigest()
return hmac.compare_digest(expected, given)
Delivery and retries#
| Rule | Value |
|---|---|
| Attempts | 3 in total: the first one and two retries. |
| Spacing | About one minute between attempts. |
| Response time | Your endpoint has 10 seconds to answer. |
| Success | Any 2xx status. anymail does not read the response body. |
| Redirects | anymail does not follow a 3xx response. It counts as a failure. Give anymail the final URL. |
| Failure | A non-2xx status, a timeout or a connection error. |
After the third failed attempt, anymail stops. The status of each delivery, the number of tries and the last error are in Settings, Integrations, Webhooks. The event stays recorded in anymail.
Handle deliveries idempotently#
A delivery can arrive more than once, for example when your endpoint processed it but the answer timed out. Store the X-Seegnals-Delivery value and ignore a repeat of an id you have already processed. Answer 2xx for the repeat.
Answer quickly. Accept the request, put the work in a queue and return 200. The 10 second limit covers your whole handler.