threads
Creates, updates, deletes, gets or lists a threads resource.
Overview
| Name | threads |
| Type | Resource |
| Id | anthropic.sessions.threads |
Fields
The following fields are returned by SELECT queries:
- get
- list
Successful response (OK)
| Name | Datatype | Description |
|---|---|---|
id | string | Unique identifier for this thread. |
parent_thread_id | string | Parent thread that spawned this thread. Null for the primary thread. |
session_id | string | The session this thread belongs to. |
agent | object | Resolved agent definition for this thread. Snapshot of the agent at thread creation time. |
archived_at | string (date-time) | When the thread was archived. Null if not archived. |
created_at | string (date-time) | When the thread was created. |
stats | object | Timing statistics for this thread. Null until the thread's first status transition. |
status | string | Current execution status of the thread. (running, idle, rescheduling, terminated) |
type | string | (session_thread) |
updated_at | string (date-time) | When the thread was last updated. |
usage | object | Cumulative token usage for this thread. Null until the thread's first idle transition. |
Successful response (OK)
| Name | Datatype | Description |
|---|---|---|
id | string | Unique identifier for this thread. |
parent_thread_id | string | Parent thread that spawned this thread. Null for the primary thread. |
session_id | string | The session this thread belongs to. |
agent | object | Resolved agent definition for this thread. Snapshot of the agent at thread creation time. |
archived_at | string (date-time) | When the thread was archived. Null if not archived. |
created_at | string (date-time) | When the thread was created. |
stats | object | Timing statistics for this thread. Null until the thread's first status transition. |
status | string | Current execution status of the thread. (running, idle, rescheduling, terminated) |
type | string | (session_thread) |
updated_at | string (date-time) | When the thread was last updated. |
usage | object | Cumulative token usage for this thread. Null until the thread's first idle transition. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | session_id, thread_id | ||
list | select | session_id | ||
archive | exec | session_id, thread_id |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
session_id | string | Path parameter session_id (example: sesn_011CZkZAtmR3yMPDzynEDxu7) |
thread_id | string | Path parameter thread_id (example: sthr_011CZkZVWa6oIjw0rgXZpnBt) |
SELECT examples
- get
- list
Successful response (OK)
SELECT
id,
parent_thread_id,
session_id,
agent,
archived_at,
created_at,
stats,
status,
type,
updated_at,
usage
FROM anthropic.sessions.threads
WHERE session_id = '{{ session_id }}' -- required
AND thread_id = '{{ thread_id }}' -- required
;
Successful response (OK)
SELECT
id,
parent_thread_id,
session_id,
agent,
archived_at,
created_at,
stats,
status,
type,
updated_at,
usage
FROM anthropic.sessions.threads
WHERE session_id = '{{ session_id }}' -- required
;
Lifecycle Methods
- archive
Successful response (OK)
EXEC anthropic.sessions.threads.archive
@session_id='{{ session_id }}' --required,
@thread_id='{{ thread_id }}' --required
;