POST /api/v1/forward/batches/{batch_id}/cancel
Once cancellation is initiated, Forward drains the queue, marks pending tasks as cancelled, and calls CancelSession on every running task.
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <PAT or SAT> |
Idempotency-Key | No | Optional idempotency key for unsafe requests. |
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
batch_id | string | Yes | Batch ID. |
Example request
Example response
HTTP 200 OK
status is the intermediate cancelling; otherwise it is cancelled directly. Cancelling a batch already in a terminal state returns the current object idempotently. usage is the aggregate CAS Credit usage persisted for subtasks at that time. It is null when no valid usage is available yet.
Response fields
| Field | Type | Description |
|---|---|---|
| Return value | object | Batch object. |
Cancellation flow
- Batch already in a terminal state: returns
200idempotently, no operation performed. - CAS transitions the status
validating|queued|processing → cancelling. - Drain the Redis queue and bulk-mark pending tasks as
cancelled. - Call
CancelSessionon each running task. - If no running tasks remain, trigger
finalizeimmediately; otherwise wait for the lastCompleteTaskto drivefinalize.
Error codes
| HTTP | Type | Code | Trigger |
|---|---|---|---|
| 404 | not_found_error | batch_not_found | Batch does not exist or belongs to another user. |
| 401 | authentication_error | authentication_required | PAT is invalid or expired. |
Notes
- Cancellation is asynchronous. A
cancellingresponse means the request was accepted; poll the batch detail to confirm the terminal state. - Cancelling a batch already in a terminal state is idempotent and returns
200.