Repository Public
1---2title: Cancel a Message Batch3url: https://platform.claude.com/docs/en/api/beta/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-beta": optional array of AnthropicBeta`2526 Optional header to specify the beta version(s) you want to use.2728 - `string`2930 - `"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 43 more`3132 - `"message-batches-2024-09-24"`3334 - `"prompt-caching-2024-07-31"`3536 - `"computer-use-2024-10-22"`3738 - `"computer-use-2025-01-24"`3940 - `"pdfs-2024-09-25"`4142 - `"token-counting-2024-11-01"`4344 - `"token-efficient-tools-2025-02-19"`4546 - `"output-128k-2025-02-19"`4748 - `"files-api-2025-04-14"`4950 - `"mcp-client-2025-04-04"`5152 - `"mcp-client-2025-11-20"`5354 - `"dev-full-thinking-2025-05-14"`5556 - `"interleaved-thinking-2025-05-14"`5758 - `"code-execution-2025-05-22"`5960 - `"extended-cache-ttl-2025-04-11"`6162 - `"context-1m-2025-08-07"`6364 - `"context-management-2025-06-27"`6566 - `"model-context-window-exceeded-2025-08-26"`6768 - `"skills-2025-10-02"`6970 - `"fast-mode-2026-02-01"`7172 - `"output-300k-2026-03-24"`7374 - `"user-profiles-2026-03-24"`7576 - `"user-profiles-2026-08-18"`7778 - `"user-profiles-2026-09-04"`7980 - `"advisor-tool-2026-03-01"`8182 - `"managed-agents-2026-04-01"`8384 - `"cache-diagnosis-2026-04-07"`8586 - `"dreaming-2026-04-21"`8788 - `"thinking-token-count-2026-05-13"`8990 - `"server-side-fallback-2026-06-01"`9192 - `"server-side-fallback-2026-07-01"`9394 - `"fallback-credit-2026-06-01"`9596 - `"fallback-credit-2026-07-01"`9798 - `"agent-memory-2026-07-22"`99100 - `"mid-conversation-tool-changes-2026-07-01"`101102 - `"compact-2026-01-12"`103104 - `"computer-use-2025-11-24"`105106 - `"mcp-tunnels-2026-06-22"`107108 - `"structured-outputs-2025-11-13"`109110 - `"task-budgets-2026-03-13"`111112 - `"thinking-display-updates-2026-08-18"`113114 - `"ce-user-management-2026-07-13"`115116 - `"mid-conversation-output-config-2026-07-01"`117118 - `"thinking-binding-controls-2026-08-01"`119120 - `"mid-conversation-system-clear-at-2026-08-21"`121122 - `"compact-2026-09-04"`123124- `"anthropic-workspace-id": optional string`125126## Returns127128- `BetaMessageBatch object`129130 - `type: "message_batch"`131132 Object type.133134 For Message Batches, this is always `"message_batch"`.135136 default: message_batch137138 - `id: string`139140 Unique object identifier.141142 The format and length of IDs may change over time.143144 - `archived_at: string or null`145146 RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.147148 format: date-time149150 - `cancel_initiated_at: string or null`151152 RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.153154 format: date-time155156 - `created_at: string`157158 RFC 3339 datetime string representing the time at which the Message Batch was created.159160 format: date-time161162 - `ended_at: string or null`163164 RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.165166 Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.167168 format: date-time169170 - `expires_at: string`171172 RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.173174 format: date-time175176 - `processing_status: "in_progress" or "canceling" or "ended"`177178 Processing status of the Message Batch.179180 - `"in_progress"`181182 - `"canceling"`183184 - `"ended"`185186 - `request_counts: BetaMessageBatchRequestCounts`187188 Tallies requests within the Message Batch, categorized by their status.189190 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.191192 - `canceled: number`193194 Number of requests in the Message Batch that have been canceled.195196 This is zero until processing of the entire Message Batch has ended.197198 default: 0199200 - `errored: number`201202 Number of requests in the Message Batch that encountered an error.203204 This is zero until processing of the entire Message Batch has ended.205206 default: 0207208 - `expired: number`209210 Number of requests in the Message Batch that have expired.211212 This is zero until processing of the entire Message Batch has ended.213214 default: 0215216 - `processing: number`217218 Number of requests in the Message Batch that are processing.219220 default: 0221222 - `succeeded: number`223224 Number of requests in the Message Batch that have completed successfully.225226 This is zero until processing of the entire Message Batch has ended.227228 default: 0229230 - `results_url: string or null`231232 URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.233234 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.235236## Example237238```bash239curl https://api.anthropic.com/v1/messages/batches/$MESSAGE_BATCH_ID/cancel \240 -X POST \241 -H 'anthropic-version: 2023-06-01' \242 -H 'anthropic-beta: message-batches-2024-09-24' \243 -H "X-Api-Key: $ANTHROPIC_API_KEY"244```245246### Response (200)247248```json249{250 "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",251 "archived_at": "2024-08-20T18:37:24.100435Z",252 "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",253 "created_at": "2024-08-20T18:37:24.100435Z",254 "ended_at": "2024-08-20T18:37:24.100435Z",255 "expires_at": "2024-08-20T18:37:24.100435Z",256 "processing_status": "in_progress",257 "request_counts": {258 "canceled": 10,259 "errored": 30,260 "expired": 10,261 "processing": 100,262 "succeeded": 50263 },264 "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",265 "type": "message_batch"266}267```268