List sessions

Updated at:

List sessions in the current workspace with pagination, optionally filtered by agent.

Endpoint

Returns 200 and a list envelope. data is an array of Session objects.

GET/agents/sessions

Query parameters

limitintegerOptional

Number of items per page, default 20, range 1..100; an empty string or a value outside the range returns 400

orderstringOptional

Sort direction, asc or desc, default desc; an invalid value returns 400

afterstringOptional

Resource ID cursor, up to 256 bytes and not blank; the cursor item is excluded

agent_idstringOptional

Agent ID filter, filter by saved or inline agent ID, an explicit empty value is invalid, and duplicates return 400

For the first page, omit after. For later pages, pass the last_id from the previous response. The list is sorted by (created_at, resource ID). Other unknown query parameters such as before are ignored; use order and after for reverse pagination.

A newly created session may not appear in the list immediately. To confirm the latest state, use Retrieve Session. The list does not provide a global snapshot or immediate visibility guarantee.

Request example

curl -sS "$BASE_URL/agents/sessions?limit=20&order=desc&agent_id=agent_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "OpenAI-Beta: agents=v1"
page = client.beta.agents.sessions.list(
    limit=20,
    order="desc",
    agent_id="agent_xxx",
)
for session in page.data:
    print(session.id, session.status)

Response fields

objectstring

List object type, fixed as list

dataarray

Session objects on this page; [] when empty

first_idstring / null

ID of the first item; null for an empty page

last_idstring / null

ID of the last item; null for an empty page; use it for the next after

has_moreboolean

Whether the current scan direction has another page

Session fields

idstring

Session ID; reuse it for follow-up turns

objectstring

Session object type, fixed as agent.session

created_atinteger

Creation time in Unix seconds

last_active_atinteger

Last activity time in Unix seconds; not a version number or lock

statusstring

Session status: idle, in_progress, requires_action, or failed

agentobject

Effective agent snapshot.

Properties

idstring

Agent ID; inline configurations return a session snapshot ID, not a reusable saved agent, and it cannot be retrieved through Agent GET

modelstring

Model ID

instructionsstring / null

Custom instructions

namestring / null

Display name

reasoningobject / null

Reasoning configuration, contains effort and summary

textobject / null

Text output configuration; contains format and verbosity

toolsarray

Tool configuration

multi_agentobject / null

Subagent configuration; contains enabled and max_concurrent_subagents

environmentobject

Safe environment summary; only type for none.

Properties

typestring

Environment type; none or openai_hosted

idstring

Environment ID, omitted when there is no authoritative value

statusstring

Environment status: omitted when there is no authoritative value

environment_template_idstring

Environment template ID, omitted when there is no authoritative value

workspace_directorystring

Workspace directory, omitted when there is no authoritative value

errorstring / null

Environment error description, omitted when there is no authoritative value

desktopobject / null

Desktop settings; contains enabled

capability_directoriesarray<string> / null

Capability discovery directories

networkobject / null

Network policy; contains access and allowed_domains

packagesobject / null

Package lists; contains npm, python, and system

filesarray

Safe environment file metadata

skillsarray

Safe skill metadata

pluginsarray

Plugin information; [] for managed environments

metadataobject

Session metadata; an empty value is {}

vault_idsarray<string>

Vault IDs recorded at creation; this does not mean mounting is complete

required_actionsarray

Function calls that need client handling; [] when empty.

Properties

typestring

Item type, fixed as function_call

turn_idstring

Public turn ID

call_idstring

Function call ID

namestring

Function name

argumentsobject

Parsed call arguments

errorstring / null

Session-level error message, different from a turn's structured error

usageobject / null

Token usage.

Properties

input_tokensinteger

Number of input tokens

input_tokens_detailsobject

Input token details.

Properties

cached_tokensinteger

Number of input tokens that hit the cache

output_tokensinteger

Number of output tokens

output_tokens_detailsobject

Output token details.

Properties

reasoning_tokensinteger

Number of reasoning tokens

total_tokensinteger

Total number of tokens

spend_controlobject

Spend control; returned only when a historical record has a value; creation and update do not accept writes.

Properties

limitinteger

Spending limit in cents

consumedinteger / null

Consumed amount in cents

null when the fields are incomplete.

Response example

{
  "object": "list",
  "data": [],
  "first_id": null,
  "last_id": null,
  "has_more": false
}

Error codes

Business errors return an error object with type, code, message, and param. Common errors:

HTTP statusError type / codeSolution
400invalid_request_error / invalid_request_errorFix limit, order, and agent_id as described, and remove duplicate parameters
401authentication_error / invalid_api_keySend a valid Authorization: Bearer $DASHSCOPE_API_KEY header
404not_found_error / not_found_errorConfirm that the parent resource exists in the current workspace; use the last_id from the previous page as after
502server_error / agents_api_upstream_unavailableRetry later. If it keeps failing, submit a ticket with the x-request-id from the response headers