向 Forward Session 写入用户或系统输入事件。
HTTP 200 OK
请求头
| Header | 是否必填 | 说明 |
|---|---|---|
| Authorization | 是 | Bearer <PAT> |
| Content-Type | 是 | application/json |
| Idempotency-Key | 否 | 有副作用请求可选的幂等键。 |
路径参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
session_id | string | 是 | Session ID。 |
请求体
| 字段 | 类型 | 必选 | 说明 |
|---|---|---|---|
events | array | 是 | 事件对象数组 |
events[].type | string | 是 | 事件类型 |
events[].content | string \ | array | 视类型 |
events[].content[].type | string | 是 | 内容块类型,如 text |
events[].content[].text | string | 是 | 文本内容 |
content 支持两种格式:
- 简写:纯字符串
"content": "文本内容" - 完整:内容块数组
"content": [{"type": "text", "text": "文本内容"}]
支持的事件类型
| type | 说明 | 必填字段 |
|---|---|---|
user.message | 用户发送消息 | content |
user.interrupt | 用户中断 Agent 执行 | - |
user.tool_confirmation | 对 Agent 的工具调用进行授权 | tool_use_id、decision(approve 或 deny) |
user.custom_tool_result | 返回自定义工具的执行结果 | tool_use_id、content |
user.define_outcome | 用户定义预期结果 | content |
示例请求
示例响应
HTTP 200 OK
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
data | array | 创建后的 Event 对象数组,已按 Forward 规则过滤。 |
错误
| HTTP | Type | Code | 触发条件 |
|---|---|---|---|
| 400 | invalid_request_error | invalid_event | Event 类型或字段不合法。 |
| 404 | not_found_error | session_not_found | Session 不存在。 |
| 409 | conflict_error | session_archived | Session 已归档。 |
| 409 | conflict_error | turn_already_running | 当前 Turn 状态不允许新建 Turn。 |
| 404 | not_found_error | pending_action_not_found | 工具确认或结果找不到对应 Pending Action。 |
| 409 | conflict_error | pending_action_already_resolved | Pending Action 已处理。 |
| 401 | - | TOKEN_INVALID | PAT 无效或已过期,或缺少 Authorization header。 |
备注
-
允许写入的类型包括
user.message、user.interrupt、user.tool_confirmation、user.tool_result、user.custom_tool_result、user.define_outcome和system.message。 -
system.message每次请求最多一条,必须是最后一个事件。 - 响应不会返回运行时原始 event JSON。
- session&event数据结构
- 查询 Event 历史
- 订阅 Session Event Stream