> ## 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.

# スレッドイベントのストリーミング

> 1 つの Session thread に限定したイベントをストリーミングします。

`GET /api/v1/cloud/sessions/{session_id}/threads/{thread_id}/stream`

1 つの thread の公開イベントを Server-Sent Events としてストリーミングします。

## パスパラメータ

| パラメータ        | 型      | 説明                            |
| ------------ | ------ | ----------------------------- |
| `session_id` | string | `sess_` プレフィックス付きの Session ID |
| `thread_id`  | string | `sthr_` プレフィックス付きの Thread ID  |

## ヘッダー

| ヘッダー            | 必須  | 説明                                                                                                          |
| --------------- | --- | ----------------------------------------------------------------------------------------------------------- |
| `Authorization` | はい  | `Bearer $QODER_PAT`                                                                                         |
| `Accept`        | いいえ | `text/event-stream` を使用します                                                                                  |
| `Last-Event-ID` | いいえ | 指定すると、ストリームは指定したイベント ID の後から再開します。イベント ID が存在しない、アーカイブ済み、非公開の内部イベントを指す、またはこの thread に属していない場合は `400` を返します。 |

## リクエスト例

```bash theme={null}
curl -N -X GET "https://api.qoder.com/api/v1/cloud/sessions/sess_019f00000000000000000000000000aa/threads/sthr_019f00000000000000000000000002bb/stream" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Accept: text/event-stream"
```

## ストリーム形式

```text theme={null}
id: evt_019f00000000000000000000000003cc
event: agent.message
data: {"id":"evt_019f00000000000000000000000003cc","type":"agent.message","content":[{"type":"text","text":"Thread response"}],"processed_at":"2026-06-15T08:02:00.000Z"}

id: evt_c3d4e5f6a7b8c9d0
event: session.thread_status_idle
data: {"agent_name":"my-agent","id":"evt_c3d4e5f6a7b8c9d0","processed_at":"2026-06-15T08:02:01.000Z","session_thread_id":"sthr_019f00000000000000000000000002bb","stop_reason":{"type":"end_turn"},"type":"session.thread_status_idle"}
```

サーバーは接続を維持するために、定期的に `: heartbeat` というコメント行を送信します。

## エラー

| HTTP | タイプ                     | トリガー条件                                                                                                    |
| ---- | ----------------------- | --------------------------------------------------------------------------------------------------------- |
| 400  | `invalid_request_error` | `Last-Event-ID` がこの Session/thread 内の有効な公開イベントを特定できない（イベントが存在しない、アーカイブ済み、非公開の内部イベント、またはこの thread に属していない） |
| 401  | `authentication_error`  | PAT が無効または期限切れ                                                                                            |
| 404  | `not_found_error`       | Session または thread が存在しない                                                                                 |

**HTTP 404 Not Found**

```json theme={null}
{
  "type": "error",
  "request_id": "cb80235f-76a2-4ff3-9e28-5aa2da12dc14",
  "error": {
    "type": "not_found_error",
    "message": "Session thread 'sthr_fakefakefake_xxxxxxxxxxxxxxxx' was not found."
  },
  "request_id": "b5822072-f264-48da-9d61-6d48ffb07551"
}
```

完全なエラーエンベロープについては [エラー](/ja/cloud-agents/api/conventions/errors) を参照してください。

## 関連項目

<CardGroup cols={2}>
  <Card title="Managed Agents" icon="user-gear" href="/ja/cloud-agents/managed-agents">
    マルチ Agent 協調におけるスレッドイベントのセマンティクスを理解します。
  </Card>

  <Card title="List Thread Events" icon="list" href="/ja/cloud-agents/api/sessions/list-thread-events">
    スレッドの過去イベントをページ送りで参照します。
  </Card>

  <Card title="List Session Threads" icon="layer-group" href="/ja/cloud-agents/api/sessions/list-threads">
    Session 内のすべてのスレッドを表示します。
  </Card>
</CardGroup>
