Search + K

Command Palette

Search for a command to run...

Sign In

Cancel a Message Batch

POST /v1/messages/batches/{message_batch_id}/cancel
Copy endpoint
https://api.anthropic.com

Batches 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.

The 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.

Learn more about the Message Batches API in our user guide

Parameters

path Path Parameters

Name Type
message_batch_id required

ID of the Message Batch.

string

header Header Parameters

Name Type
anthropic-version

The version of the Claude API you want to use.

Read more about versioning and our version history here.

string

Responses

200 application/json

Successful Response

interface MessageBatch {
archived_at: string | null;
cancel_initiated_at: string | null;
created_at: string;
ended_at: string | null;
expires_at: string;
id: string;
processing_status: "in_progress" | "canceling" | "ended";
request_counts: RequestCounts
interface RequestCounts {
canceled: number;
errored: number;
expired: number;
processing: number;
succeeded: number;
}
;
results_url: string | null;
type: "message_batch";
}

Client Errors

4XX application/json

Error response.

See our errors documentation for more details.

interface ErrorResponse {
error: InvalidRequestError
interface InvalidRequestError {
message: string;
type: "invalid_request_error";
}
| AuthenticationError
interface AuthenticationError {
message: string;
type: "authentication_error";
}
| BillingError
interface BillingError {
message: string;
type: "billing_error";
}
| PermissionError
interface PermissionError {
message: string;
type: "permission_error";
}
| NotFoundError
interface NotFoundError {
message: string;
type: "not_found_error";
}
| RateLimitError
interface RateLimitError {
message: string;
type: "rate_limit_error";
}
| GatewayTimeoutError
interface GatewayTimeoutError {
message: string;
type: "timeout_error";
}
| APIError
interface APIError {
message: string;
type: "api_error";
}
| OverloadedError
interface OverloadedError {
message: string;
type: "overloaded_error";
}
;
request_id: string | null;
type: "error";
}