全部產品
Search
文件中心

Qoder CN 系列:發送 Session Event

更新時間:Jul 15, 2026

向 Forward Session 寫入使用者或系統輸入事件。

要求標頭

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_iddecisionapprovedeny

user.custom_tool_result

返回自訂工具的執行結果

tool_use_idcontent

user.define_outcome

使用者定義預期結果

content

樣本請求

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"
    }
  ]
}

響應欄位

欄位

類型

說明

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

authentication_error

authentication_required

PAT 無效或已到期。

備忘

  • 允許寫入的類型包括 user.messageuser.interruptuser.tool_confirmationuser.tool_resultuser.custom_tool_resultuser.define_outcomesystem.message

  • system.message 每次請求最多一條,必須是最後一個事件。

  • 響應不會返回運行時原始 event JSON。

相關