What this lets you do
Finish a Video integration after accepting a quote: track the execution, recover interrupted connections, download the result, and handle cancellation or failure.What you need
- The
execution_idreturned by quote acceptance, saved asVIDEO_EXECUTION_ID - The API key for the owning account
- The saved acceptance body and original idempotency key for uncertain submissions
Steps
1. Read canonical state
image_job is null for Video. Use video_job and the top-level status.
States can be skipped between reads. A response with HTTP
200 means the read succeeded, not that generation succeeded. Recovery may later deliver unresolved work; a restored hold alone is not proof that all processing has stopped.
2. Follow or resume events
progress, asset, and done events. progress carries {"text":"generating"}-style display updates and a persisted event ID. asset contains the execution’s asset ID and owned download_url. done ends that stream. Do not expect an initial started event; obtain the execution ID from the acceptance response.
Save the last fully processed event ID and reconnect with Last-Event-ID. Only send it when you have a cursor. Terminal events can be repeated on reconnect and need not carry an ID; deduplicate handling using the execution ID and read canonical status. Streams can close before completion, so a disconnect is not a cancellation or failure. Use status reads for expired and billing details rather than inferring them from done.
Limit polling and reconnects, and close unused streams. Video permits three open streams per API key. A five-second polling interval is a reasonable starting point, not a completion guarantee. See shared request limits.
3. Download the MP4
Once state iscompleted, the owned path is /v1/video/executions/{execution_id}/asset:
--location-trusted. Other HTTP clients should request the API URL without following redirects, then fetch its HTTPS Location without API credentials. Never forward a bearer key to the storage destination or log signed URLs.
The API issues a signed link valid for 15 minutes. Output is retained for 30 days after completion; retention_expires_at is authoritative. If the signed link expires, request a new one from the same owned endpoint. Save your MP4 before retention ends. An expired link is not a reason to regenerate.
4. Cancel only eligible work
Cancellation is an optional action and succeeds only while the Video execution isqueued:
202 with status: cancelled and restores the hold. A job may start between your status read and cancellation; then the API returns 409 conflict. Read state instead of repeatedly cancelling. Closing a browser, terminal, or stream never cancels a video. Sprite-sheet cancellation rules are different.
Confirm it worked
For delivery, checkcompleted, download and play the MP4, and inspect settled_credits. For cancellation, check cancelled and credits_restored. Record the execution ID for support without putting credentials, prompts, full response bodies, or signed URLs into public logs.
Common errors
Video business errors carryerror.code, error.reason, message, and retryable. Framework validation and authentication errors can use the shared error envelope; do not require every Video error to contain category or request_id. Save X-Request-ID when present.
Troubleshooting
Persist the quote, acceptance body, idempotency key, execution ID, and event cursor securely. If acceptance returns no response, resend the samequote_id and max_credits with the same API key and idempotency key. An accepted quote is single-use and returns its existing execution, including after quote expiry. An unaccepted expired quote cannot start work.
For a long-running uncertain execution, inspect credits_restored and billing_note and contact support with its ID. Restored credits and later delivery do not trigger a second charge. Creating a new quote and accepting it can create a second video and charge; do that only deliberately.