Skip to main content
This page describes what HeyGen sends to your server for each webhook event, what your server should answer, and what happens when it does not. The same rules apply to registered endpoints and to a per-request callback_url.

Where an event is sent

When a job reaches a state that has an event, such as a video finishing, HeyGen sends the event to every target it has:
  • each enabled endpoint in your workspace that subscribes to that event_type (an endpoint with events: null subscribes to all of them);
  • the callback_url that the request which created the job set, if it set one.
Each target gets its own delivery, sent in parallel and retried on its own. A delivery is one or more HTTP attempts. Only endpoints whose status is enabled receive events.

The request

Each attempt is a POST to the target URL. The body is a compact JSON object with two fields:
event_data depends on the event type; see Webhook Events. The event ID is in the headers only, not in the body. The same ID is the event_id in GET /v3/webhooks/events and GET /v3/webhooks/deliveries, so you can look up any request your server received.
Deliveries to a callback_url are not signed: there is no signature header. Put a long random token in the callback URL’s path, check the callback_id you set, and treat the body as a hint: fetch the job from the API before you act on it. To receive signed events, register an endpoint.

What your server should answer

Answer with any 2xx status within 5 seconds. Do the real work after you answer: store the event, put it on a queue, answer 200, and process it from the queue. A handler that renders, transcodes, or calls other services before it answers will time out, and the attempt is retried. How each answer is treated: Answer 4xx only when the request itself is wrong, such as a bad signature. If your server is overloaded or a dependency is down, answer 503 or 429 so the attempt is retried.

Retry timing

  • A delivery makes at most 5 attempts.
  • The wait between attempts is about 2, 4, 8 and 8 seconds, each varied by up to 25%.
  • A Retry-After header in seconds on a retried answer, such as a 429 or 503, sets the shortest wait before the next attempt. A Retry-After longer than the time left ends the delivery as failed. A Retry-After given as a date is ignored.
  • All of an event’s deliveries share one 35-second limit, counted from the first attempt. When the next attempt cannot start within it, the delivery ends as failed.
There is no later retry schedule. If your server is unreachable for longer than about 35 seconds, the events in that window are not delivered. Find them in GET /v3/webhooks/events and send them again, or fetch the jobs’ state from the API.

URL requirements

A target URL must:
  • use https, on port 443, 8443, 8080, 8000 or 80;
  • have a host name that resolves only to public IPv4 addresses. A receiver reachable only over IPv6 is not reached;
  • carry no user name or password (https://user:pass@...);
  • answer directly, without a redirect.
A URL that breaks one of these rules fails with error_class non_public or redirect_refused, which are not retried.

Deduplicate and order

Delivery is at least once. Your server can receive the same event more than once when:
  • your server processed an attempt but its answer was lost or late, so the attempt was retried;
  • the event was sent again;
  • the event has two targets that reach the same system, such as an endpoint and a callback_url.
Record each x-heygen-event-id you have processed, and skip one you have already seen. Keep the IDs for at least 30 days, the period in which an event can be sent again.
Events are not guaranteed to arrive in the order they happened: a retried event can arrive after a later one. When order matters, fetch the job’s current state from the API instead of applying events in the order they arrive.

Media URLs in events

Download URLs in event_data, such as url on avatar_video.success, are pre-signed and expire. Download the file soon after the event arrives, or fetch a fresh URL from the job’s get endpoint; see Webhook Events. GET /v3/webhooks/events and Send again sign these URLs again, so they return working links.

Next steps

Monitor deliveries

See each attempt’s status code, error and latency, and find events that never arrived.

Send events again

Resend an event from the last 30 days to an endpoint or callback URL.