Skip to main content

threads

Creates, updates, deletes, gets or lists a threads resource.

Overview

Namethreads
TypeResource
Idanthropic.sessions.threads

Fields

The following fields are returned by SELECT queries:

Successful response (OK)

NameDatatypeDescription
idstringUnique identifier for this thread.
parent_thread_idstringParent thread that spawned this thread. Null for the primary thread.
session_idstringThe session this thread belongs to.
agentobjectResolved agent definition for this thread. Snapshot of the agent at thread creation time.
archived_atstring (date-time)When the thread was archived. Null if not archived.
created_atstring (date-time)When the thread was created.
statsobjectTiming statistics for this thread. Null until the thread's first status transition.
statusstringCurrent execution status of the thread. (running, idle, rescheduling, terminated)
typestring (session_thread)
updated_atstring (date-time)When the thread was last updated.
usageobjectCumulative token usage for this thread. Null until the thread's first idle transition.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectsession_id, thread_id
listselectsession_id
archiveexecsession_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.

NameDatatypeDescription
session_idstringPath parameter session_id (example: sesn_011CZkZAtmR3yMPDzynEDxu7)
thread_idstringPath parameter thread_id (example: sthr_011CZkZVWa6oIjw0rgXZpnBt)

SELECT examples

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
;

Lifecycle Methods

Successful response (OK)

EXEC anthropic.sessions.threads.archive
@session_id='{{ session_id }}' --required,
@thread_id='{{ thread_id }}' --required
;