Webhooks that you can trust
Signed payloads, 5× retries with exponential backoff, idempotency keys and a delivery log you can replay from.
Why webhooks
Polling /v1/usage tells you what happened. Webhooks tell you the moment it happens — before your customer notices.
Budget & rate alerts
React to spend and 429 storms in seconds, not at the next dashboard refresh.
Model degradation
Fail over your own traffic when a listing crosses its SLO.
Billing & payouts
Reconcile invoices and vendor settlements automatically.
Register an endpoint
Endpoints are registered per workspace. You choose the events, the secret is generated for you, and every delivery is signed.
/v1/webhooksRegister an endpointcurl -X POST https://api.zephai.dev/v1/webhooks \ -H "Authorization: Bearer $ZEPHAI_KEY" \ -d '{ "url": "https://hooks.acme.dev/zephai", "events": ["budget.threshold", "model.degraded", "key.exposed"], "active": true }' # { "id": "wh_9f2ab41c", "secret": "whsec_••••3f9a", ... }
Event types
| Event | Fires when | Typical consumer |
|---|---|---|
| POST budget.threshold | Spend crosses 50/80/100% of a limit | Slack, PagerDuty, FinOps |
| POST model.degraded | A subscribed listing breaches its SLO | Router, status page |
| POST model.recovered | Health returns to normal | Router, status page |
| POST key.exposed | Leak scanner finds a key in a public repo | Security, auto-revoke |
| POST key.revoked | A key is revoked or expires | Deploy tooling |
| POST invoice.paid | Invoice settles | Accounting |
| POST payout.paid | Vendor payout completes | Vendor finance |
| POST listing.reviewed | Moderation decision on a listing | Vendor console |
Subscribe with a wildcard ("events": ["*"]) during development, then narrow to what you act on.
Verifying signatures
Every delivery carries X-Zephai-Signature: t=1764412931,v1=<hmac>. Compute an HMAC-SHA256 over t + "." + rawBody using your endpoint secret and compare with a constant-time function.
import hmac, hashlib, json def verify(secret: str, payload: bytes, header: str) -> bool: parts = dict(p.split("=", 1) for p in header.split(",")) signed = f"{parts['t']}.".encode() + payload digest = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest() return hmac.compare_digest(digest, parts["v1"])
import crypto from "node:crypto"; export function verify(secret, rawBody, header) { const parts = Object.fromEntries( header.split(",").map((p) => p.split("=")) ); const signed = `${parts.t}.${rawBody}`; const digest = crypto .createHmac("sha256", secret) .update(signed) .digest("hex"); return crypto.timingSafeEqual( Buffer.from(digest), Buffer.from(parts.v1) ); }
Retries & idempotency
- Return 2xx within 5 seconds — do the work asynchronously.
- Non-2xx or timeout → retried 5× at 1s, 5s, 30s, 5m, 30m.
- Every payload carries
idandcreated_at— store the id as your idempotency key. - After the final failure the delivery is marked dead and appears in the delivery log for replay.
{
"id": "evt_9f2ab41c",
"type": "budget.threshold",
"created_at": "2026-11-28T14:02:11.402Z",
"workspace_id": "acc_9f2ab41c",
"data": {
"limit_usd": 50,
"used_usd": 41.20,
"percent": 82.4,
"key_id": "key_prod_default"
}
}
Delivery log & replay
The console keeps every delivery for 30 days: request, response, latency and signature. Replay any of them to a staging endpoint while you debug.
| Delivery | Event | Response | Latency | Attempts | |
|---|---|---|---|---|---|
| dlv_4412 | budget.threshold | 200 | 184 ms | 1 | Open console |
| dlv_4411 | model.degraded | 204 | 92 ms | 1 | Open console |
| dlv_4408 | key.exposed | 500 | 5.0 s | 5 | Open console |