A better way to handle long-running video tasks
Design a clear submit, poll, and download flow without keeping the browser waiting on one request.
Poll with the same API key. Querying status never creates another generation.
Retrieve a task
Replace TASK_ID with a returned UUID. Poll every five seconds or more. Use a bounded polling window, then save the ID and resume later for a long video.
Task states
Use status rather than assuming a fixed generation time.
| Status | Meaning | What your application should do |
|---|---|---|
| queued | Recorded, waiting for processing | Continue polling |
| submitting | Submission in progress | Continue polling; do not resubmit |
| running | Task accepted and being tracked | Continue polling |
| succeeded | Output URLs available | Read outputs and save files |
| failed | Task failed or cancelled before submission | Inspect usage/refund and error_code |
| needs_review | Outcome uncertain; reconciliation required | Stop automatic resubmission; keep task ID |
Successful response
outputs is an array of HTTPS strings. There is no promised percentage progress, fixed completion time, or file-expiry timestamp in this response.
List and paginate
GET /v1/tasks?limit=20 returns data and next_cursor. limit ranges from 1 to 100. Pass next_cursor as before on the next call. Only the current key’s tasks are listed.
Cancel before submission
POST /v1/tasks/{id}/cancel with JSON {}. This only cancels a task that has not been submitted. HTTP 409 means cancellation is no longer available. Cancellation returns status failed with error_code cancelled_before_submit; it does not stop a running upstream generation.
Keep the same task identifier across these steps so the interface, logs, and billing records describe the same operation.