Skip to main content

Retrieve Session

Returns session metadata, the embedded agent snapshot, and resource list. Event history and message content are retrieved through the Event API.

Prerequisites

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

Endpoint

GET /sessions/{session_id}

Request example

curl "$AGENTSTUDIO_URL/sessions/sesn_xxx" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"

Response example

{
  "id": "sesn_xxx",
  "type": "session",
  "status": "idle",
  "stop_reason": {
    "type": "requires_action",
    "pending_batch_id": "response_xxx:9f2c...",
    "pending_call_ids": ["call_xxx"]
  },
  "agent": {
    "id": "agent_xxx",
    "type": "agent",
    "version": 1,
    "name": "data-analyst",
    "description": null,
    "model": {"id": "qwen3.7-max"},
    "system": "你是数据分析专家,使用 pandas 处理 CSV 文件。",
    "tools": []
  },
  "environment_id": "env_xxx",
  "title": "Q3 销售数据分析",
  "metadata": {"biz_ticket_id": "1234"},
  "archived_at": null,
  "created_at": "2026-05-28T08:23:11Z",
  "updated_at": "2026-05-28T08:23:25Z",
  "request_id": "xxx",
  "environment_variables": {"API_BASE_URL": "https://api.example.com", "LOG_LEVEL": "info"},
  "vault_ids": ["vlt_xxx"],
  "mcp_configs": [{"mcp_server_name": "crm", "headers": {"X-Tenant-Id": "tenant-demo"}}]
}
The response is a Session object with the following fields:

Response fields

FieldTypeDescription
idstringSession ID, format sesn_<ULID>
typestringFixed as session
statusstringSession status: idle / running / terminated
stop_reasonobject | nullThe reason the session returned to idle. A discriminated union: null (running, or idle and just created with no end reason yet) | {"type": "end_turn"} (model ended on its own) | {"type": "retries_exhausted"} (retries exhausted) | {"type": "requires_action", "pending_batch_id": "...", "pending_call_ids": [...]} (waiting for tool approval). Only meaningful when status is idle; null when running. terminated is a terminal state and the server may retain the previous value — clients should not rely on or interpret it. The requires_action branch carries a non-empty pending_batch_id and pending_call_ids; use them to locate the pending approval calls and fetch the corresponding tool_approval_request events via the Event API
agentobjectFull agent configuration snapshot, including id/version/name/model/system/tools, etc.; session-level overrides (if any) are merged into the snapshot
environment_idstringThe bound environment ID
title / metadatastring / objectSession title and custom business metadata
archived_atstring | nullArchive time; null when not archived
created_at / updated_atstringCreation/last update time, ISO 8601
request_idstringUnique identifier for this request
environment_variablesobjectEnvironment variables injected into the session runtime as string key-value pairs; sandbox code can read them directly by name
vault_idsarray of stringBound vault ID list
mcp_configsarray of objectSession-level MCP request headers; each item contains mcp_server_name and headers. Empty array when not configured
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration