TokenLab

Files & Batches

Cancel Message Batch

Cancels a Message Batch that is still processing.

POST
/v1/messages/batches/{message_batch_id}/cancel

Overview

Request cancellation of a Message Batch that is still processing. The response shows the current state. processing_status is usually canceling, and requests that are already running can still finish. A batch that has already ended is returned unchanged.

Notes

  • After you cancel, retrieve the batch until processing_status is ended. Requests that had not started end as canceled.
  • A batch that does not exist or was deleted returns 404. A batch that is not ready to be changed yet returns 409; retry later.
  • Cancellation does not delete the batch. To remove it, delete it after it has ended.

Example

Request

cURL
curl -X POST "https://api.tokenlab.sh/v1/messages/batches/msgbatch_01ABC123/cancel" \
  -H "x-api-key: sk-your-api-key" \
  -H "anthropic-version: 2023-06-01"

Response example

Response

200 OK
{
  "id": "msgbatch_01ABC123",
  "type": "message_batch",
  "processing_status": "canceling",
  "request_counts": {
    "processing": 1,
    "succeeded": 1,
    "errored": 0,
    "canceled": 0,
    "expired": 0
  },
  "ended_at": null,
  "created_at": "2026-11-01T10:00:00Z",
  "expires_at": "2026-11-02T10:00:00Z",
  "cancel_initiated_at": "2026-11-01T10:05:00Z",
  "archived_at": null,
  "results_url": null
}

Important fields

processing_statusstring
canceling while the cancel is in progress, ended once it is complete. Do not assume every cancel request returns canceling.
cancel_initiated_atstring|null
When the cancel request was accepted, or null.

Authorization

BearerAuth
AuthorizationBearer <token>

API Key authentication. Create or manage API keys in Dashboard > API > API Keys.

In: header

Path Parameters

message_batch_id*string

Message batch identifier

Response

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json