Claude Platform Docs

Batches

Create a Message Batch
beta.messages.batches.create(BatchCreateParams**kwargs) -> BetaMessageBatch
POST/v1/messages/batches
Retrieve a Message Batch
beta.messages.batches.retrieve(strmessage_batch_id, BatchRetrieveParams**kwargs) -> BetaMessageBatch
GET/v1/messages/batches/{message_batch_id}
List Message Batches
beta.messages.batches.list(BatchListParams**kwargs) -> SyncPage[BetaMessageBatch]
GET/v1/messages/batches
Cancel a Message Batch
beta.messages.batches.cancel(strmessage_batch_id, BatchCancelParams**kwargs) -> BetaMessageBatch
POST/v1/messages/batches/{message_batch_id}/cancel
Delete a Message Batch
beta.messages.batches.delete(strmessage_batch_id, BatchDeleteParams**kwargs) -> BetaDeletedMessageBatch
DELETE/v1/messages/batches/{message_batch_id}
Retrieve Message Batch results
beta.messages.batches.results(strmessage_batch_id, BatchResultsParams**kwargs) -> BetaMessageBatchIndividualResponse
GET/v1/messages/batches/{message_batch_id}/results
Models
class BetaDeletedMessageBatch:
id: str

ID of the Message Batch.

type: Literal["message_batch_deleted"]

Deleted object type.

For Message Batches, this is always "message_batch_deleted".

defaultmessage_batch_deleted
class BetaMessageBatch:
class BetaMessageBatchCanceledResult:
type: Literal["canceled"]
defaultcanceled
class BetaMessageBatchErroredResult:
error: BetaError
One of the following:
request_id: Optional[str]
type: Literal["error"]
defaulterror
type: Literal["errored"]
defaulterrored
class BetaMessageBatchExpiredResult:
type: Literal["expired"]
defaultexpired
class BetaMessageBatchIndividualResponse:

This is a single line in the response .jsonl file and does not represent the response as a whole.

custom_id: str

Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.

Must be unique for each request within the Message Batch.

Processing result for this request.

Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

One of the following:
class BetaMessageBatchRequestCounts:
canceled: int

Number of requests in the Message Batch that have been canceled.

This is zero until processing of the entire Message Batch has ended.

default0
errored: int

Number of requests in the Message Batch that encountered an error.

This is zero until processing of the entire Message Batch has ended.

default0
expired: int

Number of requests in the Message Batch that have expired.

This is zero until processing of the entire Message Batch has ended.

default0
processing: int

Number of requests in the Message Batch that are processing.

default0
succeeded: int

Number of requests in the Message Batch that have completed successfully.

This is zero until processing of the entire Message Batch has ended.

default0

Processing result for this request.

Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

One of the following:
class BetaMessageBatchSucceededResult:
message: BetaMessage
type: Literal["succeeded"]
defaultsucceeded