简体中文API Reference
向 Thread 发送用户消息、权限决策或中断
向 Thread 应用一批事件:发送用户消息、回答待处理的权限请求,或中断当前 Run。当 Thread 空闲时,用户消息会排队启动新的 Run。
POST
/threads/{threadId}/events向 Thread 应用一批事件:发送用户消息、回答待处理的权限请求,或中断当前 Run。当 Thread 空闲时,用户消息会排队启动新的 Run。
Authorization
publicApiBearer AuthorizationBearer <token>
使用 Authorization: Bearer mst_...。API token 用于识别账号,不携带 scope。
In: header
Path Parameters
threadId*string
create thread 返回的 Thread ID。v1 ID 是不带前缀的 ULID。
Match
^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$Format
ulidHeader Parameters
Idempotency-Key?string
用于安全重试 create-thread 和 send-events 调用的可选键。用同一个键重复提交相同请求会返回原始响应。如果原始请求仍在处理中就重复使用该键,会返回 409。
Length
length <= 128Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
向 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/threads/01J00000000000000000000009/events" \ -H "Idempotency-Key: thread-20260528-linear-eng-123" \ -H "Content-Type: application/json" \ -d '{ "events": [ { "text": "Say hello from the API.", "type": "user_message" } ] }'{ "acceptedAt": "2019-08-24T14:15:22Z", "events": [ { "clientRequestId": "string", "run": { "completedAt": "2019-08-24T14:15:22Z", "createdAt": "2019-08-24T14:15:22Z", "error": { "code": "string", "message": "string", "retryable": true }, "finalOutput": { "text": "string" }, "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "startedAt": "2019-08-24T14:15:22Z", "status": "queued", "trigger": "user_prompt", "updatedAt": "2019-08-24T14:15:22Z" }, "type": "permission_decision" } ], "thread": { "agent_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "attributed_user": { "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV" }, "client_external_ref": "string", "created_at": "2019-08-24T14:15:22Z", "created_by": { "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "kind": "access_token" }, "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "kind": "pet", "last_run_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV", "source": "api", "status": "IDLE", "title": "string", "updated_at": "2019-08-24T14:15:22Z" }, "warnings": [ { "code": "string", "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" }}{ "error": { "code": "agent_not_published", "message": "string" }}