API Jobs: Queue, Poll, Cancel and Retry Safely

Queue FoxCue script, article, slide and video jobs with POST /jobs and an Idempotency-Key, poll GET /jobs/{id} for status, and cancel. No webhooks yet.

Long-running work in the FoxCue API runs as jobs. You POST /jobs with an operation, an input and an Idempotency-Key, get back 202 with a job ID, then poll GET /jobs/{id} until it's done. Completion webhooks aren't available, so poll instead.

Operations

OperationWhat it doesNeeds
script.generateWrite a standard scriptscript_id, expected_updated_at, a meaningful topic and source or brief context
script.generate_longWrite a long-form scriptSame as above
article.generateWrite an article from a scriptscript_id and a body snapshot
slides.generateBuild slides from a scriptscript_id and a body snapshot
video.renderRender existing slides into a narrated videoAn existing deck and voice settings

Script jobs accept an optional cost_limit_usd to lower the default $0.05 estimate ceiling. It can't raise it. See Script costs. Script jobs also accept writing_skill. Leave it out to keep the script's saved choice, or send null for the standard method.

Create a draft script first (POST /scripts), then queue generation.

Queue a job

curl "https://app.foxcue.com/api/v1/jobs" \
  -H "Authorization: Bearer <workspace API key>" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: article-request-001" \
  -d '{"operation":"article.generate","input":{"script_id":"<id>","body":"<script>"}}'

The response is 202 with a job ID and a Location header.

Poll for status

GET /jobs/{id} returns the status, progress, result and any error_code:

StatusMeaning
queuedWaiting for a worker
runningIn progress
doneFinished. The result is in the response.
errorFailed, with a redacted error_code
cancelledCancelled

Idempotency

  • Send an Idempotency-Key of 8–128 characters with every POST /jobs.
  • Repeating the same request with the same key returns the same job. It doesn't start (or pay for) a second one.
  • Reusing a key with a different request returns 409.
  • After a network timeout, retry the exact original request with the same key.
  • Ordinary create, update and delete calls don't have idempotency keys, so don't blindly retry a create after an uncertain response.

Cancel

POST /jobs/{id}/cancel (scope jobs:write) cancels queued work or asks running work to stop. A provider call that's already been sent may still complete and be charged.

Reliability

  • Queued jobs survive server restarts.
  • If a running job is interrupted, it fails as worker_interrupted. AI and video work is never replayed automatically. Send a new request to retry.
  • Each workspace can have at most 3 queued or running API jobs at once.

On this page