Cancel batch documents
Cancel pending or processing documents in a batch.
document_ids omitted, the batch itself becomes CANCELLED.
Idempotent: a second call returns 200 with cancelled_doc_count == 0.Authorizations
Organisation API key from Settings → API / /api/keys/. The secret is
shown once. Send Authorization: Bearer sk-abacus-…. One active key
per organisation. Ingest (/api/v2/ingest/*) refuses API keys — that
surface is Auth0-only with ingest:read / ingest:write scopes.
Path Parameters
Body
Body for POST /api/v2/batches/{batch_id}/cancel/ (AD-178).
Cancels one, several, or all PENDING / PROCESSING BatchDocument rows
in a batch. Already-COMPLETED docs are NEVER touched (work and credits
already spent). The cancel endpoint is intentionally idempotent: re-posting
when nothing is cancellable returns 200 with cancelled_doc_count == 0.
Cancel semantics:
- Per-row cancel (
document_idsprovided): only the listed docs are flipped toCANCELLED. The parentBatch.statusis left untouched — the batch can still complete on its remaining docs. - Full-batch cancel (
document_idsomitted or empty): every non-terminal doc is flipped toCANCELLEDANDBatch.statusis set toCANCELLED(terminal). Subsequent reprocess + re-add are blocked by the terminal-batch guard in those endpoints.
For docs already in PROCESSING at cancel time, the worker's in-flight
Lynx gRPC call is NOT aborted mid-stream — the call finishes and the
extraction result is saved on the attachment. But the worker's terminal
status update uses filter(status=PROCESSING) so a doc that flipped
to CANCELLED in the meantime will silently skip the COMPLETED transition
and stay CANCELLED. Credits already deducted are NOT refunded.
Fields:
document_ids: Optional list of BatchDocument PKs to cancel.
When omitted (or empty), every non-terminal doc in the batch is
cancelled and the batch itself transitions to CANCELLED.
Optional list of BatchDocument PKs to cancel. Omit (or send an empty list) to cancel every non-terminal doc in the batch AND set Batch.status to CANCELLED.
1024x >= 1Response
Response shape for POST /api/v2/batches/{batch_id}/cancel/.
Fields:
batch: Updated parent batch (status flipped to CANCELLED on
full-batch cancel; unchanged on per-row cancel).
cancelled_doc_count: Number of BatchDocument rows whose status
actually flipped to CANCELLED on this call. Zero when the
request matched no cancellable docs (still 200 — idempotent).
full_batch: True when this call cancelled the whole batch
(document_ids was omitted/empty), False for per-row cancel.
Compact projection of a Batch row for responses that need to echo the parent batch state alongside per-row payloads.
Currently used by BatchReprocessResponse so the SPA can update its
batch header (status pill, default version chip) without a follow-up GET.

