Webhooks
A webhook endpoint is a URL on your side. When an event you subscribed to happens, zemoData sends it a
POST with a JSON body, signed with the endpoint’s secret. Add and manage endpoints on the portal’s
Webhooks page (owners, admins and developers), or with a live key that has the webhooks
scope: GET /v1/webhooks, POST /v1/webhooks (url, events, description; the answer holds the
secret once), DELETE /v1/webhooks/{id} and POST /v1/webhooks/{id}/test. Test keys can’t manage
endpoints (403 auth.forbidden).
Events
Section titled “Events”| Event | Sent when | data |
|---|---|---|
credits.low |
A call takes your balance below your low-balance threshold (set on the portal’s Organization page). Sent once per crossing. | balance, threshold |
credits.granted |
Credits are added: a plan renewal, a pack, a coupon, a grant from zemoData, a trial. | kind, credits, ledger_entry_id |
key.revoked |
An API key is revoked, by a member, by zemoData, or automatically (for example a leaked key). | key_id, public_id |
invoice.paid |
An invoice is paid. | invoice_id, amount_paid_cents, currency |
invoice.payment_failed |
Collecting an invoice failed; update the payment method. | invoice_id, amount_due_cents |
bulk_job.completed |
A bulk job finished; get its result from GET /v1/bulk/jobs/{id}. |
job_id, kind, status, env, rows, matched, charged_credits |
bulk_job.failed |
A bulk job stopped (failed or expired); rows done before it stopped are in its result file. |
job_id, kind, status, env, error_code, error_message, matched, charged_credits |
product.updated |
A data product you hold has a new version (its segment, bundles or price may differ). | product_id, version_id, version |
webhook.test |
You press Send test event in the portal. | endpoint_id |
The request
Section titled “The request”POST /hooks/zemodata HTTP/1.1Content-Type: application/jsonUser-Agent: zemoData-Webhooks/1.0Zemo-Event-Id: evt_01JD3K8ZQ4V6W9XG2M5N7P0R1SZemo-Event-Type: credits.lowZemo-Delivery-Id: whd_01JD3K9A2B3C4D5E6F7G8H9J0KZemo-Delivery-Attempt: 1Zemo-Signature: t=1764064800,v1=9e0623871740b6580b8b9e30737125ff552eebd8830dc037acc0ac8bd84f064d
{"created_at":"2026-11-25T10:00:00Z","data":{"balance":480,"threshold":500},"id":"evt_01JD3K8ZQ4V6W9XG2M5N7P0R1S","type":"credits.low"}The body is always { id, type, created_at, data }. id is the event’s ID: the same event can reach you
more than once (a retry after a timeout, for example), so use id to handle each event once. Answer
with any 2xx status within 10 seconds; do the work afterwards.
Check the signature
Section titled “Check the signature”Zemo-Signature is t=<unix time>,v1=<hex>, where the hex is HMAC-SHA256 of t, a dot and the raw
body, keyed with the endpoint’s signing secret (whsec_…, shown once when you add the endpoint).
Compute it over the exact bytes you received, before any JSON parsing, compare in constant time, and
refuse anything signed more than 5 minutes ago. (The example above is signed with the made-up secret
whsec_0123456789012345678901234567890123456789.)
"""Check that a webhook delivery came from zemoData: the `Zemo-Signature` header.
Use `verify` in your endpoint with the raw request body (the exact bytes, before any JSON parsing).Run as a script, it checks one delivery given in environment variables."""
import hashlibimport hmacimport osimport sysimport time
TOLERANCE_SECONDS = 300 # refuse deliveries signed more than 5 minutes ago (replays)
def verify(secret: str, header: str, raw_body: bytes, now: float | None = None) -> bool: """True if `header` (`t=<unix>,v1=<hex>[,v1=<hex>]`) signs `raw_body` with `secret`.""" timestamp = "" signatures = [] for part in header.split(","): name, _, value = part.strip().partition("=") if name == "t": timestamp = value elif name == "v1": signatures.append(value) if not timestamp.isdigit() or not signatures: return False if abs((now or time.time()) - int(timestamp)) > TOLERANCE_SECONDS: return False expected = hmac.new(secret.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256).hexdigest() # During a secret rotation a delivery carries two v1 signatures: either may match. return any(hmac.compare_digest(expected, signature) for signature in signatures)
if __name__ == "__main__": secret = os.environ["ZEMO_WEBHOOK_SECRET"] # whsec_…, shown once when you add the endpoint header = os.environ["ZEMO_SIGNATURE"] # the Zemo-Signature header with open(os.environ["ZEMO_WEBHOOK_BODY_FILE"], "rb") as body_file: # the raw body body = body_file.read() if verify(secret, header, body): print("signature valid") else: print("signature invalid: reject the delivery with 400") sys.exit(1)// Check that a webhook delivery came from zemoData: the Zemo-Signature header. Node 18 or later.// Use `verify` in your endpoint with the raw request body (the exact bytes, before JSON parsing).// Run as a script, it checks one delivery given in environment variables.import { createHmac, timingSafeEqual } from "node:crypto";import { readFileSync } from "node:fs";import { pathToFileURL } from "node:url";
const TOLERANCE_SECONDS = 300; // refuse deliveries signed more than 5 minutes ago (replays)
export function verify(secret, header, rawBody, now = Date.now() / 1000) { let timestamp = ""; const signatures = []; for (const part of header.split(",")) { const [name, value = ""] = part.trim().split("=", 2); if (name === "t") timestamp = value; else if (name === "v1") signatures.push(value); } if (!/^\d+$/.test(timestamp) || signatures.length === 0) return false; if (Math.abs(now - Number(timestamp)) > TOLERANCE_SECONDS) return false; const expected = createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest(); // During a secret rotation a delivery carries two v1 signatures: either may match. return signatures.some((signature) => { const given = Buffer.from(signature, "hex"); return given.length === expected.length && timingSafeEqual(given, expected); });}
// Run directly (not imported): check one delivery.if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { const secret = process.env.ZEMO_WEBHOOK_SECRET; // whsec_…, shown once when you add the endpoint const header = process.env.ZEMO_SIGNATURE; // the Zemo-Signature header const body = readFileSync(process.env.ZEMO_WEBHOOK_BODY_FILE); // the raw body if (verify(secret, header, body)) { console.log("signature valid"); } else { console.log("signature invalid: reject the delivery with 400"); process.exit(1); }}# Check that a webhook delivery came from zemoData (the Zemo-Signature header) with openssl.# ZEMO_WEBHOOK_SECRET is the endpoint's whsec_… secret, ZEMO_SIGNATURE the header, and# ZEMO_WEBHOOK_BODY_FILE a file holding the exact raw body.set -euo pipefail
timestamp="$(printf '%s' "$ZEMO_SIGNATURE" | tr ',' '\n' | sed -n 's/^t=//p')"expected="$( { printf '%s.' "$timestamp"; cat "$ZEMO_WEBHOOK_BODY_FILE"; } \ | openssl dgst -sha256 -hmac "$ZEMO_WEBHOOK_SECRET" -hex | sed 's/^.* //')"
age=$(( $(date +%s) - timestamp ))if [ "${age#-}" -gt 300 ]; then # older than 5 minutes: a replay echo "signature invalid: reject the delivery with 400"; exit 1fi# During a secret rotation the header carries two v1 signatures: either may match.# (grep reads to the end instead of -q: with pipefail, -q stopping early can fail the pipe.)if printf '%s' "$ZEMO_SIGNATURE" | tr ',' '\n' | grep -x "v1=$expected" > /dev/null; then echo "signature valid"else echo "signature invalid: reject the delivery with 400"; exit 1fiThese samples run as tests against deliveries signed by the platform’s own code.
Rotating the secret
Section titled “Rotating the secret”Replace secret in the portal shows a new secret once. For the overlap you choose (none, 1, 24 or 72
hours) each delivery carries two v1= signatures, one per secret, so a receiver with either secret
accepts it. Deploy the new secret, then let the overlap run out.
Retries and the delivery log
Section titled “Retries and the delivery log”A delivery that gets no 2xx answer (an error status, a timeout, a refused connection or a TLS error)
is retried after 1 minute, 5 minutes, 30 minutes, 2, 6, 12 and 24 hours: eight attempts over about two
days, then it is marked failed. Redirects are not followed.
The portal’s delivery log shows each event, its status (waiting, delivered, retrying, failed), the attempts, the last HTTP status and response time, the reason it failed, and the body. Send again retries a failed delivery at once.
An endpoint is turned off after 50 deliveries in a row fail every attempt (the limit is the setting
webhooks.disable_after_failures), and we email your billing address. Turn it back on in the portal
once it works.
URLs we accept
Section titled “URLs we accept”Endpoint URLs must be public https addresses, without a user name, password or #fragment. We
resolve the host name when you save the endpoint and again before every delivery, and refuse private,
loopback, link-local, carrier-grade NAT, multicast and reserved addresses (including cloud metadata
addresses such as 169.254.169.254); the delivery connects to the address that was checked. An
organization can have 10 endpoints by default (webhooks.max_endpoints, which can differ by plan).
Errors
Section titled “Errors”| Problem | When |
|---|---|
422 validation with errors[].code url.https_required, url.invalid, url.unresolvable or url.private_address |
The URL is not one we accept (see above). |
422 validation with events.required or events.unknown |
No events chosen, or an event that doesn’t exist. |
409 webhooks.limit |
The organization already has the most endpoints it may have. |
409 webhooks.endpoint_disabled |
A test send or retry for an endpoint that is turned off. |
409 webhooks.delivery_state |
A retry for a delivery that is waiting or already delivered. |