List Sessions

Updated at:

Lists sessions with pagination, sorted by created_at in descending order. Supports filtering by agent, status, and creation time range.

Prerequisites

Endpoint and authentication configuration must be completed. For details, see Overview and authentication.

Endpoint

GET/sessions

Query parameters

agent_idstringOptionalDefault —

Filter by agent

statuses[]stringOptionalDefault —

Filter by multiple statuses; can be repeated. Example: ?statuses[]=idle&statuses[]=running

created_at[gte] / created_at[lte]stringOptionalDefault —

Creation time range, ISO 8601

limitintOptionalDefault 20

Number of items per page, maximum 100

pagestringOptionalDefault —

Omit on the first request; pass next_page from the previous response for subsequent requests

Request example

curl "$AGENTSTUDIO_URL/sessions?agent_id=agent_xxx&statuses[]=idle&limit=20" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
for session in client.sessions.list(
    limit=20,
    agent_id="agent_xxx",
    statuses=["idle"],
):
    print(session.id, session.status, session.title)
CursorPage<Session> page = client.sessions().list(SessionListParam.builder()
    .limit(20)
    .agentId("agent_xxx")
    .statuses(Arrays.asList("idle"))
    .build());
for (Session s : page.getData()) {
    System.out.println(s.getId() + " " + s.getStatus() + " " + s.getTitle());
}

Response fields

dataarray<Session>

Array of Session objects

data[] Session object fields

idstring

Session ID, format sesn_<ULID>

typestring

Fixed as session

statusstring

Session status: idle / running / terminated

stop_reasonobject / null

The reason the session returned to idle. A discriminated union: null (running, or idle and just created) / {"type": "end_turn"} / {"type": "retries_exhausted"} / {"type": "requires_action", "pending_batch_id": "...", "pending_call_ids": [...]}. Only meaningful when status is idle; see Retrieve Session for full details

stop_reason properties

typestring

end_turn / requires_action / retries_exhausted

pending_batch_idstring

Pending tool approval batch ID

pending_call_idsarray<string>

Tool call IDs awaiting a decision

agentobject

Agent configuration snapshot, including id/version/name/model/system/tools, etc.

agent properties

idstring

Agent ID, format agent_xxx

versioninteger

Version to pin; latest if omitted

environment_idstring

The bound environment ID

titlestring

Session title

metadataobject

Custom business key-value pairs

archived_atstring / null

Archive time; null when not archived

created_atstring

Creation time (ISO 8601)

updated_atstring

Last update time (ISO 8601)

environment_variablesobject

Environment variables injected into the session runtime as string key-value pairs; sandbox code can read them directly by name

next_pagestring / null

Cursor for the next page; absent or null when there is no more data

request_idstring

Unique identifier for this request

Response example

{
  "data": [
    {
      "id": "sesn_xxx",
      "type": "session",
      "status": "idle",
      "stop_reason": null,
      "agent": {
        "id": "agent_xxx",
        "type": "agent",
        "version": 1,
        "name": "data-analyst",
        "model": {"id": "qwen3.7-max"},
        "system": "You are a data analysis expert who uses pandas to process CSV files.",
        "tools": []
      },
      "environment_id": "env_xxx",
      "title": "Q3 sales data analysis",
      "metadata": {"biz_ticket_id": "1234"},
      "archived_at": null,
      "created_at": "2026-05-28T08:23:11.456000Z",
      "updated_at": "2026-05-28T08:23:25.789000Z",
      "environment_variables": {"API_BASE_URL": "https://api.example.com", "LOG_LEVEL": "info"}
    }
  ],
  "next_page": "xxx",
  "request_id": "xxx"
}

The response contains data (an array of Session objects) and next_page (cursor for the next page). Session object fields are as follows: