Message Batches examples
Example usage for the Message Batches API
The Message Batches API supports the same set of features as the Messages API. While this page focuses on how to use the Message Batches API, see Messages API examples for examples of the Messages API featureset.
Creating a Message Batch
Polling for Message Batch completion
To poll a Message Batch, you’ll need its id
, which is provided in the response when creating request or by listing batches. Example id
: msgbatch_013Zva2CMHLNnXjNJJKqJ2EF
.
Listing all Message Batches in a Workspace
Retrieving Message Batch Results
Once your Message Batch status is ended
, you will be able to view the results_url
of the batch and retrieve results in the form of a .jsonl
file.
Canceling a Message Batch
Immediately after cancellation, a batch’s processing_status
will be canceling
. You can use the same polling for batch completion technique to poll for when cancellation is finalized as canceled batches also end up ended
and may contain results.