Webhook payload and signatures
When an event happens for a webhook you created, Sender sends an HTTP request to the webhook’s URL. This page describes that request, the payload for each topic, and how to verify that a request really came from Sender.
The request
Section titled “The request”HTTP method: POST
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | Sender-Hook-Dispatcher |
X-Sender-Hmac-Sha256 | The request signature. See Verifying signatures. |
The body is the event’s payload as a JSON object. The body has no envelope: it does not include the topic, an event ID or a timestamp. Sender also sends no other headers that identify the event.
Payloads by topic
Section titled “Payloads by topic”| Topic | Payload |
|---|---|
subscribers/new | Subscriber |
subscribers/updated | Subscriber |
subscribers/unsubscribed | Subscriber |
groups/new-subscriber | Subscriber |
groups/unsubscribed | Subscriber |
groups/new | Group |
campaigns/new | Campaign |
bounces/new | Bounce |
Subscriber payload
Section titled “Subscriber payload”Sent for every subscribers/* topic and for groups/new-subscriber and groups/unsubscribed. It has the
same shape as a subscriber returned by the Subscribers API.
{ "id": "z61Z7gy", "firstname": "Jane", "lastname": null, "phone": null, "phone_country": null, "created": "2025-06-05T12:55:13.000000Z", "status": { "email": "active", "temail": "active" }, "ip_address": "203.0.113.10", "bounced_at": null, "unsubscribed_at": null, "location": null, "subscriber_tags": [ { "id": "eVnJVX", "title": "Newsletter" } ], "columns": [ { "id": "avAlVe", "title": "First name", "type": "text", "default": true, "value": "Jane" } ], "source": "FORM"}Group payload
Section titled “Group payload”Sent for groups/new.
{ "id": "eVnJVX", "title": "Newsletter"}Campaign payload
Section titled “Campaign payload”Sent for campaigns/new.
{ "id": "bk5X5J", "title": "November newsletter", "subject": "What's new in November", "from": "Sender",}Bounce payload
Section titled “Bounce payload”Sent for bounces/new. subscriber is the same subscriber payload as above, with
its status after the bounce. The payload has email_campaign_data when the bounced email was a campaign,
and transactional_campaign_data when it was a transactional email.
{ "email_id": "ep2W4y-7pn8o21-YPpLY9PR5Jy9-x7GYQ", "subscriber": { "id": "z61Z7gy", "status": { "email": "bounced", "temail": "bounced" }, "...": "the other subscriber payload fields" }, "email_campaign_data": { "campaign_id": "bk5X5J", }}{ "email_id": "ep2W4y-7pn8o21-YPpLY9PR5Jy9-x7GYQ", "subscriber": { "id": "z61Z7gy", "...": "the other subscriber payload fields" }, "transactional_campaign_id": "aQgA89", "transactional_campaign_data": { "domain_id": "dWLe7D", "smtp_response": "550 5.1.1 User unknown", "variables": { "order_id": "1042" } }}| Field | Description |
|---|---|
email_id | ID of the bounced email, the emailId returned when it was sent. |
email_campaign_data.campaign_id | ID of the campaign the email belonged to. |
transactional_campaign_id | ID of the transactional campaign. |
transactional_campaign_data.domain_id | ID of the sending domain, or null. |
transactional_campaign_data.variables | The variables the email was sent with, as you sent them. |
*.smtp_response | The receiving server’s SMTP response. |
transactional_campaign_id is only present when the email was sent from a transactional campaign
(/v2/message/{id}/send), not for emails sent without a template.
Verifying signatures
Section titled “Verifying signatures”Every request is signed, so you can check that it came from Sender and that the body was not changed.
| Header | X-Sender-Hmac-Sha256. Header names are case-insensitive: many frameworks give it to you as x-sender-hmac-sha256. |
| Algorithm | HMAC-SHA256 |
| Key | Your account’s signing secret, used as a UTF-8 string, exactly as shown in the app. Do not hex- or base64-decode it. |
| Signed bytes | The raw request body, exactly as received. Nothing else is signed: no timestamp, URL, method or headers. |
| Encoding | Lowercase hexadecimal, 64 characters |
| Prefix | None. The header contains only the hex digest, without sha256= or a version marker. |
Signing secret
Section titled “Signing secret”Your signing secret is in the Sender app under Settings → Webhooks → Signing secret. One secret signs all of your account’s webhooks. Rotate secret creates a new one.
How to verify
Section titled “How to verify”- Read the raw request body before any JSON parsing. Do not parse it and re-serialize it: key order,
whitespace and escaping (for example
\/or<) would change, and the signature would no longer match. - Compute HMAC-SHA256 of those bytes with your signing secret as the key, and hex-encode the result.
- Compare it with the
X-Sender-Hmac-Sha256header using a constant-time comparison. - If they don’t match, reject the request with a
4xxstatus other than404(see Retries).
import crypto from "node:crypto";import express from "express";
const app = express();const secret = process.env.SENDER_WEBHOOK_SECRET;
// express.raw keeps the body as a Buffer with the exact bytes Sender sent.app.post("/hooks/sender", express.raw({ type: "application/json" }), (req, res) => { const received = req.get("X-Sender-Hmac-Sha256") ?? ""; const expected = crypto.createHmac("sha256", secret).update(req.body).digest("hex");
const valid = received.length === expected.length && crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));
if (!valid) { return res.status(401).send("invalid signature"); }
const payload = JSON.parse(req.body.toString("utf8")); // ... handle payload res.sendStatus(200);});$secret = getenv('SENDER_WEBHOOK_SECRET');
$body = file_get_contents('php://input');$received = $_SERVER['HTTP_X_SENDER_HMAC_SHA256'] ?? '';$expected = hash_hmac('sha256', $body, $secret);
if (!hash_equals($expected, $received)) { http_response_code(401); exit('invalid signature');}
$payload = json_decode($body, true);// ... handle payloadhttp_response_code(200);import hashlibimport hmacimport os
from flask import Flask, abort, request
app = Flask(__name__)SECRET = os.environ["SENDER_WEBHOOK_SECRET"].encode("utf-8")
@app.post("/hooks/sender")def sender_webhook(): body = request.get_data() # raw bytes, before JSON parsing received = request.headers.get("X-Sender-Hmac-Sha256", "") expected = hmac.new(SECRET, body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, received): abort(401)
payload = request.get_json() # ... handle payload return "", 200func senderWebhook(w http.ResponseWriter, r *http.Request) { body, err := io.ReadAll(r.Body) if err != nil { http.Error(w, "cannot read body", http.StatusBadRequest) return }
mac := hmac.New(sha256.New, []byte(os.Getenv("SENDER_WEBHOOK_SECRET"))) mac.Write(body) expected := hex.EncodeToString(mac.Sum(nil))
if !hmac.Equal([]byte(expected), []byte(r.Header.Get("X-Sender-Hmac-Sha256"))) { http.Error(w, "invalid signature", http.StatusUnauthorized) return }
var payload map[string]any if err := json.Unmarshal(body, &payload); err != nil { http.Error(w, "invalid JSON", http.StatusBadRequest) return } // ... handle payload w.WriteHeader(http.StatusOK)}Test vector
Section titled “Test vector”Use these values to check your implementation. The secret is an example, not a real one.
| Secret | whsec_example_not_a_real_secret |
| Body | {"id":"z61Z7gy","email":"[email protected]"} |
X-Sender-Hmac-Sha256 | 69c933cce4072bd906886e8b5e1d556fd5392dd7777870751935b68d46f4b31a |
| openssl dgst -sha256 -hmac 'whsec_example_not_a_real_secret'Retries
Section titled “Retries”A delivery succeeds when your endpoint answers with a 2xx status within 10 seconds.
404 Not Found: Sender stops right away and does not retry.- Any other status, a timeout or a connection error: Sender retries. There are 5 attempts in total, with waits of 5, 10, 20 and 40 seconds between them. After the fifth failed attempt the event is dropped.
Deliveries can arrive out of order, and an event can be delivered more than once, for example when your endpoint processed it but answered too slowly.
Replay protection and duplicates
Section titled “Replay protection and duplicates”Sender does not send a timestamp or an event or delivery ID, in the headers or in the body. A retry sends the same body with the same signature, so a valid signature proves the request came from Sender but not that it is new. To protect against replays and duplicates:
- Use an HTTPS endpoint, so a request cannot be captured and resent by a third party.
- Make your handler idempotent. For example, apply a subscriber payload as “set this state” rather than “add one”.
- To drop exact duplicates, keep the signatures you processed recently (for example for 24 hours), and
skip a request whose
X-Sender-Hmac-Sha256you have already seen. Two deliveries with identical bodies have identical signatures.