メインコンテンツへスキップ
POST /api/v1/cloud/sessions/{session_id}/events 1 つ以上の受理可能なイベントを Session に送信します。user.message は非同期に Agent の処理をトリガーします。Agent の出力は list または stream エンドポイントで読み取ってください。

パスパラメータ

パラメータ説明
session_idstringsess_ プレフィックス付きの Session ID

ヘッダー

ヘッダー必須説明
AuthorizationはいBearer $QODER_PAT
Content-Typeはいapplication/json

リクエストボディ

フィールド必須説明
eventsarrayはい空でないイベントオブジェクトの配列

サポートされるイベントタイプ

タイプ必須フィールド備考
user.messagecontentcontent は空でない content block の配列でなければなりません
user.interruptなしsession_thread_id は任意です
user.tool_confirmationtool_use_idresultresultallow または deny でなければなりません。deny_message は任意で、result = "deny" の場合にのみ指定できます
user.tool_resulttool_use_id組み込みツールの結果を返すために使用します。contentis_error は任意です
user.custom_tool_resultcustom_tool_use_idクライアント側カスタムツールの結果を返すために使用します。contentis_error は任意です
user.define_outcomedescriptionrubricrubric はオブジェクトで、{"type":"text","content":"..."} または {"type":"file","file_id":"file_..."} のいずれかです。未知のフィールドは拒否されます。max_iterations は任意で、1 から 20 の整数でなければなりません。outcome_idoutc_ プレフィックス)はサーバーが割り当てるため、クライアントは指定できません
system.messagecontentcontent は空でない text content block の配列でなければなりません。1 リクエストにつき system.message は最大 1 つで、batch の最後のイベントとして、user.messageuser.tool_result、または user.custom_tool_result の直後に置く必要があります
user.message および system.message では文字列形式の content はサポートされません。

リクエスト例

curl -X POST https://api.qoder.com/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/events \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "type": "user.message",
        "content": [
          {"type": "text", "text": "Help me analyze the performance of this code."}
        ]
      }
    ]
  }'

レスポンス例

HTTP 200 OK
{
  "data": [
    {
      "id": "evt_019e3bb2c153764da54e4d3acbef52b6",
      "type": "user.message",
      "content": [
        {"type": "text", "text": "Help me analyze the performance of this code."}
      ],
      "processed_at": "2026-05-18T15:27:11.187413896Z"
    }
  ]
}

Human-in-the-loop レスポンス

ストリームが確認を必要とする agent.tool_use を発行したら、user.tool_confirmation で応答します。
{
  "events": [
    {
      "type": "user.tool_confirmation",
      "tool_use_id": "evt_01JZ6Q3FB6SG8F7J1M2N",
      "result": "deny",
      "deny_message": "Do not delete files in this directory."
    }
  ]
}
ストリームが agent.custom_tool_use を発行したら、クライアント側でツールを実行し、user.custom_tool_result で応答します。
{
  "events": [
    {
      "type": "user.custom_tool_result",
      "custom_tool_use_id": "evt_01JZ6R1V9Z8K2M3N4P5Q",
      "content": [{"type": "text", "text": "Order status: shipped"}]
    }
  ]
}

エラー

HTTPタイプトリガー条件
400invalid_request_errorevents が空、サポートされないイベントタイプ、必須フィールドの欠落、不正な content block、またはサポートされないレガシーフィールド
401authentication_errorPAT が無効または期限切れ
404not_found_errorSession または保留中のアクションが存在しない
409invalid_request_errorSession が現在ターンを処理中、またはその他の Session 状態の競合(注意: typeconflict_error ではなく invalid_request_error です)

例: 400 不正な content

user.message に content block の配列ではなくプレーンな文字列を送信した場合:
{
  "error": {
    "message": "Field 'content' must be a non-empty array of content blocks.",
    "type": "invalid_request_error"
  },
  "request_id": "2c9d3d8a-dd0f-4c27-b2ad-24c8719c97e1",
  "type": "error"
}

例: 404 Session が見つからない

{
  "error": {
    "message": "Session 'sess_doesnotexist_xxxxxxxxxxxxxxxxxxxxxxxx' was not found.",
    "type": "not_found_error"
  },
  "request_id": "590c2a0c-1656-42d3-ba0c-32c755d22e77",
  "type": "error"
}

例: 409 Session が実行中

Session がすでにターンを処理しているときに user.message を送信した場合:
{
  "error": {
    "message": "Session is currently processing a turn. Cancel the current turn or wait for completion.",
    "type": "invalid_request_error"
  },
  "request_id": "ba018d2f-d6b0-4bbe-a53c-2241baca34fe",
  "type": "error"
}
完全なエラーエンベロープについては エラー を参照してください。

関連項目

Session イベントストリーム

Agent の思考、メッセージ、ツール呼び出し、ステータスを SSE でストリーミングします。