Skip to main content

归档 Session thread

归档 managed-agent Session 中的子线程。

POST /api/v1/cloud/sessions/{session_id}/threads/{thread_id}/archive 归档处于 idle 状态的子线程。主线程不可归档。

路径参数

参数类型说明
session_idstring以 sess_ 为前缀的 Session ID
thread_idstring以 sthr_ 为前缀的 Thread ID

请求头

头部必选说明
Authorization是Bearer <PAT 或 SAT>

示例请求

curl -X POST "https://api.qoder.com/api/v1/cloud/sessions/sess_019f00000000000000000000000000aa/threads/sthr_019f00000000000000000000000002bb/archive" \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN"

示例响应

HTTP 200 OK 返回归档后的 Session Thread 对象。
{
  "id": "sthr_019ef2a07a06704fb899908c29eed779",
  "type": "session_thread",
  "session_id": "sess_019ef2a07a0670b3b68a84f0f3c5c98e",
  "parent_thread_id": "sthr_019ef2a07a06704fb899908c29eed778",
  "agent": {
    "id": "agent_019e390add9f7bac9b6cc806db46fcbd",
    "type": "agent",
    "version": 2,
    "name": "doc-test-agent",
    "description": "",
    "model": {"id": "ultimate", "effective_context_window": 200000},
    "system": "You are an expert software engineer.",
    "tools": [{"enabled_tools": ["Bash", "Read", "Write", "Edit", "Glob", "Grep"], "type": "agent_toolset_20260401"}],
    "skills": [],
    "mcp_servers": []
  },
  "status": "terminated",
  "stats": null,
  "archived_at": "2026-06-23T06:00:00.000Z",
  "created_at": "2026-06-23T05:53:19.774840Z",
  "updated_at": "2026-06-23T06:00:00.000Z"
}

错误码

HTTP类型触发条件
401认证错误,响应格式见下文缺少访问令牌,或 PAT / SAT 无效、过期
404not_found_errorSession 或 thread 不存在,或不在当前可访问范围内
409invalid_request_error主线程不可归档,或子线程不是 idle(包括已经归档的子线程)
HTTP 401 Unauthorized 认证错误可能由网关直接返回,不一定包含 error.type。例如缺少 Authorization 时:
{
  "code": "TOKEN_INVALID",
  "message": "missing authorization token",
  "timestamp": "1792982170292"
}
HTTP 404 Not Found
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "not_found_error",
    "message": "Session thread 'sthr_fakefakefake_xxxxxxxxxxxxxxxx' was not found."
  }
}
HTTP 409 Conflict
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "invalid_request_error",
    "message": "Only idle child session threads can be archived."
  }
}
错误示例中的 ID 和时间仅用于说明。客户端应按 HTTP 状态码及响应中的 code 或 error.type 处理,不依赖固定的 message 文案。 收到 409 时,可通过 GET /api/v1/cloud/sessions/{session_id}/threads/{thread_id} 查看线程的当前状态。 完整错误信封格式见 错误参考。