跳转到主要内容
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_idstringsess_ 为前缀的 Session ID

请求头

头部必选说明
AuthorizationBearer $QODER_PAT

查询参数

参数类型必填说明
limitinteger最大返回事件数。默认 20,范围 1-100。超过 100 返回 400 invalid_request_error
pagestring上一次响应 next_page 返回的不透明游标。与 before_idafter_id 互斥
before_idstring返回排在该事件 ID 之前的事件。与 pageafter_id 互斥
after_idstring返回排在该事件 ID 之后的事件。与 pagebefore_id 互斥
orderstring排序方向:asc(默认)或 desc
typesstring 或 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
}
完整事件类型见 公开事件类型 对于开启增量流式的 Session,按 types 过滤时请使用顶层事件类型:agent.message_startagent.content_block_startagent.content_block_deltaagent.content_block_stopagent.message_deltaagent.message_stop。不要使用 text_deltainput_json_delta 过滤;它们是 agent.content_block_delta 内部的 delta.type

响应字段

字段类型说明
dataarray公开 Event 对象 列表
has_moreboolean当前结果集之后还有更多页时为 true
first_idstring | null当前页第一个事件的 ID
last_idstring | null当前页最后一个事件的 ID
next_pagestring | null下一页的不透明游标,无更多结果时为 null

错误码

HTTP类型触发条件
400invalid_request_errorlimit 非正整数、order 非法、时间戳过滤非法,或 pagebefore_id/after_id 同时提供
401authentication_errorPAT 无效或过期
备注: 该接口对不存在的 Session ID 返回 HTTP 200 并返回空 data 数组,便于客户端安全轮询。如需确认 Session 是否存在,请使用 GET /api/v1/cloud/sessions/{id}

示例: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 的思考、消息、工具调用与状态。