Workspace / Explore
← All guides
ENGINEERING · 6 min read

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.

A better way to handle long-running video tasks diagram

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.

StatusMeaningWhat your application should do
queuedRecorded, waiting for processingContinue polling
submittingSubmission in progressContinue polling; do not resubmit
runningTask accepted and being trackedContinue polling
succeededOutput URLs availableRead outputs and save files
failedTask failed or cancelled before submissionInspect usage/refund and error_code
needs_reviewOutcome uncertain; reconciliation requiredStop 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.

Input→Task→Result + cost

Keep the same task identifier across these steps so the interface, logs, and billing records describe the same operation.