Skip to main content
Webhooks deliver generation results to your server in real-time. Instead of polling GET /api/generations/:id repeatedly, you receive a single POST request when the generation is done.

Polling vs. webhooks

How to use webhooks

Add a webhook URL to your /api/run request:
Webhook URLs must use HTTPS. Private or internal URLs (localhost, private IPs) are rejected for security.

Webhook payload

When a generation completes successfully, we send a POST request to your URL with these headers and body:

Headers

Body

Example handlers

Retries

If your endpoint does not return a 200 status, we retry with exponential backoff: After 9 failed retries, the webhook is marked as failed.

Best practices

Return a 200 quickly. Your endpoint should respond within 5 seconds. Process the webhook data asynchronously if needed.
  • Handle duplicates — Retries may deliver the same webhook twice. Use the id field to deduplicate.
  • Validate the payload — Check that the data matches expected formats before processing.
  • Log everything — Keep logs of received webhooks for debugging.

Requirements

Your webhook endpoint must:
  • Be publicly accessible (no localhost or private IPs)
  • Use HTTPS
  • Accept POST requests with a JSON body
  • Return 200 to acknowledge receipt