jq one-liner: export Sume bulk queue items to CSV by index
Turn the bulk queue receipt from a curl poll into CSV rows of index, status, run_id and error code with jq, then paste them next to your SKU column.

To get a bulk queue into a spreadsheet, poll GET /v1/format-run-queues/{id} once and pipe .data.items through jq with @csv. Each queue item has index, status, run_id and error; the rows come out in the order you sent them, so row N of the CSV pastes beside row N of your input sheet without a lookup.
The one-liner is below. It needs a key with formats:read, the queue id that the create call returned, and jq 1.6 or later.
curl -sS -H "Authorization: Bearer $SUME_API_KEY" \
"https://api.sume.com/v1/format-run-queues/$QUEUE_ID" |
jq -r '["index","status","run_id","error_code"],
(.data.items[] | [.index, .status, (.run_id // ""), (.error.code // "")]) | @csv'What comes out
The first array is the header row. The second expression turns each item into an array, and @csv quotes strings and leaves numbers bare. The // "" operator replaces null with an empty cell: run_id is null while an item is queued and for a child that never started, and error is null on success. Without it, jq prints a bare null into the file.
If you saved the receipt earlier, replace the curl with jq ... queue.json and use the same filter. The -r flag matters, because without it jq wraps each CSV line in quotes and escapes the inner ones.
| Item field | Possible values | CSV cell |
|---|---|---|
index | 0 up to counts.total minus 1 | The number |
status | queued, running, completed, failed, canceled | The word, quoted |
run_id | a run id, or null | The id, or empty |
error.code | format_run_failed, format_run_canceled, a start failure code, or no error | The code, or empty |
Filters you will want next
Add a select before the array to keep only the rows to chase: .data.items[] | select(.status == "failed" or .status == "canceled") gives the retry list, and select(.status == "completed") gives the rows whose media you can fetch. The completed item status means the child run completed, so its receipt at GET /v1/format-runs/{run_id} holds the output.
Check .data.status first. While the queue is queued or running, some rows will have an empty run_id and a non-terminal status, and a CSV taken then is a snapshot. Only completed on the queue means every item is terminal, and even that does not mean they all succeeded: read .data.counts.failed as well.
A 429 or 503 on the poll is transient. Wait and run the command again. A 404 means the id is wrong, or the queue belongs to another owner.
To join the export to your sheet, put the SKU column from the file you sent next to the CSV by row number: the first data line is index 0 and your first row. Do not sort the CSV first, since the index is what ties it to your input. If you chunked a large sheet into several queues, export each queue to its own file and keep the queue id in the file name, because an index only means something inside its own queue.
For failed rows, open the run receipt with run_id rather than guessing from the error code: a format_run_failed item says only that the child failed, and the reason is on the receipt. Rows with an empty run_id and status failed never started a run, and their error.code is the create-time failure.
Sources
Related posts
More in Developers
- Let browsers start Sume jobs through your server, not with your key
Browsers must never hold a Sume API key. A server route authenticates the user, checks the input, derives an Idempotency-Key and returns only the status URL.
- List every Format run: no GET /v1/format-runs, page per Format
GET /v1/format-runs does not exist. List runs per Format with limit, next_cursor and has_more, or keep your own index of the data.id you stored at create.
- How do I add a listen-to-this-page audio version with TTS?
Turn each article into an audio file with one async TTS job per page: a 9,000-character article costs 43 cents on Sume. What it does not replace.
- Mandarin Chinese speech to text API: Sume STT language_code zh
Transcribe Mandarin audio with Sume STT using language_code zh, then check the result and timings. $0.01 per audio minute and no accuracy claim without a test.
Written by Sume