Anthropic’s Messages API shipped a beta called message threads on November 2, 2026: instead of resending the entire conversation on every turn, you send only the new messages and the API keeps the rest on its own servers. This guide walks through migrating an existing agent loop — the kind that resends full history every turn — to the new pattern, including the field rules, error codes, and the cases where you should not use it yet.
What actually changes
In the classic pattern, every request to /v1/messages carries the full messages array — every prior user and assistant turn — because the API is stateless by default. A ten-turn support conversation means the tenth request still re-sends and re-tokenizes the first nine turns. With a thread, the server holds that history for you. You open a thread with "thread": {"type": "create"} on your first request, and every later turn sends "thread": {"type": "continue", "previous_message_id": "<id>"} with nothing but the new message. Anthropic is explicit that this is a performance change, not a pricing change: threads “do not change pricing or rate limits.” What you save is request size and a steadier time to first token, because the API no longer has to re-validate and re-tokenize messages it already processed.
The structural difference matters more than it first sounds. Under the old pattern, the total bytes you transmit across an N-turn conversation grows roughly with the square of its length, because each of the N requests re-sends an ever-longer transcript. Under threads, each request carries only that turn’s new content, so total bytes sent grows roughly linearly with the number of turns. That gap is small for a three-turn exchange and large for a long-running agent loop that runs for dozens of turns in a single session.
Before and after: the same two-turn exchange
Here is the field-level difference for turn two of a conversation, using Anthropic’s own support-agent example.
Before (classic, stateless)
POST /v1/messages with: model, max_tokens, system (resent), and a messages array containing both the first user turn, the assistant’s first reply, and the new second user turn — the full transcript, every time.
After (message threads)
POST /v1/messages with the anthropic-beta: message-threads-2026-08-12 header, model, max_tokens, a messages array containing only the new second user turn, and "thread": {"type": "continue", "previous_message_id": "<id from the first response>"}. No system field — sending it on a continue request, even as null, returns a 400 error.
Skipping the manual plumbing with the Python SDK helper
If you’re on the Python SDK, there’s a beta helper that does steps 2 through 4 below for you: client.beta.messages.thread(...) returns a thread object, and calling .send({"role": "user", "content": "..."}) on it adds the beta header, sets thread.type to create or continue as appropriate, and tracks previous_message_id internally. It keeps the conversation in memory on your side only — it doesn’t persist anything to disk, so you still need your own storage if the process can restart mid-conversation. For any other language, or if you want full control over retries and the error handling below, build the requests directly as shown in the steps that follow.
Step by step: migrating your loop
- Add the beta header to every call in the loop.
anthropic-beta: message-threads-2026-08-12must be present on the create request and on every continue request — not just the first one. - Replace your in-memory message list with a single stored value: the last response
id. There is no separatethread_id; the responseidof the previous turn is what you pass asprevious_message_idon the next one. Your code no longer needs to append to a growing array before each call. - Open the thread on turn one with
"thread": {"type": "create"}, and keepsystem,tools, and other fixed fields on this request only. - On every later turn, send only the new message(s) with
"thread": {"type": "continue", "previous_message_id": "<id>"}, and dropsystemandtoolsentirely — they’re create-only. - Keep
model,tool_choice,thinking,mcp_servers, and the beta header identical across the whole thread. Changing any of them mid-thread returns 400thread_fingerprint_mismatch; you have to start a new thread instead. - If you use MCP servers or a container, resend those fields on every request that needs them. The API doesn’t store MCP URLs, tokens, or container IDs between turns, even inside a thread.
- Handle the 5-minute idle expiry. A thread expires 5 minutes after its last request (each new request resets the clock) and is deleted no more than an hour after it was last used. Keep your own copy of the full conversation client-side so you can recover.
- Catch 404
thread_not_foundand replay. If a continue request 404s, send a fresh"thread": {"type": "create"}request with your own saved copy of the full conversation — this is why step 7 matters. - If you stream, wait for
message_stopbefore continuing. The responseidarrives early, inmessage_start, but continuing before the stream finishes risks a race. If a stream drops mid-response, resend the same continue request once; if you getthread_already_continuedorthread_continue_in_flight, fall back to replaying with a create request.
Field rules, reproduced from the docs
| Field category | Examples | Rule |
|---|---|---|
| Create-only | system, tools | Sending either on a continue request returns 400, even if the value is null |
| Fixed for the whole thread | model, tool_choice, thinking, mcp_servers, context_management, output_config, container skills, top-level cache_control, the beta header set | Changing one returns 400 thread_fingerprint_mismatch; start a new thread to change it |
| Free to change per turn | max_tokens, stop_sequences, stream, metadata, service_tier | No restriction |
| Resend every time | mcp_servers, container | Not stored between turns even within a thread |
Error codes you’ll hit while migrating
Each of these shows up as a 400 or 404 with a specific error.details.error_code, and each has a different fix — worth handling individually in your retry logic rather than with one generic catch block.
| Status | error_code | What to do |
|---|---|---|
| 404 | thread_not_found | Replay the full conversation in a new create request |
| 400 | thread_fingerprint_mismatch | Keep fixed fields (model, tool_choice, thinking, mcp_servers, etc.) unchanged, or start a new thread |
| 400 | thread_already_continued | Continue from the latest response id instead, or replay |
| 400 | thread_continue_in_flight | Wait for the earlier in-flight request to finish, or replay |
| 400 | thread_unsupported_request | Remove the unsupported feature (for example, a 5th cache_control breakpoint) or send the request without thread at all |
How to tell the migration actually worked
Don’t take the performance improvement on faith. Log the outgoing request body size (in bytes, before you send it) alongside the turn number, for both your old code path and the new one, during a side-by-side test against the same scripted conversation. If the migration is wired correctly, request size for turn N should stop growing with N under threads, while it keeps climbing under the classic path. If you still see your continue requests carrying a full messages history, the most common cause is a leftover line of code that still appends every turn to a local array and sends the whole thing — the array is fine to keep for your own replay copy, just stop putting all of it in the request body once thread.type is "continue".
Where threads don’t apply yet
Threads are append-only: you can’t edit or branch an earlier message, so any workflow that needs to retry a turn with a different prompt has to start a new thread. They’re also not supported alongside Message Batches, token counting, compaction, most context-editing options, or for organizations configured for HIPAA readiness or Inference hooks, and threads aren’t eligible for Zero Data Retention. There’s no management API either — you can’t list, read, or delete a thread, which is one more reason to keep your own copy of the conversation rather than treating the server-held thread as your system of record.
FAQ
Do message threads make Claude cheaper to run?
No. Anthropic states directly that threads “do not change pricing or rate limits” — the benefit is smaller requests and steadier time to first token, not a lower per-token price. If cost is your goal rather than latency, prompt caching is the relevant feature, and it still needs to be added manually with cache_control even inside a thread.
What happens if my app crashes and loses the thread’s last response ID?
Nothing recovers it for you — there’s no API to list or look up an existing thread. You have to fall back to a create request with your own saved copy of the conversation, which is why the docs stress keeping your own copy as the source of truth rather than relying on the thread alone.
For the conversations you do keep server-side, see our guides to clearing a turn-scoped system message in the Claude API, context caching pricing across Claude, GPT, and Gemini for the cost side threads don’t cover, reusing PDF uploads with the Files API for another way to shrink repeated request payloads, and how stop reasons and truncation work across Claude, OpenAI, and Gemini, since a thread’s pause_turn handling builds on the same stop-reason mechanics.
Source: Anthropic, “Message threads” API reference, and the Claude Platform release notes.



