TimoBy Amotion AI

TimoBlog

Claude Batch API: Choose Batch Processing and Handle Partial Failures

Claude’s Message Batches API is for independent requests that can finish asynchronously, such as evaluations, document classification, and data analysis. An interactive Messages API call fits when a person or service needs an answer before it can continue.

Message Batches · result matchingJoin by custom_id, even when order changes
Submission orderResult order may differ
case_104Transcript 104
case_105Join to transcript 105
case_105Transcript 105
case_104Join to transcript 104

Store the ID-to-source mapping before submitting the batch.

Illustrative IDs. Match each returned result to the stored source record using custom_id, even when the return order changes.

Choice depends on the action after the model responds. A batch changes timing, but every result needs checking.

Interactive requests and batches solve different timing problems

An interactive request follows a request and response sequence. Your application sends one task, receives the response, checks it, and continues. This fits a support reply or a workflow that needs immediate feedback.

A Message Batch contains independent Messages API requests processed asynchronously. Your application submits the batch, polls its status, retrieves results, and matches each result to the original work item. The official documentation lists the result states succeeded, errored, canceled, and expired.

Batching fits independent work where the caller can wait. Use an interactive request when a user is waiting or the next step needs an immediate result. Both approaches need controls to prevent retries from duplicating a business action.

Use custom_id as your join key

A batch result may arrive in a different order from the requests you submitted. The API’s custom_id field is the stable identifier that lets your application join a result to the correct source record. Give each request an ID from your own work item, such as invoice_2026_00421 or ticket_8831, rather than relying on line position.

Store the mapping before submission:

custom_id source record intended output
case_104 support transcript 104 suggested category and reason
case_105 support transcript 105 suggested category and reason

When results return, write the outcome beside the matching source record. Do not assume result order matches request order. Keep the original input, prompt version, submission time, and status with the record.

Review each result state before retrying

A successful request produced a message, but that does not mean the message is correct for the business decision. An errored request needs an error-specific response. A validation error usually means the request must be fixed before resubmission; a transient server error may be eligible for a controlled retry. An expired request was not sent to the model before the batch reached its 24-hour expiry. A canceled batch may contain partial results for requests processed before cancellation.

Partial results · review and retryGive every result state its own next step
succeeded

Validate the message and its business meaning before approving an action.

errored

Inspect the error. Repair invalid input or apply a controlled retry for eligible errors.

canceled

Check the per-request outcome. A canceled batch can still contain completed results.

expired

The request was not sent before the batch expired. Review which requests remain useful and eligible to retry.

After per-record validation and any required review ↓
Approved action queue

Execute only approved actions. Keep a stable idempotency key and action record so a retry cannot create the action twice.

Retry only eligible records. Preserve completed outcomes and human decisions. A custom_id joins results; your action service must provide idempotency.

Illustrative routing after results are joined by custom_id. A succeeded message still needs validation; unresolved records need an explicit review and retry decision.

That distinction matters when a result can trigger an external action. An illustrative operations team classifies supplier records and receives succeeded, errored, and expired results. It reviews unresolved records and validates classifications before changing supplier status. It does not resubmit the entire file automatically, because a second pass could create duplicate tasks or overwrite a human decision.

For refunds, notices, account changes, or payments, separate model output from execution. Store approved_for_action only after validation and any required review. The action service must enforce an idempotency key so a retry cannot create the action twice. The batch request’s custom_id joins a result to its input; it does not enforce idempotency or guarantee exactly-once execution.

An illustrative batch workflow

The following sequence is an original workflow illustration. It is not executable code and Timo has not run it:

  1. Export a fixed set of records and assign a unique custom_id to each.
  2. Validate the request shape interactively, then submit the batch with a prompt version and source snapshot recorded.
  3. Poll until it ends, stream results, and join each result by custom_id.
  4. Validate succeeded results; route errored, canceled, and expired records to a review queue with retry eligibility.
  5. Execute external actions only from an approved queue with idempotency protection, and preserve the batch and action IDs.

The documentation says batches can take up to 24 hours and results remain available for a limited period. Check it before designing a time-sensitive process.

Batch design checklist

Common questions

Will batching make my workflow finish faster?

Do not treat batching as a guaranteed speed result. Measure the workflow you need, including polling, validation, review, and retries.

Can one batch contain different kinds of requests?

Requests can include many Messages API capabilities and are processed independently. Keep batches coherent; use separate queues when validators or owners differ.

Should I rerun the entire batch if some requests fail?

Keep successful and unresolved records separate. Inspect the error type, repair invalid inputs, retry eligible records, and preserve the original IDs. Do not regenerate the whole input without a duplicate-action safeguard.

How can Timo help me practise batch-processing decisions for Claude certification?

Use Timo's public Developer Foundations and Architect Foundations samples to practise comparing implementation choices and explaining your answer. For the workflow in this article, write down how you would detect a missing result and prevent a duplicate business action before checking your design.

Timo is run by Amotion AI, a registered member of the Claude Partner Network. If you need partner access for official preparation and registration, the Timo application guide explains the review, agreement and account process. Partner access is available through Timo. Official certification registration is separate from independent practice; Anthropic awards the credential.