Cancel Message Batch

VerifiedSafe

Cancel a message batch that is currently being processed. The batch transitions to a `canceling` state, and any in-progress non-interruptible requests may still complete. This is useful when you need to stop a batch early.

Sby Skills Guide Bot
DevelopmentIntermediate
1006/2/2026
Claude Code
#anthropic-api#message-batches#batch-cancellation#api-management

Recommended for

Our review

Cancels a message batch currently being processed via the Anthropic API.

Strengths

  • Provides a clean way to stop batch processing without waiting for completion.
  • Immediately returns 'canceling' status and request counts.
  • Simple POST call requiring only the batch ID.

Limitations

  • Cancellation is not immediate: some non-interruptible requests may still finish.
  • Requires prior knowledge of the message_batch_id.
  • Only works if the batch is still being processed.
When to use it

Use this operation when a message batch needs to be stopped before completion, such as for error handling or priority changes.

When not to use it

Avoid using it to cancel individual requests or when absolute immediate cancellation is needed.

Security analysis

Safe
Quality score88/100

The skill provides documentation for a POST endpoint to cancel a message batch, using a localhost mock server. No dangerous commands, secrets handling, or execution risks are present. It is purely informational.

No concerns found

Examples

Cancel a batch by ID
Cancel the message batch with ID msgbatch_013Zva2CMHLNnXjNJJKqJ2EF.
Stop processing of a batch
Stop the processing of batch msgbatch_013Zva2CMHLNnXjNJJKqJ2EF using the Anthropic API.

Cancel Message Batch

Initiate cancellation of a Message Batch that is currently being processed. The batch enters a canceling state and any in-progress, non-interruptible requests may still complete.

API Details

Sandbox

Mock server URL: http://localhost:8080/rest/anthropic-message-batches-api/1.0.0/messages/batches/{message_batch_id}/cancel

Required Headers

  • anthropic-version: 2023-06-01
  • x-api-key: {api-key}

Path Parameters

| Parameter | Type | Required | Description | |-----------|------|----------|-------------| | message_batch_id | string | Yes | Unique identifier of the message batch to cancel |

Example Request

curl -X POST "http://localhost:8080/rest/anthropic-message-batches-api/1.0.0/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/cancel" \
  -H "anthropic-version: 2023-06-01" \
  -H "x-api-key: your-api-key"

Example Response

{
  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
  "type": "message_batch",
  "processing_status": "canceling",
  "request_counts": {
    "processing": 50,
    "succeeded": 40,
    "errored": 5,
    "canceled": 5,
    "expired": 0
  },
  "created_at": "2024-08-20T18:37:24Z",
  "cancel_initiated_at": "2024-08-20T19:00:00Z"
}

Instructions

When the user asks to cancel or stop a message batch, use this operation by making a POST request to /messages/batches/{message_batch_id}/cancel. Note that cancellation is not immediate — the batch enters canceling status and some requests may still complete.

Related skills