Class: Anthropic::Resources::Beta::Sessions::Threads

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/resources/beta/sessions/threads.rb,
lib/anthropic/resources/beta/sessions/threads/events.rb,
sig/anthropic/resources/beta/sessions/threads.rbs,
sig/anthropic/resources/beta/sessions/threads/events.rbs

Defined Under Namespace

Classes: Events

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Threads

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Threads.

Parameters:



145
146
147
148
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 145

def initialize(client:)
  @client = client
  @events = Anthropic::Resources::Beta::Sessions::Threads::Events.new(client: client)
end

Instance Attribute Details

#events ⇒ Anthropic::Resources::Beta::Sessions::Threads::Events (readonly)



9
10
11
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 9

def events
  @events
end

Instance Method Details

#archive(thread_id, session_id:, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Sessions::BetaManagedAgentsSessionThread

Archive Session Thread

Some parameter documentations has been truncated, see Models::Beta::Sessions::ThreadArchiveParams for more details.

Parameters:

  • thread_id (String) —

    Path param

  • session_id (String) —

    Path param

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Header param: This endpoint is in beta: requests must send

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • session_id: (String)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • workspace_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 120

def archive(thread_id, params)
  parsed, options = Anthropic::Beta::Sessions::ThreadArchiveParams.dump_request(params)
  session_id =
    parsed.delete(:session_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::SESSIONS_THREADS_ARCHIVE,
    span_attributes: {
      "anthropic.session.id" => session_id,
      "anthropic.session.thread.id" => thread_id
    },
    span_route: "/v1/sessions/{session_id}/threads/{thread_id}/archive",
    method: :post,
    path: ["v1/sessions/%1$s/threads/%2$s/archive", session_id, thread_id],
    headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"),
    model: Anthropic::Beta::Sessions::BetaManagedAgentsSessionThread,
    options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **options}
  )
end

#list(session_id, limit: nil, page: nil, statuses: nil, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::Beta::Sessions::BetaManagedAgentsSessionThread>

List Session Threads

Some parameter documentations has been truncated, see Models::Beta::Sessions::ThreadListParams for more details.

Parameters:

  • session_id (String) —

    Path param

  • limit (Integer) —

    Query param: Maximum results per page. Defaults to 1000.

  • page (String) —

    Query param: Opaque pagination cursor from a previous response's next_page. Fo

  • statuses (Array<Symbol, Anthropic::Models::Beta::Sessions::BetaManagedAgentsSessionThreadStatus>) —

    Query param: Return only threads that have one of these statuses.

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Header param: This endpoint is in beta: requests must send

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • limit: (Integer)
  • page: (String)
  • statuses: (::Array[Anthropic::Models::Beta::Sessions::beta_managed_agents_session_thread_status])
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • workspace_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 77

def list(session_id, params = {})
  query_params = [:limit, :page, :statuses]
  parsed, options = Anthropic::Beta::Sessions::ThreadListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::SESSIONS_THREADS_LIST,
    span_attributes: {"anthropic.session.id" => session_id},
    span_route: "/v1/sessions/{session_id}/threads",
    span_query: %w[limit page statuses],
    method: :get,
    path: ["v1/sessions/%1$s/threads", session_id],
    query: query,
    headers: parsed.except(*query_params).transform_keys(
      betas: "anthropic-beta",
      workspace_id: "anthropic-workspace-id"
    ),
    page: Anthropic::Internal::PageCursor,
    model: Anthropic::Beta::Sessions::BetaManagedAgentsSessionThread,
    options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **options}
  )
end

#retrieve(thread_id, session_id:, betas: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::Beta::Sessions::BetaManagedAgentsSessionThread

Get Session Thread

Some parameter documentations has been truncated, see Models::Beta::Sessions::ThreadRetrieveParams for more details.

Parameters:

  • thread_id (String) —

    Path param

  • session_id (String) —

    Path param

  • betas (Array<Symbol, String, Anthropic::Models::AnthropicBeta>) —

    Header param: This endpoint is in beta: requests must send

  • workspace_id (String) —

    Header param: Optional header to select the Workspace for this request. The valu

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)
  • session_id: (String)
  • betas: (::Array[Anthropic::Models::anthropic_beta])
  • workspace_id: (String)
  • request_options: (Anthropic::request_opts)

Returns:

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 31

def retrieve(thread_id, params)
  parsed, options = Anthropic::Beta::Sessions::ThreadRetrieveParams.dump_request(params)
  session_id =
    parsed.delete(:session_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    qualifiers: {beta: "true"},
    span_name: Anthropic::Internal::Tracing::SpanName::SESSIONS_THREADS_RETRIEVE,
    span_attributes: {
      "anthropic.session.id" => session_id,
      "anthropic.session.thread.id" => thread_id
    },
    span_route: "/v1/sessions/{session_id}/threads/{thread_id}",
    method: :get,
    path: ["v1/sessions/%1$s/threads/%2$s", session_id, thread_id],
    headers: parsed.transform_keys(betas: "anthropic-beta", workspace_id: "anthropic-workspace-id"),
    model: Anthropic::Beta::Sessions::BetaManagedAgentsSessionThread,
    options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **options}
  )
end