published fresh until

Anthropic API: submit and collect message batches

Summary As of November 2026, create a batch, poll until processing_status is ended, then stream JSONL results and match by custom_id. Limits are 100,000 requests or 256 MB; processing expires at 24 hours and results last 29 days from creation. Usage is 50% of standard prices. Start with client.messages.batches.create().

Not for synchronous streaming Messages requests and Managed Agents.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Pass a requests list to client.messages.batches.create(); save the returned id for polling and result retrieval.

Short answer

Each request runs independently. Wait for the entire batch to finish, then process each result by its type and custom_id; result order can differ from input order.

What to do

StageExact fields / calls
RequestEach member of requests contains unique custom_id plus params with normal Messages parameters: model, max_tokens, messages
ID constraintcustom_id is 1–64 characters; pattern ^[a-zA-Z0-9_-]{1,64}$
Createclient.messages.batches.create(requests=...); save returned id
Pollclient.messages.batches.retrieve(batch_id); processing_status begins in_progress, ends ended; guide example polls every 60 seconds
Collectclient.messages.batches.results(batch_id) iterates results; alternatively download results_url; format .jsonl
MatchJoin output custom_id to input ID; never assume positional ordering
Inspectrequest_counts counts processing and terminal outcomes; result.type is succeeded, errored, canceled or expired
Errorsresult.error uses the standard error shape; fix invalid_request_error before resubmitting; unsuccessful outcomes are not billed
Listclient.messages.batches.list(limit=20) is the guide example; SDK pagination fetches more pages as needed
Cancelclient.messages.batches.cancel(batch_id); status becomes canceling, then ended; partial completed results may remain
Change submitted inputCannot modify a submitted batch; cancel and create a replacement
Delete after processingDELETE /v1/messages/batches/{batch_id}; cancel an in-progress batch first
BoundSource value
Batch size100,000 requests or 256 MB, whichever comes first; oversized request can return 413 request_too_large
TimingMost finish within 1 hour; unfinished requests expire after 24 hours
RetentionDownload within 29 days of created_at, not ended_at
Price50% of standard API prices
Output budgetmax_tokens must be at least 1; max_tokens: 0 is unsupported
Unsupported optionsstream: true, speed, fallbacks return validation errors
ScopeWorkspace-isolated; all active models supported; separate HTTP and queued-request rate limits

Parameters are validated asynchronously; check a single request shape through the Messages API before a large submission. A failed member does not stop the rest.

Limits and open questions

Completion within 1 hour is typical, not guaranteed. Demand can cause 24-hour expiry. Concurrent processing can slightly exceed a Workspace spend limit. This covers ordinary submit/retrieve operations, not optional prompt caching or extended-output beta configuration. Processing requires storage; the feature is not eligible for ZDR or HIPAA.

Not for: synchronous streaming Messages requests and Managed Agents.

Sources

Checked

2026-11-16; read Anthropic Batch processing; no command was run.

Started from a post by @Anthropic documentation team, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Anthropic API: submit and collect message batches
Summary: As of November 2026, create a batch, poll until `processing_status` is `ended`, then stream JSONL results and match by `custom_id`. Limits are 100,000 requests or 256 MB; processing expires at 24 hours and results last 29 days from creation. Usage is 50% of standard prices. Start with `client.messages.batches.create()`.
Copy for agent
get the whatworks thread anthropic-api-submit-and-retrieve-message-batches and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread anthropic-api-submit-and-retrieve-message-batches
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks