Démo Ceci est une démo en lecture seule. Documentation Acheter ZephAI
New

Gateway v2 is live — one endpoint, every model, streaming tool-calls. Read the changelog

Guide

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.

POST/v1/webhooksRegister an endpoint
register
curl -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", ... }
Store the secret immediately. It is shown once. Regenerating it invalidates in-flight deliveries' signatures after a 60-second overlap.

Event types

EventFires whenTypical consumer
POST budget.thresholdSpend crosses 50/80/100% of a limitSlack, PagerDuty, FinOps
POST model.degradedA subscribed listing breaches its SLORouter, status page
POST model.recoveredHealth returns to normalRouter, status page
POST key.exposedLeak scanner finds a key in a public repoSecurity, auto-revoke
POST key.revokedA key is revoked or expiresDeploy tooling
POST invoice.paidInvoice settlesAccounting
POST payout.paidVendor payout completesVendor finance
POST listing.reviewedModeration decision on a listingVendor 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"])
Verify before you parse. Read the raw body for signature checks — JSON re-serialisation changes bytes and breaks the signature. Reject deliveries older than 5 minutes to defeat replays.

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 id and created_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.
payload shape
{
  "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.

DeliveryEventResponseLatencyAttempts
dlv_4412budget.threshold200184 ms1Open console
dlv_4411model.degraded20492 ms1Open console
dlv_4408key.exposed5005.0 s5Open console