GET /api/v1/cloud/sessions/{session_id}/events
使用游标分页读取 Session 公开事件。如果 Accept header 请求 text/event-stream,该路由会切换到 SSE streaming;需要 JSON 分页响应时请使用 Accept: application/json 或省略 SSE media type。
路径参数
| 参数 | 类型 | 说明 |
|---|---|---|
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 时间的事件 |
示例请求
curl -X GET "https://api.qoder.com/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/events?limit=5&types=user.message,agent.message" \
-H "Authorization: Bearer $QODER_PAT"
示例响应
HTTP 200 OK{
"data": [
{
"id": "evt_019e392c0d787cfaa21bda98e06cd913",
"type": "user.message",
"content": [
{"type": "text", "text": "Hello, this is a test message."}
],
"processed_at": "2026-05-18T03:40:48.888851795Z"
},
{
"id": "evt_771c1195bcbd4a07834d4ed4dd6450ca",
"type": "agent.message",
"content": [
{"type": "text", "text": "Hello! How can I help you today?"}
],
"processed_at": "2026-05-18T03:40:55.123Z"
}
],
"first_id": "evt_019e392c0d787cfaa21bda98e06cd913",
"has_more": false,
"last_id": "evt_771c1195bcbd4a07834d4ed4dd6450ca",
"next_page": null
}
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 无效或过期 |
| 404 | not_found_error | Session 不存在;错误消息为 Session '<session_id>' was not found. |
示例:400 order 非法
{
"error": {
"message": "Field 'order' must be one of: asc, desc.",
"type": "invalid_request_error"
},
"request_id": "74c9b7ee-f2f4-450a-9283-933fd3315cf8",
"type": "error"
}
示例:400 limit 非法
{
"error": {
"message": "Field 'limit' must be a positive integer.",
"type": "invalid_request_error"
},
"request_id": "d582074b-11ec-45cb-9c94-929278a19261",
"type": "error"
}
相关
Session 事件流
通过 SSE 实时获取 Agent 的思考、消息、工具调用与状态。