Claude Platform Docs

Sessions

Créer une session
client.Beta.Sessions.New(ctx, params) (*BetaManagedAgentsSession, error)
POST/v1/sessions
Lister les sessions
client.Beta.Sessions.List(ctx, params) (*BidirectionalPageCursor[BetaManagedAgentsSession], error)
GET/v1/sessions
Obtenir une session
client.Beta.Sessions.Get(ctx, sessionID, query) (*BetaManagedAgentsSession, error)
GET/v1/sessions/{session_id}
Mettre à jour une session
client.Beta.Sessions.Update(ctx, sessionID, params) (*BetaManagedAgentsSession, error)
POST/v1/sessions/{session_id}
Supprimer une session
client.Beta.Sessions.Delete(ctx, sessionID, body) (*BetaManagedAgentsDeletedSession, error)
DELETE/v1/sessions/{session_id}
Archiver une session
client.Beta.Sessions.Archive(ctx, sessionID, body) (*BetaManagedAgentsSession, error)
POST/v1/sessions/{session_id}/archive
Models
type BetaManagedAgentsAdvisorParams struct { Type: "advisor"; Model }

Platform advisor roster entry: a model the session's primary thread may consult mid-turn. At most one per roster; the entry occupies the roster name anthropic.advisor.

Type BetaManagedAgentsAdvisorParamsType
Model string

A Claude model id. The model must be permitted as an advisor for this agent's model.

minLength1
maxLength256
type BetaManagedAgentsAgentMessagePreview struct { Type: "agent.message"; ID }
Type BetaManagedAgentsAgentMessagePreviewType
ID string

The id the buffered agent.message will carry if it is emitted. Matches the event_id on this preview's event_delta events.

type BetaManagedAgentsAgentParams struct { Type: "agent"; ID; Version }

Specification for an Agent. Provide a specific version or use the short-form agent="agent_id" for the most recent version

Type BetaManagedAgentsAgentParamsType
ID string

The agent ID.

minLength1
maxLength128
Version int64 Optional

The specific agent version to use. Omit to use the latest version. Must be at least 1 if specified.

formatint32
type BetaManagedAgentsAgentThinkingPreview struct { Type: "agent.thinking"; ID }
Type BetaManagedAgentsAgentThinkingPreviewType
ID string

The id the buffered agent.thinking will carry if it is emitted. Start-only — no event_delta events follow.

type BetaManagedAgentsAgentWithOverridesParams struct { Type: "agent_with_overrides"; ID; MCPServers; /* 5 more */ }

Reference to an agent plus optional configuration overrides. Each provided field replaces the agent's value for the caller's use; the agent resource is unchanged.

type BetaManagedAgentsBranchCheckout struct { Type: "branch"; Name }
Type BetaManagedAgentsBranchCheckoutType
Name string

Branch name to check out.

minLength1
maxLength255
type BetaManagedAgentsBudgetLimit struct { Type: "limit"; MaxListCost }

A hard spend ceiling. The session stops issuing new model requests once the tracked list cost reaches max_list_cost.

Type BetaManagedAgentsBudgetLimitType
MaxListCost BetaMonetaryAmount

Maximum list cost the session may accrue. List price is used regardless of any negotiated discount, so the cap fires at or before the actual charge.

Amount string

Amount in minor units of the currency, as an integer decimal string with no leading zeros: "2500" is $25.00 and "50" is fifty cents. A string rather than a number so no float rounding is ever applied.

Currency BetaCurrency

Uppercase ISO-4217 currency code. USD is the only currency currently supported; the accepted set is closed and grows only when a new currency is priced.

type BetaManagedAgentsCacheCreationUsage struct { Ephemeral1hInputTokens; Ephemeral5mInputTokens }

Prompt-cache creation token usage broken down by cache lifetime.

Ephemeral1hInputTokens int64 Optional

Tokens used to create 1-hour ephemeral cache entries.

formatint32
Ephemeral5mInputTokens int64 Optional

Tokens used to create 5-minute ephemeral cache entries.

formatint32
type BetaManagedAgentsCommitCheckout struct { Type: "commit"; Sha }
Type BetaManagedAgentsCommitCheckoutType
Sha string

Full commit SHA to check out.

minLength7
maxLength64
type BetaManagedAgentsDeletedSession struct { Type: "session_deleted"; ID }

Confirmation that a session has been permanently deleted.

Type BetaManagedAgentsDeletedSessionType
ID string
type BetaManagedAgentsDeltaContent struct { Type: "content_delta"; Content; Index }
Type BetaManagedAgentsDeltaContentType

A partial element of the content array at index, typed like the element itself — the same shape the buffered agent.message carries in content.

Type BetaManagedAgentsTextBlockType
Text string

The text content.

minLength1
Index int64 Optional

Which entry in the previewed event's content array this fragment lands in. Insert content as that entry when the index is new; append to the existing entry otherwise.

type BetaManagedAgentsDeltaEvent struct { Type: "event_delta"; Delta; EventID }

An incremental update to an event that is still being streamed. Deltas are best-effort and may stop early; when the buffered event with id == event_id is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no buffered event — its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.

Type BetaManagedAgentsDeltaEventType

One fragment of the previewed event. The delta type is named for the previewed event's field it streams into: agent.message events stream content_delta fragments, each a partial element of the content array.

Type BetaManagedAgentsDeltaContentType

A partial element of the content array at index, typed like the element itself — the same shape the buffered agent.message carries in content.

Type BetaManagedAgentsTextBlockType
Text string

The text content.

minLength1
Index int64 Optional

Which entry in the previewed event's content array this fragment lands in. Insert content as that entry when the index is new; append to the existing entry otherwise.

EventID string

The id of the event being previewed. Matches event.id on the corresponding event_start and the buffered event that reconciles the preview.

type BetaManagedAgentsDeltaType string
One of the following:
const BetaManagedAgentsDeltaTypeAgentMessage BetaManagedAgentsDeltaType = "agent.message"
const BetaManagedAgentsDeltaTypeAgentThinking BetaManagedAgentsDeltaType = "agent.thinking"
type BetaManagedAgentsFileResourceParams struct { Type: "file"; FileID; MountPath }

Mount a file uploaded via the Files API into the session.

Type BetaManagedAgentsFileResourceParamsType
FileID string

ID of a previously uploaded file.

minLength1
maxLength128
MountPath string Optional

Mount path in the container. Defaults to /mnt/session/uploads/<file_id>.

minLength1
maxLength4096
type BetaManagedAgentsGitHubRepositoryResourceParams struct { Type: "github_repository"; URL; AuthorizationToken; /* 2 more */ }

Mount a GitHub repository into the session's container.

type BetaManagedAgentsMemoryStoreResourceParam struct { Type: "memory_store"; MemoryStoreID; Access; Instructions }

Parameters for attaching a memory store to an agent session.

Type BetaManagedAgentsMemoryStoreResourceParamType
MemoryStoreID string

The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

Access BetaManagedAgentsMemoryStoreResourceParamAccess Optional

Access mode for the mounted store. Defaults to read_write. read_only mounts the store as a read-only filesystem.

One of the following:
const BetaManagedAgentsMemoryStoreResourceParamAccessReadWrite BetaManagedAgentsMemoryStoreResourceParamAccess = "read_write"
const BetaManagedAgentsMemoryStoreResourceParamAccessReadOnly BetaManagedAgentsMemoryStoreResourceParamAccess = "read_only"
Instructions string Optional

Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

maxLength4096
type BetaManagedAgentsMultiagentUnion interface{…}

Resolved multiagent orchestration configuration as returned in API responses.

One of the following:
type BetaManagedAgentsMultiagentParamsUnion interface{…}

Multiagent orchestration configuration.

One of the following:
type BetaManagedAgentsMultiagentCoordinatorParams struct { Type: "coordinator"; Agents }

A coordinator topology: the session's primary thread orchestrates work by spawning session threads, each running an agent drawn from the agents roster.

type BetaManagedAgentsMultiagent20261001Params struct { Type: "multiagent_20261001"; Advisor; Subagents; Workflows }

Multiagent configuration with three members, each enabled or disabled on its own. On an update, if the agent's stored multiagent also has type multiagent_20261001, this configuration is merged into the stored one, level by level, instead of replacing it. A key that the update omits keeps its stored value. A key sent as null takes its default, on create as well, so "workflows": null enables workflows. An object sent with a type other than the stored one replaces the stored object, and the keys that it omits take their defaults. A predefined_agents list that is sent replaces the stored list. Every object that is sent needs its type, and an enabled advisor needs its model. Other validation applies to the merged result.

type BetaManagedAgentsMultiagentRosterEntryParamsUnion interface{…}

An entry in a multiagent roster: an agent ID string, a versioned agent reference, or self.

One of the following:
string
type BetaManagedAgentsAgentParams struct { Type: "agent"; ID; Version }

Specification for an Agent. Provide a specific version or use the short-form agent="agent_id" for the most recent version

Type BetaManagedAgentsAgentParamsType
ID string

The agent ID.

minLength1
maxLength128
Version int64 Optional

The specific agent version to use. Omit to use the latest version. Must be at least 1 if specified.

formatint32
type BetaManagedAgentsMultiagentSelfParams struct { Type: "self" }

Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

Type BetaManagedAgentsMultiagentSelfParamsType
type BetaManagedAgentsAdvisorParams struct { Type: "advisor"; Model }

Platform advisor roster entry: a model the session's primary thread may consult mid-turn. At most one per roster; the entry occupies the roster name anthropic.advisor.

Type BetaManagedAgentsAdvisorParamsType
Model string

A Claude model id. The model must be permitted as an advisor for this agent's model.

minLength1
maxLength256
type BetaManagedAgentsOutcomeEvaluationResource struct { Type: "outcome_evaluation"; CompletedAt; Description; /* 4 more */ }

Evaluation state for a single outcome defined via a define_outcome event.

Type BetaManagedAgentsOutcomeEvaluationResourceType
CompletedAt Time

When the outcome reached a terminal result. Null while pending/running/evaluating.

formatdate-time
Description string

What the agent should produce.

Explanation string

Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

Iteration int64

0-indexed revision cycle the outcome is currently on.

formatint32
OutcomeID string

Server-generated outc_ ID for this outcome.

Result string

Current evaluation state. pending before the agent begins work; running while producing or revising; evaluating while the grader scores; satisfied/max_iterations_reached/failed/interrupted are terminal.

type BetaManagedAgentsServerToolUsage struct { WebFetchRequests; WebSearchRequests }

Cumulative count of server-executed tool invocations, broken down by tool.

WebFetchRequests int64 Optional

Number of server-executed web fetch requests.

formatint32
WebSearchRequests int64 Optional

Number of server-executed web search requests.

formatint32
type BetaManagedAgentsSession struct { Type: "session"; ID; Agent; /* 14 more */ }

A Managed Agents session.

type BetaManagedAgentsSessionAgent struct { Type: "agent"; ID; Description; /* 9 more */ }

Resolved agent definition for a session. Snapshot of the agent at session creation time.

type BetaManagedAgentsSessionAgentUpdateParam struct { MCPServers; Tools }

Mid-session agent configuration update. Only tools and mcp_servers are updatable. Full replacement: the provided array becomes the new value. To preserve existing entries, GET the session, modify the array, and POST it back.

type BetaManagedAgentsSessionMultiagentUnion interface{…}

Resolved multiagent orchestration configuration as returned on a session.

One of the following:
type BetaManagedAgentsSessionMultiagentCoordinator struct { Type: "coordinator"; Agents }

Resolved coordinator topology with full agent definitions for each roster member.

Type BetaManagedAgentsSessionMultiagentCoordinatorType
Agents []BetaManagedAgentsSessionMultiagentCoordinatorAgentUnion

Full agent definitions the coordinator may spawn as session threads.

One of the following:
type BetaManagedAgentsSessionThreadAgent struct { Type: "agent"; ID; Description; /* 8 more */ }

Resolved agent definition for a single session_thread. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from Session.agent.

type BetaManagedAgentsAdvisor struct { Type: "advisor"; Model }

Platform advisor roster entry: a model the session's primary thread may consult mid-turn.

Type BetaManagedAgentsAdvisorType
Model string

The advisor model id.

type BetaManagedAgentsSessionMultiagentSubagentsUnion interface{…}

Whether the agent can spawn session threads.

One of the following:
type BetaManagedAgentsSessionMultiagentSubagentsEnabled struct { Type: "enabled"; InlineAgents; PredefinedAgents }

The agent can spawn session threads.

type BetaManagedAgentsMultiagentSubagentsDisabled struct { Type: "disabled" }

The agent cannot spawn session threads.

Type Disabled
type BetaManagedAgentsSessionMultiagentSubagentsEnabled struct { Type: "enabled"; InlineAgents; PredefinedAgents }

The agent can spawn session threads.

type BetaManagedAgentsSessionMultiagentWorkflowsUnion interface{…}

Whether the agent can start workflow runs.

One of the following:
type BetaManagedAgentsSessionMultiagentWorkflowsEnabled struct { Type: "enabled"; InlineAgents; PredefinedAgents }

The agent can start workflow runs.

type BetaManagedAgentsMultiagentWorkflowsDisabled struct { Type: "disabled" }

The agent cannot start workflow runs.

Type Disabled
type BetaManagedAgentsSessionMultiagentWorkflowsEnabled struct { Type: "enabled"; InlineAgents; PredefinedAgents }

The agent can start workflow runs.

type BetaManagedAgentsSessionMultiagent20261001 struct { Type: "multiagent_20261001"; Advisor; Subagents; Workflows }

Resolved multiagent configuration with three members, as copied to the session at creation.

type BetaManagedAgentsSessionStats struct { ActiveSeconds; DurationSeconds }

Timing statistics for a session.

ActiveSeconds float64 Optional

Cumulative time in seconds the session spent in running status. Excludes idle time.

formatdouble
DurationSeconds float64 Optional

Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

formatdouble
type BetaManagedAgentsSessionUpdatedEvent struct { Type: "session.updated"; ID; ProcessedAt; /* 4 more */ }

Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

type BetaManagedAgentsSessionUsage struct { ActiveSeconds; CacheCreation; CacheReadInputTokens; /* 4 more */ }

Cumulative token usage for a session across all turns.

type BetaManagedAgentsSessionUsageEvent struct { Type: "session.usage"; ID; ProcessedAt; /* 2 more */ }

Periodic snapshot of the session's cumulative usage and tracked list cost.

Type BetaManagedAgentsSessionUsageEventType
ID string

Unique identifier for this event.

ProcessedAt Time

Timestamp when the snapshot was taken.

formatdate-time

The session's cumulative usage at the snapshot time.

Budget BetaManagedAgentsBudgetLimit Optional

The session's configured budget at the snapshot time, or null when the session has no budget.

Type BetaManagedAgentsBudgetLimitType
MaxListCost BetaMonetaryAmount

Maximum list cost the session may accrue. List price is used regardless of any negotiated discount, so the cap fires at or before the actual charge.

Amount string

Amount in minor units of the currency, as an integer decimal string with no leading zeros: "2500" is $25.00 and "50" is fifty cents. A string rather than a number so no float rounding is ever applied.

Currency BetaCurrency

Uppercase ISO-4217 currency code. USD is the only currency currently supported; the accepted set is closed and grows only when a new currency is priced.

type BetaManagedAgentsStartEvent struct { Type: "event_start"; Event }

Opens a preview of a buffered event. Carries the previewed event's type and id only. Followed by zero or more event_delta events with the same event id, normally concluded by the buffered event carrying that id. If the producing model request ends without that event (an error or interrupt mid-stream), its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.

Type BetaManagedAgentsStartEventType

The previewed event's type and id. The event type determines which delta types the preview's event_delta events carry: agent.message events stream content_delta fragments; agent.thinking previews are start-only — no deltas follow, and the buffered agent.thinking with the same id concludes them.

One of the following:
type BetaManagedAgentsAgentMessagePreview struct { Type: "agent.message"; ID }
Type BetaManagedAgentsAgentMessagePreviewType
ID string

The id the buffered agent.message will carry if it is emitted. Matches the event_id on this preview's event_delta events.

type BetaManagedAgentsAgentThinkingPreview struct { Type: "agent.thinking"; ID }
Type BetaManagedAgentsAgentThinkingPreviewType
ID string

The id the buffered agent.thinking will carry if it is emitted. Start-only — no event_delta events follow.

type BetaManagedAgentsStartEventPreviewUnion interface{…}
One of the following:
type BetaManagedAgentsAgentMessagePreview struct { Type: "agent.message"; ID }
Type BetaManagedAgentsAgentMessagePreviewType
ID string

The id the buffered agent.message will carry if it is emitted. Matches the event_id on this preview's event_delta events.

type BetaManagedAgentsAgentThinkingPreview struct { Type: "agent.thinking"; ID }
Type BetaManagedAgentsAgentThinkingPreviewType
ID string

The id the buffered agent.thinking will carry if it is emitted. Start-only — no event_delta events follow.

type BetaManagedAgentsSystemContentBlock struct { Type: "text"; Text }

Content block in a mid-conversation system message. Text-only.

Type BetaManagedAgentsSystemContentBlockType
Text string

The text content.

minLength1
type BetaManagedAgentsSystemMessageEvent struct { Type: "system.message"; ID; Content; ProcessedAt }

A mid-conversation system message event. Carries system-role content that is appended to the session as a role: "system" turn.

Type BetaManagedAgentsSystemMessageEventType
ID string

Unique identifier for this event.

System content blocks. Text-only.

Type BetaManagedAgentsSystemContentBlockType
Text string

The text content.

minLength1
ProcessedAt Time Optional

Timestamp when this system message was processed.

formatdate-time
type BetaManagedAgentsUserToolResultEvent struct { Type: "user.tool_result"; ID; ToolUseID; /* 4 more */ }

Event sent by the client providing the result of an agent-toolset tool execution. Only valid on self_hosted environments, where sandbox-routed tools are executed by the client rather than the server.

SessionsÉvénements

Lister les événements
client.Beta.Sessions.Events.List(ctx, sessionID, params) (*PageCursor[BetaManagedAgentsSessionEventUnion], error)
GET/v1/sessions/{session_id}/events
Envoyer des événements
client.Beta.Sessions.Events.Send(ctx, sessionID, params) (*BetaManagedAgentsSendSessionEvents, error)
POST/v1/sessions/{session_id}/events
Diffuser les événements en streaming
client.Beta.Sessions.Events.StreamEvents(ctx, sessionID, params) *ssestream.Stream[BetaManagedAgentsStreamSessionEventsUnion]
GET/v1/sessions/{session_id}/events/stream

SessionsRessources

Ajouter une ressource de session
client.Beta.Sessions.Resources.Add(ctx, sessionID, params) (*BetaManagedAgentsFileResource, error)
POST/v1/sessions/{session_id}/resources
Lister les ressources de session
client.Beta.Sessions.Resources.List(ctx, sessionID, params) (*PageCursor[BetaManagedAgentsSessionResourceUnion], error)
GET/v1/sessions/{session_id}/resources
Obtenir une ressource de session
client.Beta.Sessions.Resources.Get(ctx, resourceID, params) (*BetaSessionResourceGetResponseUnion, error)
GET/v1/sessions/{session_id}/resources/{resource_id}
Mettre à jour une ressource de session
client.Beta.Sessions.Resources.Update(ctx, resourceID, params) (*BetaSessionResourceUpdateResponseUnion, error)
POST/v1/sessions/{session_id}/resources/{resource_id}
Supprimer une ressource de session
client.Beta.Sessions.Resources.Delete(ctx, resourceID, params) (*BetaManagedAgentsDeleteSessionResource, error)
DELETE/v1/sessions/{session_id}/resources/{resource_id}

SessionsFils

Lister les fils de session
client.Beta.Sessions.Threads.List(ctx, sessionID, params) (*PageCursor[BetaManagedAgentsSessionThread], error)
GET/v1/sessions/{session_id}/threads
Obtenir un fil de session
client.Beta.Sessions.Threads.Get(ctx, threadID, params) (*BetaManagedAgentsSessionThread, error)
GET/v1/sessions/{session_id}/threads/{thread_id}
Archiver un fil de session
client.Beta.Sessions.Threads.Archive(ctx, threadID, params) (*BetaManagedAgentsSessionThread, error)
POST/v1/sessions/{session_id}/threads/{thread_id}/archive

SessionsFilsÉvénements

Lister les événements d'un fil de session
client.Beta.Sessions.Threads.Events.List(ctx, threadID, params) (*PageCursor[BetaManagedAgentsSessionEventUnion], error)
GET/v1/sessions/{session_id}/threads/{thread_id}/events
Diffuser en streaming les événements d'un fil de session
client.Beta.Sessions.Threads.Events.StreamEvents(ctx, threadID, params) *ssestream.Stream[BetaManagedAgentsStreamSessionThreadEventsUnion]
GET/v1/sessions/{session_id}/threads/{thread_id}/stream