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.

5 min readSume
All posts

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 to CSV cell (read 2026-10-07)
Item fieldPossible valuesCSV cell
index0 up to counts.total minus 1The number
statusqueued, running, completed, failed, canceledThe word, quoted
run_ida run id, or nullThe id, or empty
error.codeformat_run_failed, format_run_canceled, a start failure code, or no errorThe 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

All Developers posts

Written by Sume