ReqManagedAgents. Providers. ClaudeManagedAgents. Client
(ReqManagedAgents v0.17.0)
Copy Markdown
View Source
Low-level control-plane HTTP client for Claude Managed Agents (agents, sessions,
events) over Req. The long-lived SSE event stream lives in
ReqManagedAgents.Providers.ClaudeManagedAgents.Stream.
Build one with new/1; pass it as the first argument to every call. All
requests carry the managed-agents-2026-04-01 beta header.
Summary
Functions
Fetch ALL events for a session, paging via the API's opaque next_page cursor
(limit 100/page). Passes the cursor back as the page query param;
stops when next_page is absent/blank, or if a cursor repeats (a guard against
a pathological server). Returns the flat event list.
Lists persisted events for one thread using page / next_page pagination.
Lists session threads using the API's page / next_page pagination.
Build a client. Resolves :api_key from the option, then
Application.get_env(:req_managed_agents, :api_key), then ANTHROPIC_API_KEY.
Alternatively resolve :bearer_token_file from the option, application env or
ANTHROPIC_BEARER_TOKEN_FILE. Alternatively use Anthropic workload identity
federation: :federation_rule_id, :organization_id, optional :service_account_id
and :workspace_id, and an identity token from :identity_token_file or from
:identity_token, a zero-arity function returning {:ok, jwt} | {:error, reason}.
Pass a stable function or a :cache_key (any term): the access-token cache is keyed on it.
Each falls back to application env, then to ANTHROPIC_FEDERATION_RULE_ID,
ANTHROPIC_ORGANIZATION_ID, ANTHROPIC_SERVICE_ACCOUNT_ID, ANTHROPIC_WORKSPACE_ID
and ANTHROPIC_IDENTITY_TOKEN_FILE (:identity_token has no variable).
Select exactly one source; explicit nil disables a source, and a source
set alongside federation settings raises rather than winning silently. Other keys
fall back to application env, then defaults.
Convenience for a single event.
Types
@type t() :: %ReqManagedAgents.Providers.ClaudeManagedAgents.Client{ anthropic_version: String.t(), api_key: String.t() | nil, base_url: String.t(), bearer_token_file: String.t() | nil, beta: String.t(), federation: ReqManagedAgents.Providers.ClaudeManagedAgents.Federation.t() | nil, files_beta: String.t(), profile: atom(), receive_timeout: timeout(), req_options: keyword() }
Functions
Fetch ALL events for a session, paging via the API's opaque next_page cursor
(limit 100/page). Passes the cursor back as the page query param;
stops when next_page is absent/blank, or if a cursor repeats (a guard against
a pathological server). Returns the flat event list.
@spec list_thread_events( t() | ReqManagedAgents.Client.t(), String.t(), String.t(), map() ) :: {:ok, map()} | {:error, term()}
Lists persisted events for one thread using page / next_page pagination.
@spec list_threads(t() | ReqManagedAgents.Client.t(), String.t(), map()) :: {:ok, map()} | {:error, term()}
Lists session threads using the API's page / next_page pagination.
Build a client. Resolves :api_key from the option, then
Application.get_env(:req_managed_agents, :api_key), then ANTHROPIC_API_KEY.
Alternatively resolve :bearer_token_file from the option, application env or
ANTHROPIC_BEARER_TOKEN_FILE. Alternatively use Anthropic workload identity
federation: :federation_rule_id, :organization_id, optional :service_account_id
and :workspace_id, and an identity token from :identity_token_file or from
:identity_token, a zero-arity function returning {:ok, jwt} | {:error, reason}.
Pass a stable function or a :cache_key (any term): the access-token cache is keyed on it.
Each falls back to application env, then to ANTHROPIC_FEDERATION_RULE_ID,
ANTHROPIC_ORGANIZATION_ID, ANTHROPIC_SERVICE_ACCOUNT_ID, ANTHROPIC_WORKSPACE_ID
and ANTHROPIC_IDENTITY_TOKEN_FILE (:identity_token has no variable).
Select exactly one source; explicit nil disables a source, and a source
set alongside federation settings raises rather than winning silently. Other keys
fall back to application env, then defaults.
Convenience for a single event.