Skip to main content
POST
Cancel pending/processing docs in a batch
Flips PENDING/PROCESSING rows to CANCELLED. Completed rows are never touched. Credits already spent are not refunded. With document_ids omitted, the batch itself becomes CANCELLED. Idempotent: a second call returns 200 with cancelled_doc_count == 0.

Authorizations

Authorization
string
header
required

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

batch_id
integer
required

Body

application/json

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_ids provided): only the listed docs are flipped to CANCELLED. The parent Batch.status is left untouched — the batch can still complete on its remaining docs.
  • Full-batch cancel (document_ids omitted or empty): every non-terminal doc is flipped to CANCELLED AND Batch.status is set to CANCELLED (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.

document_ids
integer[]

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.

Maximum array length: 1024
Required range: x >= 1

Response

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.

batch
object
required

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.

cancelled_doc_count
integer
required
full_batch
boolean
required