Webhooks

Instead of polling, set one webhook URL per API Key on the API Keys page (HTTPS, public addresses only). When a Generation started with that key finishes, we POST a generation-finished event to it; its body is in the reference. The secret starting with whsec_ is shown once.

HeaderValue
webhook-idThe delivery id, equal to the body's id and the same on every retry: use it to drop duplicates.
webhook-timestampUnix seconds of this attempt.
webhook-signaturev1, followed by the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{body}, keyed with the base64-decoded part of the secret after whsec_.

Verify every request on its raw body bytes before trusting it, for example in Python:

import base64
import hashlib
import hmac
import time


def verify(secret: str, headers: dict[str, str], body: bytes) -> bool:
    """Return True when a webhook request is ours and recent (Standard Webhooks)."""
    key = base64.b64decode(secret.removeprefix("whsec_"))
    webhook_id = headers["webhook-id"]
    timestamp = headers["webhook-timestamp"]
    if abs(time.time() - int(timestamp)) > 300:
        return False
    signed = f"{webhook_id}.{timestamp}.".encode() + body
    expected = (
        "v1,"
        + base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
    )
    return any(
        hmac.compare_digest(expected, signature)
        for signature in headers["webhook-signature"].split()
    )

Answer with a 2xx within 10 seconds. Anything else, including a redirect, is retried after 5 s, 30 s, 2 min, 10 min, 30 min, then hourly for 24 hours. The body carries no media URL: download a Video through the API.

Reference

Every endpoint with its parameters, request and response examples and error codes, rendered from the live OpenAPI document. The reference is in English. Download openapi.json