Long-running jobs
Start work that takes minutes, track it, and collect the result.
Dubbing a video, translating a batch of documents or analyzing an image takes longer than an HTTP request should stay open. These endpoints start a job and return its ID straight away. You then poll the job until it finishes.
The pattern
Start the job
The response comes back immediately with a job ID and its first status. Credits are checked at this point; if there aren't enough, you get a 402 and nothing starts.
/v1/galaxy/translate-video/process-log/run{
"jobId": "9b1f6c2e-3d4a-4e5f-8a7b-1c2d3e4f5a6b",
"status": "SCHEDULED",
"processType": "VIDEO_TO_SPEECH_TRANSLATION"
}Poll until it finishes
GET/v1/galaxy/translate-video/process-log/run/{id}{
"jobId": "9b1f6c2e-3d4a-4e5f-8a7b-1c2d3e4f5a6b",
"status": "RUNNING",
"stage": "TRANSCREATION-ENGINE",
"progress": 55,
"result": null,
"error": null
}Read the result
When status is COMPLETED, read the output in result and the cost in credits. For FAILED, read error for details.
Job statuses
Video Dubbing jobs use these statuses:
| Status | Meaning |
|---|---|
DRAFT | Saved and waiting to be submitted. |
SCHEDULED | Accepted and waiting to start. |
RUNNING | In progress. Read stage and progress. |
PAUSED | Waiting for a review or approval. |
COMPLETED | Finished. Collect the result. |
COMPLETED_WITH_ERRORS | Finished with some items in error. |
FAILED | Stopped with an error. Read error for details. |
TIMED_OUT | Stopped after reaching the time limit. |
TERMINATED | Stopped before completion. |
Polling well
async function waitForJob(jobId: string) {
const url = `{{API_BASE_URL}}/v1/galaxy/translate-video/process-log/run/${jobId}`;
let delay = 5_000;
for (;;) {
const res = await fetch(url, { headers: { 'x-api-key': process.env.ACCLARO_API_KEY! } });
if (res.status === 429) {
await sleep(Number(res.headers.get('retry-after') ?? 60) * 1000);
continue;
}
if (!res.ok) throw new Error(`Job request failed: ${res.status}`);
const job = await res.json();
if (['COMPLETED', 'COMPLETED_WITH_ERRORS', 'FAILED', 'TIMED_OUT', 'TERMINATED'].includes(job.status)) return job;
await sleep(delay);
delay = Math.min(delay * 1.5, 30_000);
}
}
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));- Start at about 5 seconds between polls and slow down to around 30 seconds for long jobs.
- Respect
429andRetry-After. Polls count toward the key's rate limit. - Store the job ID as soon as you get it, so a restart of your system can pick the job up again.
Each product's job endpoints
Every product that runs jobs follows this shape, but the paths and status fields are its own:
| Product | Start | Poll |
|---|---|---|
| Video Dubbing | Start a job | Get a job |
| Voice & Lip-sync | Start a lip-sync, Clone a voice, Generate speech | Get a lip-sync job, Get a cloned voice, Get a session |
| Image Translation | Translate an image, Analyze an image | Get a translation, Get the analysis |
| Document Translation | Translate a document | Get a translation, Get a text result |
| Translation Memory | Import a file, Import terms | Get an import |
| Quality Control | Check video, Check text and the other checks | Get a check |
| Hyperlocal | Create a broadcast | Get a broadcast |
| Blog | Write a post, Translate a post, Start an Autopilot run | Get a post, Get a translation, Get an Autopilot run |
| Workflows | Start a run | Get a run |
Webhooks
Only the Blog API sends webhooks so far: register one to be told when a post, a translation, a recording or an Autopilot run finishes. The other products don't send webhooks yet, and the app's live-progress websockets don't accept API keys, so polling is the supported way to track their jobs.