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

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:



109
110
111
112
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 109

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

Instance Attribute Details

#eventsAnthropic::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, request_options: {}) ⇒ Anthropic::Models::Beta::Sessions::BetaManagedAgentsSessionThread

Archive Session Thread

Parameters:

  • thread_id (String)

    Path param: Path parameter thread_id

  • session_id (String)

    Path param: Path parameter session_id

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

    Header param: Optional header to specify the beta version(s) you want to use.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 91

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(
    method: :post,
    path: ["v1/sessions/%1$s/threads/%2$s/archive?beta=true", session_id, thread_id],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::Sessions::BetaManagedAgentsSessionThread,
    options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **options}
  )
end

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

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

List Session Threads

Parameters:

  • session_id (String)

    Path param: Path parameter session_id

  • 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. Forw

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

    Header param: Optional header to specify the beta version(s) you want to use.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 61

def list(session_id, params = {})
  query_params = [:limit, :page]
  parsed, options = Anthropic::Beta::Sessions::ThreadListParams.dump_request(params)
  query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["v1/sessions/%1$s/threads?beta=true", session_id],
    query: query,
    headers: parsed.except(*query_params).transform_keys(betas: "anthropic-beta"),
    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, request_options: {}) ⇒ Anthropic::Models::Beta::Sessions::BetaManagedAgentsSessionThread

Get Session Thread

Parameters:

  • thread_id (String)

    Path param: Path parameter thread_id

  • session_id (String)

    Path param: Path parameter session_id

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

    Header param: Optional header to specify the beta version(s) you want to use.

  • request_options (Anthropic::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/anthropic/resources/beta/sessions/threads.rb', line 26

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(
    method: :get,
    path: ["v1/sessions/%1$s/threads/%2$s?beta=true", session_id, thread_id],
    headers: parsed.transform_keys(betas: "anthropic-beta"),
    model: Anthropic::Beta::Sessions::BetaManagedAgentsSessionThread,
    options: {extra_headers: {"anthropic-beta" => "managed-agents-2026-04-01"}, **options}
  )
end