Events & receiving
Webhooks
Receive signed HTTP callbacks for delivery and engagement events.
Configure up to three URLs per event type on the domain's Webhooks tab or with POST /v3/domains/{domain}/webhooks. Types: accepted, delivered, permanent_fail, temporary_fail, opened, clicked, unsubscribed, complained.
Payload
Example
POST /your-endpoint
Content-Type: application/json
{
"signature": {
"timestamp": "1793361600",
"token": "a8c2f0…",
"signature": "d2271d12299f6592d9d44cd9d250f0704e4674c30d79d07c47a66f95ce71cf55"
},
"event-data": {
"id": "0192f0a1-…",
"timestamp": 1793361600.123,
"event": "delivered",
"recipient": "[email protected]",
"tags": ["onboarding"],
"user-variables": {},
"delivery-status": { "code": 250, "message": "OK", "mx-host": "gmail-smtp-in.l.google.com", "tls": true },
"message": { "headers": { "message-id": "…", "from": "…", "to": "…", "subject": "…" }, "size": 4211 }
}
}Verifying signatures
Compute hex(HMAC-SHA256(signing_key, timestamp + token)) with your webhook signing key (Settings) and compare it to signature in constant time. Reject timestamps older than a few minutes and cache tokens to prevent replays.
import crypto from "node:crypto";
export function verify(signingKey, { timestamp, token, signature }) {
const digest = crypto
.createHmac("sha256", signingKey)
.update(timestamp + token)
.digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;
return fresh && crypto.timingSafeEqual(Buffer.from(digest), Buffer.from(signature));
}
// Express handler
app.post("/webhooks/mailzone", express.json(), (req, res) => {
if (!verify(process.env.MAILZONE_SIGNING_KEY, req.body.signature)) return res.sendStatus(406);
const event = req.body["event-data"];
console.log(event.event, event.recipient);
res.sendStatus(200);
});Retries
Respond with any 2xx within 10 seconds. Other responses and timeouts are retried with exponential back-off for 8 hours. Recent attempts are visible on the Webhooks tab.