> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# セッションイベントの送信

> Forward セッションにユーザーまたはシステムの入力イベントを送信します。

`POST /api/v1/forward/sessions/{session_id}/events`

セッションに入力イベントを追加します。Forward はユーザー入力イベントおよび制御されたシステム入力イベントを受け付けます。呼び出し元がエージェントイベントやセッションステータスイベントを偽造することはできません。

## Headers

| Header            | Required | Description            |
| ----------------- | -------- | ---------------------- |
| `Authorization`   | Yes      | `Bearer <PAT>`         |
| `Content-Type`    | Yes      | `application/json`     |
| `Idempotency-Key` | No       | 安全でないリクエスト向けの任意の冪等性キー。 |

## Path parameters

| Parameter    | Type   | Required | Description |
| ------------ | ------ | -------- | ----------- |
| `session_id` | string | Yes      | Session ID。 |

## Body parameters

| Parameter                     | Type    | Required    | Description                                                      |
| ----------------------------- | ------- | ----------- | ---------------------------------------------------------------- |
| `events`                      | array   | Yes         | 追加する Event オブジェクト。                                               |
| `events[].type`               | string  | Yes         | Input Event の種類。                                                 |
| `events[].content`            | array   | Conditional | `user.message` と `system.message` に必須。空でないコンテンツブロック配列である必要があります。 |
| `events[].file_attachments`   | array   | No          | `user.message` 用のファイル添付メタデータ。                                    |
| `events[].tool_use_id`        | string  | Conditional | `user.tool_confirmation` と `user.tool_result` に必須。               |
| `events[].custom_tool_use_id` | string  | Conditional | `user.custom_tool_result` に必須。                                   |
| `events[].result`             | string  | Conditional | `user.tool_confirmation` に必須: `allow` または `deny`。                |
| `events[].deny_message`       | string  | No          | `result=deny` の場合の拒否理由。                                          |
| `events[].description`        | string  | Conditional | `user.define_outcome` に必須。                                       |
| `events[].rubric`             | object  | Conditional | `user.define_outcome` に必須。                                       |
| `events[].reason`             | string  | No          | `user.interrupt` の割り込み理由。                                        |
| `events[].is_error`           | boolean | No          | ツール結果イベントのエラーフラグ。                                                |

## Allowed input event types

```text theme={null}
user.message
user.interrupt
user.tool_confirmation
user.tool_result
user.custom_tool_result
user.define_outcome
system.message
```

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/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."
          }
        ],
        "file_attachments": []
      }
    ]
  }'
```

## Example response

**HTTP 200 OK**

```json theme={null}
{
  "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"
    }
  ]
}
```

## Response fields

| Field  | Type  | Description                           |
| ------ | ----- | ------------------------------------- |
| `data` | array | Forward のフィルタリング後に作成された Event オブジェクト。 |

## Errors

| HTTP | Type                    | Code                              | Trigger                     |
| ---- | ----------------------- | --------------------------------- | --------------------------- |
| 400  | `invalid_request_error` | `invalid_event`                   | Event の種類またはフィールドが無効。       |
| 401  | `authentication_error`  | `authentication_required`         | PAT が無効または期限切れ。             |
| 404  | `not_found_error`       | `session_not_found`               | Session が存在しない。             |
| 409  | `conflict_error`        | `session_archived`                | Session がアーカイブ済み。           |
| 409  | `conflict_error`        | `turn_already_running`            | 現在のターンが新しいターンを許可しない。        |
| 404  | `not_found_error`       | `pending_action_not_found`        | ツール確認または結果に対応する保留中アクションがない。 |
| 409  | `conflict_error`        | `pending_action_already_resolved` | 保留中アクションはすでに解決済み。           |

## Notes

* `system.message` はリクエストごとに 1 件までで、最後のイベントである必要があり、`user.message`、`user.tool_result`、または `user.custom_tool_result` に続く必要があります。
* レスポンスはフィルタリング済みの Forward Event オブジェクトを使用し、生のランタイムイベント JSON は公開しません。

## Related

<CardGroup cols={2}>
  <Card title="セッションイベントの一覧取得" icon="list" href="/cloud-agents/api/forward/sessions/list-events" />

  <Card title="セッションイベントのストリーミング" icon="radio" href="/cloud-agents/api/forward/sessions/stream-events" />
</CardGroup>
