跳转到内容
EN

删除会话

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

DELETE/agent/v1/sessions/{session_id}● 支持

Claude 官方文档 ↗

请求参数

  • session_idstring必填

    path: 会话 ID(sesn_...),由 sessions.create 或 sessions.list 返回。资源和线程调用的 session_id 查询参数也接受同一 ID,且必须与路径值一致。

返回

200

运行中返回 409 INVALID_STATE;请先 interrupt 或等待结束。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

请求示例

curl
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
curl -X DELETE https://api.deepraxis.com/agent/v1/sessions/sesn_123 \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
Python
# 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
import requests

opts = dict(
    base_url="https://api.deepraxis.com/agent",
    api_key="$PRAXIS_API_KEY",
)

# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.delete(
    f"{opts['base_url']}/v1/sessions/sesn_123",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
)
print(resp.status_code, resp.json())
TypeScript
// 先调用「创建会话」,用返回的会话 ID 替换示例 ID。
const opts = {
  baseURL: "https://api.deepraxis.com/agent",
  apiKey: "$PRAXIS_API_KEY",
};

// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/sessions/sesn_123`, {
  method: "DELETE",
  headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "application/json" },
});
console.log(resp.status, await resp.json());

响应示例 200

{
  "id": "sesn_771c3fcb4a8c41229f35f9fcf6f3cd7d",
  "type": "session_deleted"
}

响应

HTTP 200

Successful response

application/json

名称 类型 说明
id string Identifier of the object, as returned by the API; pass it in the path of follow-up calls on the same resource.
type string session_deleted confirms that the session and its events have been deleted.