Webhooks
Webhooks notify your backend when jobs finish or account thresholds trigger. Splixir emits job.delivered, job.failed, job.partial, job.rejected, api_key.cap_reached, balance.low, and webhook.test events.
Create a webhook endpoint
Section titled “Create a webhook endpoint”Register one or more https:// webhook endpoints with POST /v1/webhooks using an API key with the webhooks:manage scope. Webhook endpoint URLs must use https://. Set events to specific event names or ["*"], and optionally pass apiKeyId to route events only for jobs created by that API key.
curl -X POST https://api.splixir.com/v1/webhooks \ -H "Authorization: Bearer $SPLIXIR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Production media hook", "url": "https://example.com/hooks/splixir", "events": ["job.delivered", "job.partial", "job.failed", "balance.low"], "apiKeyId": "key_optional_filter" }'Splixir returns 201 Created with the endpoint object (whe_...) and a one-time signingSecret (whsec_...). Store it in your secrets manager right away.
Use PATCH /v1/webhooks/:id to toggle enabled or update events, url, or apiKeyId, and DELETE /v1/webhooks/:id to remove an endpoint. To send a live test ping (webhook.test) and inspect HTTP status and latency, call POST /v1/webhooks/:id/test.
To override delivery for a single job without editing endpoints, pass callbackUrl on POST /v1/jobs.
Rotate secrets with a 24-hour grace period
Section titled “Rotate secrets with a 24-hour grace period”Call POST /v1/webhooks/:id/rotate-secret to generate a new whsec_... secret. Splixir keeps your previous signing secret active for 24 hours (previousSecretExpiresAt) and sends both signatures during the grace window so you can roll keys with zero dropped events.
Verify webhook signatures
Section titled “Verify webhook signatures”Every webhook request sends Standard Webhooks headers alongside X-Splixir-* headers:
webhook-id: Delivery ID (whd_...)webhook-timestamp: Unix timestamp in secondswebhook-signature:v1,<base64>(contains comma-separated signatures during 24-hour rotation)X-Splixir-Signature:t=<unix_seconds>,v1=<hmac_sha256_hex>X-Splixir-Event: Event name (such asjob.deliveredorbalance.low)X-Splixir-Delivery: Delivery ID (whd_...)User-Agent:Splixir-Webhooks/2.0
Compute HMAC-SHA256 using your whsec_... secret over ${timestamp}.${rawBody} for X-Splixir-Signature (or ${webhookId}.${timestamp}.${rawBody} for webhook-signature) and compare in constant time:
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifySplixirWebhook( rawBody: string, signatureHeader: string, secret: string, toleranceSeconds = 300,): boolean { const tokens = signatureHeader.split(","); const timestamp = tokens.find((p) => p.startsWith("t="))?.slice(2); const signatures = tokens.filter((p) => p.startsWith("v1=")).map((p) => p.slice(3)); if (!timestamp || signatures.length === 0) return false;
const age = Math.abs(Math.floor(Date.now() / 1000) - Number(timestamp)); if (!Number.isFinite(age) || age > toleranceSeconds) return false;
const expectedHex = createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex"); const expectedBuf = Buffer.from(expectedHex, "hex");
return signatures.some((sig) => { const actualBuf = Buffer.from(sig, "hex"); return expectedBuf.length === actualBuf.length && timingSafeEqual(expectedBuf, actualBuf); });}import hashlibimport hmacimport time
def verify_splixir_webhook( raw_body: str, signature_header: str, secret: str, tolerance_seconds: int = 300,) -> bool: tokens = signature_header.split(",") timestamp = next((p[2:] for p in tokens if p.startswith("t=")), None) signatures = [p[3:] for p in tokens if p.startswith("v1=")] if not timestamp or not signatures: return False
if abs(int(time.time()) - int(timestamp)) > tolerance_seconds: return False
expected = hmac.new( secret.encode("utf-8"), f"{timestamp}.{raw_body}".encode("utf-8"), hashlib.sha256, ).hexdigest()
return any(hmac.compare_digest(expected, sig) for sig in signatures)Automatic retries and dead letters
Section titled “Automatic retries and dead letters”Splixir waits up to 8 seconds per delivery attempt and retries up to 6 attempts over roughly 7 hours:
initial attempt -> +30s -> +2m -> +10m -> +1h -> +6h
Each attempt records HTTP status, latency in milliseconds, and a response body snippet (up to 512 characters). If all 6 attempts fail or SSRF protection blocks the target URL, Splixir marks the delivery dead_lettered.
Replay failed deliveries
Section titled “Replay failed deliveries”Inspect delivery history with GET /v1/webhooks/deliveries (filterable by endpointId, status, event, and limit), and replay any delivery ID (whd_...) with POST /v1/webhooks/deliveries/:id/replay:
curl -X POST https://api.splixir.com/v1/webhooks/deliveries/whd_.../replay \ -H "Authorization: Bearer $SPLIXIR_API_KEY"Replays allow up to 5 replays per delivery and 20 replays per hour, within your tier’s replay retention window:
| Tier | Replay window |
|---|---|
| Free | Not available (0 days) |
| PAYG Starter | 7 days |
| PAYG 10x | 14 days |
| PAYG 20x, 30x, Basic | 30 days |
| Pro | 60 days |
| Scale | 90 days |
| Studio | 180 days |
Deliveries older than your tier’s window return 403 replay_window_expired. See Errors for full replay error codes.