Documentation/Integration guide/Tenant webhooks
Integration guide

Tenant webhooks

Configure webhook listeners, verify HMAC-SHA256 signatures, and handle retries gracefully.

6 min read
•Updated October 21, 2026

Tenant Webhook Registration

Create a webhook in Dashboard → Webhooks or POST /v1/webhooks using your project key. Send url, events and enabled. Save the returned secret once; it is used only to verify callbacks.

Supported Webhook Event Types

Supported events: character.ready, character.failed, generation.completed and generation.failed. Registration is project-scoped. Existing jobs are not replayed automatically when a webhook is created.

Callback Payload & Signature Header

The callback JSON contains id, event, created_at and data. Character data includes characterId; generation data includes generationId. Verify X-Webhook-Signature against the original raw body before trusting it.

HMAC-SHA256 Signature Verification

The signature is t=UNIX_SECONDS,v1=HEX_HMAC_SHA256. The signed bytes are timestamp + a dot + raw body. Use constant-time comparison and reject old timestamps. X-Webhook-ID is stable across retries.

At-Least-Once Delivery & Retry Delays

Delivery is at least once, so duplicates are possible. Return 2xx after durably recording the event. Non-2xx responses and network failures retry up to five total attempts, with 10, 20, 40 and 80 second delays. A disabled/deleted endpoint does not receive events.

Delivery Diagnostics & Test Pings

GET /v1/webhooks/{id}/deliveries lists attempts. POST /v1/webhooks/{id}/test sends a signed ping. A ping is not a full generation lifecycle test. Poll resource state when reconciling a missing event. Webhooks are not an exactly-once guarantee.

Worker Scheduler & High Availability

Persisted-event recovery requires the operator’s delivery worker and periodic scheduler to run. A production outage can delay callbacks; inspect delivery history rather than assuming immediate receipt.

Code Implementation

import hashlib
import hmac
import json
import time

def verify_webhook(raw_body: bytes, signature_header: str, secret: str):
    # Pass the X-Webhook-Signature header and the original request bytes.
    try:
        parts = dict(part.split("=", 1) for part in signature_header.split(","))
        timestamp = int(parts["t"])
        signature = parts["v1"]
    except (ValueError, KeyError):
        raise ValueError("Malformed webhook signature") from None
    if abs(int(time.time()) - timestamp) > 300:
        raise ValueError("Expired webhook")
    expected = hmac.new(secret.encode(), str(timestamp).encode() + b"." + raw_body,
                        hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, signature):
        raise ValueError("Invalid signature")
    event = json.loads(raw_body)
    # Persist event["id"] with a UNIQUE constraint before enqueueing your own work.
    # Return HTTP 2xx promptly. Repeated IDs must not repeat your side effects.
    return event