Agent session ID (ase_...) of the session to cancel.
The agent session after the cancellation request is applied.
Create an agent session
Creates a new agent session and enqueues it for execution. The session begins
in "pending" status and transitions to "running" once the platform picks
it up. Subscribe to the session stream endpoint to receive real-time status
updates.
You must supply the ID of an agent that the authenticated app owns and a
plain-text instructions string describing the task. All other parameters
are optional and default to the agent's configured limits when omitted.
Set start_idle to true to create the session without running an opening
turn — it begins in "waiting" status and runs its first turn only once you
post a message (see the message endpoint). Use this when you want the first
message to drive the session instead of the instructions alone.
Requires an app-scoped API key. Returns HTTP 201 on success.
Request body.
Agent ID (agi_...) of the agent that will execute the session.
Plain-text task description given to the agent as its primary objective for this session.
Optionalmax_runs_per_turn?: numberMaximum number of tool invocations allowed within a single agent turn. Defaults to 25.
Optionalmax_tokens?: numberMaximum number of tokens the agent may consume across all turns. Defaults to 20,000.
Optionalmax_turns?: numberMaximum number of agent turns before the session is automatically terminated. Defaults to 100.
Optionalmetadata?: Record<string, unknown>Arbitrary key-value metadata to attach to the session. Stored and returned as-is; not interpreted by the platform.
Optionalname?: stringHuman-readable display name for the session. Useful for identifying sessions in the dashboard. null if omitted.
Optionalstart_idle?: booleanWhen true, create the session without running an opening turn. The session starts in "waiting" status and runs its first turn only when you post a message. Defaults to false, which runs an initial turn from instructions immediately.
Optionalteam?: stringTeam ID (tea_...) to associate with this session for access-control and attribution purposes. null if omitted.
Optionalthread?: stringThread ID (thr_...) to link this session to an existing conversation thread. null if omitted.
Optionaluser?: stringUser ID to associate with this session for attribution purposes. null if omitted.
The newly created agent session.
Delete an agent session
Permanently deletes an agent session and its associated data. This action is
irreversible — the session record, its trajectory, and all inbox messages are
removed.
To stop a running session without deleting it, use the cancel endpoint
instead. The session must be in a terminal state ("completed", "failed",
or "cancelled") before it can be deleted; attempting to delete an active
session returns 422.
Requires an app-scoped API key. Returns HTTP 204 with no body on success.
Agent session ID (ase_...) of the session to delete.
Empty body. HTTP 204 indicates the session was permanently deleted.
Retrieve an agent session
Returns the agent session identified by agent_session. Use this endpoint
to poll session status or to inspect the final result after execution
completes.
For real-time updates without polling, subscribe to the session stream
endpoint instead, which delivers server-sent events whenever the session
state changes.
Requires an app-scoped API key. The session must belong to an agent owned
by the authenticated app.
Agent session ID (ase_...) of the session to retrieve.
The requested agent session.
List agent sessions
Returns a flat list of agent sessions visible to the authenticated app,
ordered by creation time descending. Use the agent, status, and
routine_run filters to narrow results.
All filters are optional and can be combined. The status and routine_run
parameters each accept multiple values; pass the parameter more than once or
as a comma-separated array to match any of the supplied values.
Requires an app-scoped API key. Results are limited to sessions that belong
to agents owned by the authenticated app.
Optionalparams: {Query parameters.
Optionalagent?: stringFilter by agent ID (agi_...). Omit to return sessions for all agents in the app.
OptionalexcludeSystem?: booleanWhen true, omits sessions that were created automatically by the platform rather than by your app. Defaults to false.
Optionallimit?: numberMaximum number of sessions to return. Defaults to 25; maximum is 100.
OptionalroutineRun?: string[]Filter to sessions that were created by the specified routine run IDs. Accepts up to 100 IDs. Omit to return sessions regardless of their originating routine run.
Optionalstatus?: string[]Filter by one or more session statuses. Accepted values are "pending", "running", "waiting", "completed", "failed", and "cancelled". Omit to return sessions in any status.
A list of agent sessions matching the supplied filters.
Send a message to an agent session
Appends a message to the inbox of the specified agent session. The agent
reads inbox messages at the start of each turn; sending a message to a
"waiting" session signals it to resume execution.
Use role to identify the sender type. The default role is "user".
Arbitrary key-value metadata may be attached to the message for tracking
or display purposes.
Requires an app-scoped API key. The session must belong to an agent owned
by the authenticated app.
Agent session ID (ase_...) of the session whose inbox should receive the message.
Request body.
Plain-text body of the message to deliver to the agent.
Optionalmetadata?: Record<string, unknown>Arbitrary key-value metadata to attach to the message. Stored and returned as-is; not interpreted by the platform.
Optionalrole?: stringRole of the message sender. Typically "user" or "tool". Defaults to "user".
The agent session with the new message appended to its inbox.
Update an agent session
Updates the mutable fields of an agent session. Currently only metadata
can be changed; supply any key-value pairs you want to store alongside the
session. Omitting metadata leaves it unchanged.
This endpoint may be called while the session is in any status, including
while it is actively running.
Requires an app-scoped API key. The session must belong to an agent owned
by the authenticated app.
Agent session ID (ase_...) of the session to update.
Request body.
Optionalmetadata?: Record<string, unknown>Arbitrary key-value metadata to attach to the session. Replaces the existing metadata map entirely. Omit to leave the current metadata unchanged.
The agent session with the updated fields applied.
Cancel an agent session Requests cancellation of an active agent session. The session status is set to
"cancelled"and any in-progress agent turn is interrupted as soon as the platform can safely stop it. If the session is already in a terminal state ("completed","failed", or"cancelled"), the call succeeds and returns the session unchanged — it is safe to call this endpoint more than once. Requires an app-scoped API key. The session must belong to an agent owned by the authenticated app.