message-threads changedbuild-with-claude/message-threads
Nearest release: v2.1.336, published an hour before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+13added
Lines−1removed
From line
46
where the diff opens
First seen
2 Nov 2026
this site's first read of the page
Recorded edits12to this page, all time
### How long a thread lasts
The whole hunk
from line 46, old and new numbered
/
from line 46
4646
4747* **Create.** Send your first request as you do today, with the full conversation, `system`, and `tools`. Add `"thread": {"type": "create"}` to the request. The API stores the conversation, including Claude’s reply, under the response `id`.
4848* **Continue.** Send only the messages since the previous response and add `"thread": {"type": "continue", "previous_message_id": "<previous id>"}`. Leave `system` and `tools` out of the request. The thread keeps the values from the create request. Use each new response `id` for the next turn.
49* **Replay.** A thread is best-effort. It expires 5 minutes after its last request, and the API deletes it no more than 1 hour after its last use. Each response that the API stores restarts the 5 minutes. If the API can no longer continue the thread, a continue request returns a 404 error. Send the full conversation again in a new create request and continue from the new response `id`. The SDK thread helper does this replay for you (see [How the SDK helper behaves](https://platform.claude.com/docs/en/build-with-claude/message-threads#sdk-helper-handles)). After a response from a fallback model, see [Use fallbacks with a thread](https://platform.claude.com/docs/en/build-with-claude/message-threads#fallbacks).
49* **Replay.** If the API can no longer continue the thread, a continue request returns a 404 error with the code `thread_not_found`. Send the full conversation, including your new messages, in a new create request with `system` and `tools`. Then, continue from the new response `id`. For the causes and the full steps, see [Recover when a thread can’t be continued](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover). The SDK thread helper does this replay for you (see [How the SDK helper behaves](https://platform.claude.com/docs/en/build-with-claude/message-threads#sdk-helper-handles)).
5050
5151Your application stays the source of truth for the conversation. Keep your own copy of every message and build the [replay path](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover) from the start. No response to a create or a continue request says whether the API stored that turn. You find out on the next continue request. The SDK thread helper keeps this copy in memory while the helper object exists, and it saves the copy nowhere else. If the conversation has to outlive your process, keep your own copy.
52
53### How long a thread lasts
54
55A thread is best-effort and short-lived. Each time the API stores a response, it sets how long to keep the thread. You can’t set that time yourself.
56
57* **Plan for 5 minutes.** Expect a thread to expire 5 minutes after the last response that the API stored.
58* **Don’t rely on more.** The API might set a longer time. That time is at most 1 hour, and it might differ from one response to the next.
59* **Be ready for less.** A thread might end within the 5 minutes.
60
61You don’t need a timer. Send the continue request. If it returns `thread_not_found`, replay the conversation (see [Recover when a thread can’t be continued](https://platform.claude.com/docs/en/build-with-claude/message-threads#recover)).
62
63Whatever time the API sets, it deletes every thread no more than 1 hour after its last use. See [Data retention](https://platform.claude.com/docs/en/build-with-claude/message-threads#data-retention).
5264
5365## Use a thread with the SDK
5466
No line in this hunk matches that.