Repository Public
1---2title: Cancel a Message Batch3url: https://platform.claude.com/docs/en/api/messages/batches/cancel4---56# Cancel a Message Batch78**POST** `/v1/messages/batches/{message_batch_id}/cancel`910Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation.1112The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible.1314Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)1516## Path parameters1718- `message_batch_id: string`1920 ID of the Message Batch.2122## Headers2324- `"anthropic-workspace-id": optional string`2526## Returns2728- `MessageBatch object`2930 - `type: "message_batch"`3132 Object type.3334 For Message Batches, this is always `"message_batch"`.3536 default: message_batch3738 - `id: string`3940 Unique object identifier.4142 The format and length of IDs may change over time.4344 - `archived_at: string or null`4546 RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.4748 format: date-time4950 - `cancel_initiated_at: string or null`5152 RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.5354 format: date-time5556 - `created_at: string`5758 RFC 3339 datetime string representing the time at which the Message Batch was created.5960 format: date-time6162 - `ended_at: string or null`6364 RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.6566 Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.6768 format: date-time6970 - `expires_at: string`7172 RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.7374 format: date-time7576 - `processing_status: "in_progress" or "canceling" or "ended"`7778 Processing status of the Message Batch.7980 - `"in_progress"`8182 - `"canceling"`8384 - `"ended"`8586 - `request_counts: MessageBatchRequestCounts`8788 Tallies requests within the Message Batch, categorized by their status.8990 Requests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.9192 - `canceled: number`9394 Number of requests in the Message Batch that have been canceled.9596 This is zero until processing of the entire Message Batch has ended.9798 default: 099100 - `errored: number`101102 Number of requests in the Message Batch that encountered an error.103104 This is zero until processing of the entire Message Batch has ended.105106 default: 0107108 - `expired: number`109110 Number of requests in the Message Batch that have expired.111112 This is zero until processing of the entire Message Batch has ended.113114 default: 0115116 - `processing: number`117118 Number of requests in the Message Batch that are processing.119120 default: 0121122 - `succeeded: number`123124 Number of requests in the Message Batch that have completed successfully.125126 This is zero until processing of the entire Message Batch has ended.127128 default: 0129130 - `results_url: string or null`131132 URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.133134 Results in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.135136## Example137138```bash139curl https://api.anthropic.com/v1/messages/batches/$MESSAGE_BATCH_ID/cancel \140 -X POST \141 -H 'anthropic-version: 2023-06-01' \142 -H "X-Api-Key: $ANTHROPIC_API_KEY"143```144145### Response (200)146147```json148{149 "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",150 "archived_at": "2024-08-20T18:37:24.100435Z",151 "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",152 "created_at": "2024-08-20T18:37:24.100435Z",153 "ended_at": "2024-08-20T18:37:24.100435Z",154 "expires_at": "2024-08-20T18:37:24.100435Z",155 "processing_status": "in_progress",156 "request_counts": {157 "canceled": 10,158 "errored": 30,159 "expired": 10,160 "processing": 100,161 "succeeded": 50162 },163 "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",164 "type": "message_batch"165}166```167