GET /api/v1/cloud/sessions/{session_id}/events
使用游标分页读取 Session 公开事件。如果 Accept header 请求 text/event-stream,该路由会切换到 SSE streaming;需要 JSON 分页响应时请使用 Accept: application/json 或省略 SSE media type。
如果 Session 创建时设置了 incremental_streaming_enabled: true,响应中可能包含已持久化的增量 agent 事件;如果该字段为 false 或省略,增量事件会被隐藏,只返回完整公开事件。
路径参数
| 参数 | 类型 | 说明 |
|---|---|---|
session_id | string | 以 sess_ 为前缀的 Session ID |
请求头
| 头部 | 必选 | 说明 |
|---|---|---|
Authorization | 是 | Bearer $QODER_PAT |
查询参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
limit | integer | 否 | 最大返回事件数。默认 20,范围 1-100。超过 100 返回 400 invalid_request_error |
page | string | 否 | 上一次响应 next_page 返回的不透明游标。与 before_id、after_id 互斥 |
before_id | string | 否 | 返回排在该事件 ID 之前的事件。与 page、after_id 互斥 |
after_id | string | 否 | 返回排在该事件 ID 之后的事件。与 page、before_id 互斥 |
order | string | 否 | 排序方向:asc(默认)或 desc |
types | string 或 array | 否 | 按事件类型过滤。无法识别的事件类型会被静默忽略——响应中不会包含匹配项 |
created_at[gt] | string | 否 | 返回创建时间晚于该 RFC 3339 时间的事件 |
created_at[gte] | string | 否 | 返回创建时间不早于该 RFC 3339 时间的事件 |
created_at[lt] | string | 否 | 返回创建时间早于该 RFC 3339 时间的事件 |
created_at[lte] | string | 否 | 返回创建时间不晚于该 RFC 3339 时间的事件 |
示例请求
示例响应
HTTP 200 OKtypes 过滤时请使用顶层事件类型:agent.message_start、agent.content_block_start、agent.content_block_delta、agent.content_block_stop、agent.message_delta、agent.message_stop。不要使用 text_delta 或 input_json_delta 过滤;它们是 agent.content_block_delta 内部的 delta.type。
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
data | array | 公开 Event 对象 列表 |
has_more | boolean | 当前结果集之后还有更多页时为 true |
first_id | string | null | 当前页第一个事件的 ID |
last_id | string | null | 当前页最后一个事件的 ID |
next_page | string | null | 下一页的不透明游标,无更多结果时为 null |
错误码
| HTTP | 类型 | 触发条件 |
|---|---|---|
| 400 | invalid_request_error | limit 非正整数、order 非法、时间戳过滤非法,或 page 与 before_id/after_id 同时提供 |
| 401 | authentication_error | PAT 无效或过期 |
备注: 该接口对不存在的 Session ID 返回 HTTP 200 并返回空data数组,便于客户端安全轮询。如需确认 Session 是否存在,请使用GET /api/v1/cloud/sessions/{id}。
示例:400 order 非法
示例:400 limit 非法
相关
Session 事件流
通过 SSE 实时获取 Agent 的思考、消息、工具调用与状态。