Skip to main content

Webhooks

Webhooks let your application react to events as they happen instead of polling. You subscribe a URL to a set of event types on a network; AdBridge then POSTs a signed JSON envelope to that URL whenever a matching event occurs.

Manage subscriptions under /v1/networks/{networkId}/webhooks (administrator role required).

Event types

EventFires when
offer.acceptedA campaign offer is accepted.
offer.rejectedA campaign offer is rejected.
optin.completedA podcast completes opt-in.
invitation.acceptedA network invitation is accepted.
creative.readyA host-voiced creative finished generating and its audio is ready.
creative.failedA creative failed to generate.

The creative.ready / creative.failed events are how you learn the outcome of the asynchronous creative generation kicked off by accepting an offer.

Creating a subscription

curl -X POST https://api.adbridge.ai/v1/networks/7Hb2Kp9QvL3mNx0R8tZ4/webhooks \
-H "Authorization: Bearer $ADBRIDGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/adbridge",
"events": ["offer.accepted", "creative.ready"]
}'

The response includes a secret (e.g. whsec_…) once — store it; it is never returned again and is used to verify deliveries.

Delivery format

Each delivery is a POST of a JSON envelope:

{
"id": "b1d2c3e4-...",
"type": "offer.accepted",
"occurred_at": "2026-01-15T09:30:00Z",
"data": { "offer_id": "7Hb2Kp9QvL3mNx0R8tZ4", "campaign_id": "..." }
}

data contains only curated, client-facing fields — no vendor or storage internals. Headers:

HeaderMeaning
X-AdBridge-EventThe event type wire string (e.g. offer.accepted).
X-AdBridge-DeliveryA unique delivery id (UUID), equal to the envelope id.
X-AdBridge-SignatureLowercase-hex HMAC-SHA256 of the raw request body, keyed by the subscription secret.

Verifying the signature

Recompute the HMAC over the exact raw body and compare it to X-AdBridge-Signature using a constant-time comparison. Reject the delivery if it does not match.

# Given the raw body in body.json and the secret in $WEBHOOK_SECRET:
expected=$(openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" body.json | awk '{print $2}')
# Compare $expected to the X-AdBridge-Signature header value.
echo "$expected"
Sign over the raw bytes

Compute the HMAC over the unparsed request body. Re-serializing the JSON first can change bytes (key order, whitespace) and break verification.

Delivery semantics

  • Best-effort, at-least-once. A delivery is retried a few times on connection errors or 5xx responses. Respond 2xx quickly to acknowledge.
  • Be idempotent. Use X-AdBridge-Delivery to de-duplicate; the same event may arrive more than once.
  • No durable queue today. A process crash mid-delivery may drop an event, so treat webhooks as a fast-path notification and reconcile critical state by reading the API when needed.

Pause deliveries without losing the subscription by setting its status to disabled via PATCH /v1/networks/{networkId}/webhooks/{id}.