# Jobs

Poll background work and collect every page of results.

`GET https://www.ninjabuy.com/api/v1/jobs/{id}` requires the [same account's bearer token](/docs/partners-api/authentication.mdx). Missing, unknown and other accounts' jobs return `404`.

## Lifecycle

| `job.status` | Meaning                                          |
| ------------ | ------------------------------------------------ |
| `queued`     | Waiting to start.                                |
| `running`    | Work is in progress; more results may arrive.    |
| `done`       | Processing finished. Check each result's status. |
| `failed`     | The job failed. Read `job.error` when present.   |

`job` includes `id`, `kind`, `status` and `startedAt`, plus optional `progress` (`done`, `total`), `finishedAt`, `result` and `error`. Timestamps are milliseconds since the Unix epoch. While queued or running, `poll_after_seconds` and the `Retry-After` header tell you how long to wait; the initial suggestion is 5 seconds.

Link batches have `kind: "link_mints"`. Their final `result` reports `total`, `converted`, `failed` and optional `campaign` and `label`. Here `failed` counts inputs answered without conversion; it does not mean the whole job's status is `failed`. [Sheet conversions](/docs/partners-api/sheets.mdx) have `kind: "sheet_conversion"`; their final `job.result` contains counts and a signed XLSX download URL. [Batch jobs](/docs/partners-api/batch-jobs.mdx) have `kind: "batch_job"`; their `result` reports `endpoint`, `success_count`, `failure_count` and, once finished, a `download_url` for the JSONL results. The job schema also covers `sheet_read`, `picture_copy` and `resolution_run`.

## Cursor paging

The response contains `job`, `results`, `cursor`, `has_more` and `request_id`. Each page contains up to 50 results in input order.

1. Omit `cursor` for the first page (offset 0).
2. Consume `results` and retain any non-null returned `cursor`.
3. When `has_more` is true, request the next page with `?cursor=RETURNED_CURSOR`.
4. If `has_more` is false while queued or running, wait `poll_after_seconds`, then poll with the retained cursor. More results can arrive later.
5. Finish only when the job is `done` or `failed` and all result pages have been read (`cursor` is null).

A cursor must be a single query parameter of 1 to 6 digits (0 to 999999). Invalid or repeated cursor parameters return `400`. Do not treat `has_more: false` alone as completion. See the [curl examples](/docs/partners-api/quickstart.mdx#4-read-results-by-cursor).
