SPB Git

Repository Public

retrieving-message-batches.md 4.3 KB 164 lines markdown

1---2title: Retrieve a Message Batch3url: https://platform.claude.com/docs/en/api/messages/batches/retrieve4---56# Retrieve a Message Batch78**GET** `/v1/messages/batches/{message_batch_id}`910This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.1112Learn more about the Message Batches API in our [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)1314## Path parameters1516- `message_batch_id: string`1718  ID of the Message Batch.1920## Headers2122- `"anthropic-workspace-id": optional string`2324## Returns2526- `MessageBatch object`2728  - `type: "message_batch"`2930    Object type.3132    For Message Batches, this is always `"message_batch"`.3334    default: message_batch3536  - `id: string`3738    Unique object identifier.3940    The format and length of IDs may change over time.4142  - `archived_at: string or null`4344    RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.4546    format: date-time4748  - `cancel_initiated_at: string or null`4950    RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.5152    format: date-time5354  - `created_at: string`5556    RFC 3339 datetime string representing the time at which the Message Batch was created.5758    format: date-time5960  - `ended_at: string or null`6162    RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.6364    Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.6566    format: date-time6768  - `expires_at: string`6970    RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.7172    format: date-time7374  - `processing_status: "in_progress" or "canceling" or "ended"`7576    Processing status of the Message Batch.7778    - `"in_progress"`7980    - `"canceling"`8182    - `"ended"`8384  - `request_counts: MessageBatchRequestCounts`8586    Tallies requests within the Message Batch, categorized by their status.8788    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.8990    - `canceled: number`9192      Number of requests in the Message Batch that have been canceled.9394      This is zero until processing of the entire Message Batch has ended.9596      default: 09798    - `errored: number`99100      Number of requests in the Message Batch that encountered an error.101102      This is zero until processing of the entire Message Batch has ended.103104      default: 0105106    - `expired: number`107108      Number of requests in the Message Batch that have expired.109110      This is zero until processing of the entire Message Batch has ended.111112      default: 0113114    - `processing: number`115116      Number of requests in the Message Batch that are processing.117118      default: 0119120    - `succeeded: number`121122      Number of requests in the Message Batch that have completed successfully.123124      This is zero until processing of the entire Message Batch has ended.125126      default: 0127128  - `results_url: string or null`129130    URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.131132    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.133134## Example135136```bash137curl https://api.anthropic.com/v1/messages/batches/$MESSAGE_BATCH_ID \138    -H 'anthropic-version: 2023-06-01' \139    -H "X-Api-Key: $ANTHROPIC_API_KEY"140```141142### Response (200)143144```json145{146  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",147  "archived_at": "2024-08-20T18:37:24.100435Z",148  "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",149  "created_at": "2024-08-20T18:37:24.100435Z",150  "ended_at": "2024-08-20T18:37:24.100435Z",151  "expires_at": "2024-08-20T18:37:24.100435Z",152  "processing_status": "in_progress",153  "request_counts": {154    "canceled": 10,155    "errored": 30,156    "expired": 10,157    "processing": 100,158    "succeeded": 50159  },160  "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",161  "type": "message_batch"162}163```164
Files main
Menu

Theme