# Jobs and uploads

## POST /v1/jobs

Queues work and answers **`202 Accepted`** at once; the work runs in the background.
See "Async jobs" for the life cycle. Test keys get a finished sample job ("Test mode").
Idempotent with `Idempotency-Key` (a retry returns the same job).

The maximum estimate, computed from the **measured** length of what you send, is reserved
when the job is created; on success you pay the measured amount and the rest is released.
Failed, canceled and timed-out jobs are refunded in full.

| `type` | Input | Output (`result`) | Price |
|---|---|---|---|
| `sign_video` | The [shared sign request fields](#shared-sign-request-fields) (as for studio), or multipart `audio` (≤ 10 min, ≤ 25 MB) instead of `text` | `download_url`, `expires_at`, `video_url`, `durationSeconds`, … (+ `input`, `transcript` for audio) | $1.32 / min of rendered video |
| `captions` | Multipart `video` (MP4/MOV/WebM, ≤ 500 MB, ≤ 10 min) or `video_upload_id`; optional `captions` (array of `{ start, end, text }` in seconds, ≤ 300 lines), omitted = automatic transcript; `language`, `burn_in` (default `true`), `resolution` (`720p`/`1080p`) | `video_url` / `download_url` (MP4 with burned-in captions), `srt_url`, `vtt_url`, `expires_at`, `durationSeconds`, `lines`, `transcript` (auto) | $0.99 / min of source video |
| `sign_morph` | Multipart `video` (≤ 200 MB, ≤ 30 s) or `video_upload_id`, plus `photo` (JPG/PNG/WEBP, ≤ 10 MB) or a preset `avatar` (`arthur`, `amara`, `daniel`, `elena`); `quality` `480p` or `720p` (default); **`consent: true` required** | `video_url` / `download_url`, `expires_at`, `durationSeconds`, `billedSeconds`, `quality` | $0.055 / s at 480p, $0.11 / s at 720p of output, 10 s minimum |

`consent: true` confirms you have the rights to the photo and video and the consent of every
person in them (`400 consent_required` otherwise). Files are checked from their content, not
their names (`400 invalid_file`).

```bash
curl https://api-staging.talksign.co/v1/jobs \
  -H "Authorization: Bearer $TALKSIGN_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1234-video" \
  -d '{ "type": "sign_video", "text": "Welcome to our store", "avatar": "amara" }'
```

```json
{ "id": "job_8c1d2e3f4a5b6c7d8e9f0a1b", "object": "job", "type": "sign_video",
  "status": "queued", "created_at": "2026-11-22T12:00:00.000Z" }
```

```bash
curl https://api-staging.talksign.co/v1/jobs \
  -H "Authorization: Bearer $TALKSIGN_KEY" \
  -F type=captions -F video=@talk.mp4

curl https://api-staging.talksign.co/v1/jobs \
  -H "Authorization: Bearer $TALKSIGN_KEY" \
  -F type=sign_morph -F quality=480p -F consent=true \
  -F video=@signing.mp4 -F photo=@person.jpg
```

Shortcut: `POST /v1/speech-to-sign/studio?async=true` with the studio body does the same as
`type: sign_video` and returns the same `202` job.

Errors: `400 missing_parameter` / `invalid_parameter` / `invalid_file` / `consent_required`
(with `param`), `402 insufficient_credits`, `403`, `404 upload_not_found`,
`409 idempotency_in_progress`, `413 text_too_long` / `file_too_large` / `audio_too_long` /
`video_too_long`, `422 idempotency_key_reused`, `429`.

## POST /v1/uploads

A signed upload link for a large source video (up to 500 MB), so you don't have to send it
through the API. Free. Body: `{ "content_type": "video/mp4", "size_bytes": 104857600 }`
(`video/mp4`, `video/quicktime` or `video/webm`).

```json
{ "id": "upl_0a1b2c3d4e5f60718293a4b5", "object": "upload", "upload_url": "https://…", "method": "PUT",
  "headers": { "Content-Type": "video/mp4", "x-goog-content-length-range": "0,104857600" },
  "expires_at": "2026-11-22T12:30:00.000Z" }
```

`PUT` the file to `upload_url` with exactly those headers within 30 minutes, then create the
job with `"video_upload_id": "upl_…"` (JSON or form field) instead of a `video` file.

## GET /v1/jobs

Your account's jobs, newest first. Free.
Query: `limit` (1–100, default 20), `starting_after` (a job id from the previous page).
Response: `{ "object": "list", "data": [Job, …], "has_more": true|false }`.
To get the next page, pass the last job's `id` as `starting_after`.

## GET /v1/jobs/{id}

One job. Free. Jobs belong to the account of the key that created them; any key of the
same account can read them, other accounts get `404 job_not_found`.

| Field | Type | Notes |
|---|---|---|
| `id` | string | `job_…` |
| `object` | string | `job` |
| `type` | string | `sign_video`, `captions` or `sign_morph` |
| `status` | string | `queued`, `processing`, `succeeded`, `failed` or `canceled`. |
| `created_at`, `started_at`, `finished_at` | string \| null | ISO 8601. |
| `result` | object \| null | When `succeeded`: per type (see the table under `POST /v1/jobs`). |
| `error` | object \| null | When `failed`: `{ code, message }`, for example `avatar_not_found` or `job_timeout`. |
| `usage` | object \| null | When `succeeded`: `{ type, durationSeconds, costUsd }`. |

`download_url` is valid for 1 hour from when the job finished. After that, download with your
key from `result.video_url` (videos are kept for 7 days).

## POST /v1/jobs/{id}/cancel

Cancels a `queued` or `processing` job and refunds its reservation in full. Returns the job
(`status: canceled`). A job that already finished answers `409 job_not_cancelable`.
Free.
