Archive Session

Updated at:

Archives a session: sets status to the terminal state terminated, populates archived_at with the archive time, and event history remains queryable.

Prerequisites

Endpoint and authentication configured. For details, see Overview and authentication.

Endpoint

POST /sessions/{session_id}/archive

Request example

curl -X POST "$AGENTSTUDIO_URL/sessions/sesn_xxx/archive" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY"
client.sessions.archive("sesn_xxx")
client.sessions().archive("sesn_xxx");

Response example

Returns the full session object with status set to terminated and archived_at populated with the archive time.

{
  "id": "sesn_xxx",
  "type": "session",
  "status": "terminated",
  "agent": {
    "id": "agent_xxx",
    "type": "agent",
    "version": 1,
    "name": "data-analyst",
    "model": {"id": "qwen3-max"},
    "system": "你是数据分析专家,使用 pandas 处理 CSV 文件。",
    "tools": []
  },
  "environment_id": "env_xxx",
  "title": "Q3 销售数据分析",
  "metadata": {"biz_ticket_id": "1234"},
  "archived_at": "2026-05-28T11:00:00Z",
  "created_at": "2026-05-28T08:23:11Z",
  "updated_at": "2026-05-28T11:00:00Z",
  "request_id": "xxx"
}

The response is a Session object with the following fields:

Response fields

Field

Type

Description

id

string

Session ID

type

string

Always session

status

string

Set to terminated (terminal state) after archiving

agent

object

Agent configuration snapshot

environment_id

string

The bound environment ID

title / metadata

string / object

Session title and business metadata

archived_at

string

Archive time, ISO 8601; this field is always non-null in responses from the archive endpoint

created_at / updated_at

string

Creation/last update time

request_id

string

Unique identifier for this request