向 Forward Session 寫入使用者或系統輸入事件。
要求標頭
Header | 是否必填 | 說明 |
Authorization | 是 |
|
Content-Type | 是 |
|
Idempotency-Key | 否 | 有副作用請求可選的等冪鍵。 |
路徑參數
參數 | 類型 | 是否必填 | 說明 |
| string | 是 | Session ID。 |
請求體
欄位 | 類型 | 必選 | 說明 |
| array | 是 | 事件對象數組 |
| string | 是 | 事件類型 |
| string \ | array | 視類型 |
| string | 是 | 內容塊類型,如 |
| string | 是 | 常值內容 |
content 支援兩種格式:
簡寫:純字串
"content": "常值內容"完整:內容塊數組
"content": [{"type": "text", "text": "常值內容"}]
純文字訊息建議使用簡寫格式;需要發送多媒體內容(如圖片)時使用完整格式。
支援的事件類型
type | 說明 | 必要欄位 |
| 使用者發送訊息 |
|
| 使用者中斷 Agent 執行 | - |
| 對 Agent 的工具調用進行授權 |
|
| 返回自訂工具的執行結果 |
|
| 使用者定義預期結果 |
|
樣本請求
curl -s -X POST 'https://api.qoder.com.cn/api/v1/forward/sessions/sess_xxx/events' \
-H "Authorization: Bearer $QODER_PAT" \
-H "Content-Type: application/json" \
-d '{
"events": [
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "Continue the analysis."
}
]
}
]
}'
樣本響應
HTTP 200 OK
{
"data": [
{
"id": "evt_xxx",
"type": "user.message",
"session_id": "sess_xxx",
"content": [
{
"type": "text",
"text": "Continue the analysis."
}
],
"processed_at": "2026-06-22T11:00:00Z"
}
]
}
響應欄位
欄位 | 類型 | 說明 |
| array | 建立後的 Event 對象數組,已按 Forward 規則過濾。 |
錯誤
HTTP | Type | Code | 觸發條件 |
400 |
|
| Event 類型或欄位不合法。 |
404 |
|
| Session 不存在。 |
409 |
|
| Session 已歸檔。 |
409 |
|
| 當前 Turn 狀態不允許建立 Turn。 |
404 |
|
| 工具確認或結果找不到對應 Pending Action。 |
409 |
|
| Pending Action 已處理。 |
401 |
|
| PAT 無效或已到期。 |
備忘
允許寫入的類型包括
user.message、user.interrupt、user.tool_confirmation、user.tool_result、user.custom_tool_result、user.define_outcome和system.message。system.message每次請求最多一條,必須是最後一個事件。響應不會返回運行時原始 event JSON。