跳转到内容
EN

归档线程

先调用「创建会话」,用返回的会话 ID 替换示例 ID。

POST/anthropic/v1/sessions/{session_id}/threads/{thread_id}/archive◐ 部分支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(路径或查询参数)。

  • thread_idstring必填

    path: 路径参数:线程 ID。

  • session_idstring必填

    query: 会话 ID(路径或查询参数)。

返回

200

主线程沿用会话归档动作;子线程仅归档对应子会话,不归档父会话或其他子线程。子线程归档后 status 为 terminated,带 archived_at;历史事件仍可读。

错误按 Claude Managed Agents 格式返回,参见 错误码

请求示例

curl
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
curl -X POST https://api.deepraxis.com/anthropic/v1/sessions/sesn_123/threads/sthr_123/archive \
  -H "x-api-key: $PRAXIS_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: managed-agents-2026-04-01"
Python
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.deepraxis.com/anthropic",
    api_key="$PRAXIS_API_KEY",
)

# 官方有、平台未支持:调用得到 501(not_implemented_error),无副作用。
result = client.beta.sessions.threads.archive("thread_123", {"session_id": "sample_id_123"})
print(result)
TypeScript
// 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.deepraxis.com/anthropic",
  apiKey: "$PRAXIS_API_KEY",
});

// 官方有、平台未支持:调用得到 501(not_implemented_error),无副作用。
const result = await client.beta.sessions.threads.archive("thread_123", { session_id: "sample_id_123" });
console.log(result);

响应示例 200

{
  "id": "sthr_d72b90b27a414fe5885adff0ac6b9b96",
  "type": "session_thread",
  "parent_thread_id": null,
  "session_id": "sesn_d72b90b27a414fe5885adff0ac6b9b96",
  "agent": {
    "id": "agent_57d15145-7ef6-4bd3-8b33-2b8ddca88ac0",
    "type": "agent",
    "name": "文档助手(已更新)",
    "description": null,
    "system": "用一句话简短回答。",
    "model": {
      "id": "deepseek-flash"
    },
    "version": 2,
    "tools": [],
    "skills": [],
    "mcp_servers": []
  },
  "archived_at": "2026-09-26T07:16:50.754Z",
  "created_at": "2026-09-26T07:16:14.796Z",
  "updated_at": "2026-09-26T07:16:50.754Z",
  "status": "idle",
  "stats": null,
  "usage": null
}

响应

HTTP 200

Successful response

application/json

名称 类型 说明
id string Unique identifier for this thread.
agent object The resolved agent a session_thread runs.
agent.model string | object The advisor model id. / Model identifier and configuration.
agent.type string
agent.id string
agent.description null | string
agent.mcp_servers array<object>
agent.name string
agent.skills array<object>
agent.system null | string
agent.tools array<object>
agent.version number
archived_at null | string A timestamp in RFC 3339 format
created_at string A timestamp in RFC 3339 format
parent_thread_id null | string Parent thread that spawned this thread. Null for the primary thread.
session_id string The session this thread belongs to.
stats null | object Timing statistics for a session thread.
stats.active_seconds number Cumulative time in seconds the thread spent actively running. Excludes idle time.
stats.duration_seconds number Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.
stats.startup_seconds number Time in seconds for the thread to begin running. Zero for child threads, which start immediately.
status string SessionThreadStatus enum
type string
updated_at string A timestamp in RFC 3339 format
usage null | object Cumulative token usage for a session thread across all turns.
usage.active_seconds number Cumulative time in seconds this thread spent in running status. Equal to stats.active_seconds; surfaced here so a thread's usage carries every quantity its cost is priced on.
usage.cache_creation object Prompt-cache creation token usage broken down by cache lifetime.
usage.cache_read_input_tokens number Total tokens read from prompt cache.
usage.input_tokens number Total input tokens consumed across all turns.
usage.list_cost null | object A monetary amount in a specific currency.
usage.output_tokens number Total output tokens generated across all turns.
usage.server_tool_use null | object Cumulative count of server-executed tool invocations, broken down by tool.