For AI agents: every API docs page in one plain-text file is at /docs/llms-full.txt, and the documentation index is at /llms.txt. This page is available as Markdown at https://diffio.ai/docs/developers/webhooks.md, and every docs URL returns Markdown when requested with Accept: text/markdown.

Webhooks: events, signatures and retries
Webhooks notify your server with signed HTTP POST events whenever a project, generation, separated-track stem, export or transcript assistant turn finishes or fails, so your application does not need to poll.
How webhooks work
- Diffio: State transition. A generation, project, stem, export or turn completes or fails
- Signed POST: JSON event.
svix-id,svix-timestamp,svix-signatureheaders - Your endpoint: Verify, then answer
200OK.. Answer fast; any non-2xx response is retried with backoff - Background job: Fetch media or details. Call generation media or get generation, then update records
Account scope and portal model
Webhooks belong to your whole Diffio account rather than a single API key. Once enabled, events fire across all API keys and all end users on the account; every event payload carries data.end_user (null when created without Diffio-End-User).
Development and production use separate webhook portals and applications. Disable CSRF middleware on your webhook route so incoming signed POST requests reach your signature check untouched.
Add an endpoint
- 1
Open the webhook portal
Call POST /webhooks/portal with an API key that has Write permission (a read-only key gets
403Forbidden: the key lacks permission.). The first call creates your account's webhook application and turns event delivery on. Open the returnedurlright away: portal links are short-lived, so request a fresh link each time you visit.Do not send the
Diffio-End-Userheader onPOST /webhooks/portal; the endpoint is account-wide and refuses that header with403Forbidden: the key lacks permission. (permission_denied). Both SDKs leave it off this call, even on a client created for an end user.from diffio import DiffioClient client = DiffioClient() # reads DIFFIO_API_KEY portal = client.webhooks.portal() print(portal.url, portal.event_types)
Select Add Endpoint in the webhook portal. Full-size screenshot No server yetIf you do not have an HTTPS receiver deployed yet, use the portal to create a temporary test receiver URL so you can inspect real deliveries while building your handler.
- 2
Add your endpoint URL and events
Paste your HTTPS endpoint URL and tick the events you handle. Leaving every box clear subscribes the endpoint to all of them.
- Generations
generation.completedgeneration.failedgeneration.stems_readygeneration.stems_failed - Projects
project.readyproject.failed - Exports
export.readyexport.failed - Assistant turns
transcript_assistant_turn.completedtranscript_assistant_turn.failed
About the portal's event list
- It also lists
generation.queuedandgeneration.processing, kept for an older API. This API never sends them; follow progress with Get a generation. - Its sample payloads for
generation.completedandgeneration.failedshow that older schema. Real deliveries use the{ type, id, created_at, data }envelope under Events and payloads.
- Generations
- 3
Save the signing secret
Open the new endpoint's details page, reveal its
whsec_...signing secret and store it asDIFFIO_WEBHOOK_SECRETin your secret manager. Each endpoint has its own unique secret.
Copy the Signing Secret from the endpoint details. Full-size screenshot
Test endpoints
- Trigger: Run a short restore. Upload a short clip and restore it; there is no test-event API endpoint
- Inspect: Portal message log. View each delivery's payload and your endpoint's response in the portal
- Confirm: Signature +
200OK.. Your receiver verifiessvix-signatureand returns a2xxstatus
Events and payloads
Every delivery is { type, id, created_at, data }. id is "evt_" plus 32 hex characters, the same on every retry, so dedupe on it. Only finished or failed states send events, never progress.
Every data has id, project_id, end_user and status. The table lists what each event adds.
Event type | data.object | status | Also in data |
|---|---|---|---|
generation.completed | object generation | status "complete" | also kind ("restore" or "edit") |
generation.failed | object generation | status "failed" | also kind, error_code |
generation.stems_ready | object generation | status the generation's | also kind, stems_status: "ready" |
generation.stems_failed | object generation | status the generation's | also kind, stems_status: "failed" |
export.ready | object generation_export | status "ready" | also generation_id; id ends -inline for inline exports |
export.failed | object generation_export | status "failed" | also generation_id |
transcript_assistant_turn.completed | object transcript_assistant_turn | status "complete" | also generation_id |
transcript_assistant_turn.failed | object transcript_assistant_turn | status "failed" | also generation_id |
project.ready | object project | status "ready" | also none (project_id equals id) |
project.failed | object project | status "failed" | also none (project_id equals id) |
{
"type": "generation.completed",
"id": "evt_4b8c1d0e9f2a3b4c5d6e7f8091a2b3c4",
"created_at": "2026-11-13T00:33:41Z",
"data": {
"object": "generation",
"id": "ce832a32-a1ce-516a-b8bd-75457bd8517f",
"project_id": "62f62565-049f-5e7e-bbd2-9de0cf7ddbfe",
"end_user": "customer-42",
"status": "complete",
"kind": "restore"
}
}Reading generation and failure details
- Generation id location: on all four
generation.*events, the generation id isdata.id(there is nogeneration_idfield on generation payloads). Onexport.*andtranscript_assistant_turn.*events,data.idis the export or turn id anddata.generation_idnames the generation. - Fetching media and errors: webhook payloads intentionally stay compact and never embed media URLs or human-readable error messages. On
generation.completed, call GET /projects/{project_id}/generations/{generation_id}/media (or GET .../transcript). Ongeneration.failed,data.error_codegives the machine-readable code; call GET /projects/{project_id}/generations/{generation_id} to inspect the fullerrorobject andwarnings.
Verify signatures
Every webhook delivery is signed with Svix headers so you can verify authenticity and reject replay attacks. Always verify against the exact raw request body bytes (or string) before parsing JSON.
Required delivery headerssvix-idsvix-timestampsvix-signature
Verify with the Diffio SDK
Both SDKs verify signatures locally with zero external dependencies (default timestamp tolerance: 300 seconds) and return the parsed { type, id, created_at, data } event. In WebCrypto runtimes (Cloudflare Workers, Deno, Bun or browsers), call client.webhooks.verifySignatureAsync (or standalone verifyWebhookSignatureAsync). Python also exports standalone diffio.verify_webhook_signature.
import os
from diffio import DiffioClient, WebhookVerificationError
client = DiffioClient()
secret = os.environ["DIFFIO_WEBHOOK_SECRET"] # the endpoint's whsec_... signing secret from the webhook portal
def handle_webhook(raw_body, headers):
"""raw_body: the request body bytes as received; headers: the request headers (any mapping)."""
try:
event = client.webhooks.verify_signature(raw_body, headers, secret)
except WebhookVerificationError:
return 400
if event.type == "generation.completed":
print("restored", event.data.project_id, event.data.id, event.data.end_user)
elif event.type == "generation.failed":
print("failed", event.data.id, event.data.error_code)
return 200Drop-in handlers
Each framework hides the raw body differently, and a parsed body never verifies. These read it the way the signature needs.
import { DiffioWebhookVerificationError, verifyWebhookSignatureAsync } from "diffio";
export async function POST(request: Request) {
const rawBody = await request.text(); // read once, never request.json()
try {
const event = await verifyWebhookSignatureAsync(rawBody, request.headers, process.env.DIFFIO_WEBHOOK_SECRET!);
// Record event.id and queue the work, then answer quickly.
console.log(event.type, event.id, event.data.id);
return new Response(null, { status: 204 });
} catch (error) {
if (error instanceof DiffioWebhookVerificationError) return new Response(null, { status: 400 });
throw error;
}
}Verify by hand
If you do not use a Diffio SDK (or an official Svix library), verify the HMAC-SHA256 signature directly:
- Read
svix-id,svix-timestamp(Unix seconds) andsvix-signaturefrom the headers, plus the raw body bytes. - Reject the delivery if
svix-timestampis not an integer or differs from the current Unix time by more than300seconds. - Strip the
whsec_prefix from your endpoint's signing secret and base64-decode the remaining string into raw key bytes. - Compute HMAC-SHA256 over
{svix-id}.{svix-timestamp}.{raw_body}using those key bytes, then base64-encode the digest. - Split
svix-signatureon spaces; each entry has the form<version>,<digest>. Compare your digest in constant time against everyv1,entry and accept if any matches.
import base64
import hashlib
import hmac
import json
import time
def verify_svix_webhook(raw_body: bytes, headers: dict, secret: str, tolerance_seconds: int = 300) -> dict:
lower = {k.lower(): v for k, v in headers.items()}
msg_id = lower.get("svix-id") or ""
msg_timestamp = lower.get("svix-timestamp") or ""
msg_signature = lower.get("svix-signature") or ""
if not msg_id or not msg_timestamp or not msg_signature:
raise ValueError("Missing Svix signature headers")
ts = int(msg_timestamp)
if abs(time.time() - ts) > tolerance_seconds:
raise ValueError("Webhook timestamp outside tolerance")
key = base64.b64decode(secret[len("whsec_"):] if secret.startswith("whsec_") else secret)
signed_content = f"{msg_id}.{msg_timestamp}.".encode("utf-8") + raw_body
expected = base64.b64encode(hmac.new(key, signed_content, hashlib.sha256).digest()).decode("ascii")
for entry in msg_signature.split():
version, _, digest = entry.partition(",")
if version == "v1" and hmac.compare_digest(expected, digest):
return json.loads(raw_body.decode("utf-8"))
raise ValueError("Webhook signature does not match")Retries and recovery
Return any 2xx HTTP status code (such as 200OK. or 204No content.) as soon as signature verification succeeds, and hand downloads or database updates off to a background worker. Any non-2xx response or connection failure is retried automatically by Svix with backoff.
- Deduplicate: Record
event.id(evt_...) before running side effects. The eventidis derived from the event type, resource and transition, so it stays identical across every automatic retry and manual redelivery. - Signature fails: Verify the raw body with the endpoint's own secret. Never pass
JSON.stringify(req.body): re-serialized JSON changes bytes and breaks the HMAC (see drop-in handlers). Each endpoint has its ownwhsec_...secret, and timestamps more than 300 seconds from your clock are rejected. - Missed events: Inspect and resend deliveries in the webhook portal. Open a fresh portal link via
POST /webhooks/portalto review attempt responses and trigger manual redeliveries.