mosoodocs

为 Agent API Endpoint 创建 Thread

从最新保存的私有 Agent 创建持久 Thread。无需发布或提供 userId。输入和文件可选。该 Thread 的接纳配置被冻结;后续 Agent 修改仅影响新 Thread。

POST/agents/{agentId}/threads

从最新保存的私有 Agent 创建持久 Thread。无需发布或提供 userId。输入和文件可选。该 Thread 的接纳配置被冻结;后续 Agent 修改仅影响新 Thread。

Authorization

publicApiBearer
AuthorizationBearer <token>

使用 Authorization: Bearer msp_...。Project API key 只能配置、执行和访问本 Project 的 Agent、Session 和文件。密钥和账号管理需要 console 或 CLI 登录。旧账号 token 已被拒绝。

In: header

Path Parameters

agentId*string

来自 Agent API Access 面板的 Agent API Endpoint ID。v1 ID 是不带前缀的 ULID。

Match^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$
Formatulid

Header Parameters

Idempotency-Key?string

用于安全重试 create-thread 和 send-events 调用的可选键。用同一个键重复提交相同请求会返回原始响应。如果原始请求仍在处理中就重复使用该键,会返回 409。

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

从最新保存的私有 Agent 配置创建持久 Thread。userId 可选;省略 input 可创建空闲 Thread。现有 Thread 保留接纳时的配置。

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/agents/01J00000000000000000000001/threads" \  -H "Idempotency-Key: thread-20260528-linear-eng-123" \  -H "Content-Type: application/json" \  -d '{}'
{  "links": {    "thread": "string"  },  "run": {    "completedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "error": {      "code": "string",      "message": "string",      "retryable": true    },    "finalOutput": {      "text": "string",      "warnings": [        {          "code": "unresolved_provider_citation",          "count": 1        }      ]    },    "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "startedAt": "2019-08-24T14:15:22Z",    "status": "queued",    "trigger": "user_prompt",    "updatedAt": "2019-08-24T14:15:22Z"  },  "thread": {    "agent_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "created_at": "2019-08-24T14:15:22Z",    "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "last_run_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "source": "api",    "status": "IDLE",    "title": "string",    "updated_at": "2019-08-24T14:15:22Z",    "userId": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}