Overview
The/beta/sessions API is the durable, server-side contract for managed agent runs. A session represents a long-lived conversation thread or task run between a user and an agent. It tracks message history as immutable events, enforces execution budgets (tokens, turns, tool calls), supports child threads via parent_thread_id, and can carry session-scoped files and credentials.
Sessions are scoped to the authenticated user. Accessing another user’s session returns 404 Not Found so existence is never leaked.
Base URL
All beta session endpoints are mounted under:Authorization header. See Authentication for details.
The session object
Budget and truncation strategies
Budgets are optional limits enforced when events are appended.
When
context_window is set and projected usage crosses 80%, a context_warning event is emitted. When a hard max_* limit is exceeded, the append is rejected and a budget_exceeded event is recorded.
Endpoints
List sessions
Query parameters
Response
Create a session
Request body
Response
Get a session
Response
Update a session
Request body
At least one field must be provided.Response
Archive a session
Archiving setsstatus to archived, sets archived_at, and prevents new events from being appended or the session from being interrupted.
Response
Append an event
Events are the immutable audit trail of a session. Only a subset of event types may be appended by callers.Request body
Response
accepted is false and the returned event has type budget_exceeded:
List events
Response
Stream events (SSE)
Open a long-lived Server-Sent Events stream. Each event corresponds to one row inbeta_session_events.
after=<sequence> resumes the stream after a known sequence number.
Stream format
Stream events (WebSocket)
The WebSocket endpoint delivers the same events as SSE and is useful when you need bidirectional control, such as sending an interrupt.after query parameter to resume from a known sequence.
Search session memory
Performs a simple substring search across the most recent 200 events.Response
Interrupt a session
Emit auser_interrupt event into an active session. The payload must be an object.
Response
Edit context
Delete or summarize ranges of events to manage the context window. This mutates event history and reducestokens_used.
Operation object
Response
Session resources
Resources attach credentials or references to a session. Values are encrypted at rest; references point to an external vault or secret store.Supported resource kinds
Attach a resource
value or ref must be provided, but not both.
Response
List resources
Delete a resource
204 No Content on success.
Session files
Upload and retrieve binary files scoped to a session. Files are stored on the server’s localdata_dir/session-files and returned as base64.
Upload a file
Response
List files
Get a file
Delete a file
204 No Content.