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

# チャネル QR セッションの作成

> Channel 向けの短時間有効な QR 認可セッションを作成します。

`POST /api/v1/forward/channels/{channel_id}/qr_sessions`

対応するチャネルをアクティベートまたは再バインドできる QR セッションを作成します。

## Headers

| Header            | Required | Description                     |
| ----------------- | -------- | ------------------------------- |
| `Authorization`   | Yes      | `Bearer <PAT>`                  |
| `Content-Type`    | No       | ボディを送信する場合は `application/json`。 |
| `Idempotency-Key` | No       | 安全でないリクエスト向けの任意のべき等性キー。         |

## Path parameters

| Parameter    | Type   | Required | Description |
| ------------ | ------ | -------- | ----------- |
| `channel_id` | string | Yes      | チャネル ID。    |

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/channels/channel_dingtalk-001/qr_sessions' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Example response

**HTTP 200 OK**

```json theme={null}
{
  "session_key": "qr-a1b2c3d4",
  "channel_id": "channel_dingtalk-001",
  "channel_type": "dingtalk",
  "status": "waiting",
  "qr_code_content": "https://login.dingtalk.com/oauth2/...",
  "qr_code_image_base64": "data:image/png;base64,...",
  "expires_at": "2026-06-18T10:05:00Z",
  "poll_interval_seconds": 2
}
```

## Response fields

| Field                   | Type    | Description                               |
| ----------------------- | ------- | ----------------------------------------- |
| `session_key`           | string  | ポーリングに使用する不透明な QR セッションキー。                |
| `channel_id`            | string  | 関連付けられた Channel ID。                       |
| `channel_type`          | string  | `wechat`、`feishu`、`dingtalk`、または `wecom`。 |
| `status`                | string  | 初期ステータス。通常は `waiting`。                    |
| `qr_code_content`       | string  | 元の QR コンテンツ。通常はサードパーティの認可 URL。            |
| `qr_code_image_base64`  | string  | サービスが生成した QR 画像。                          |
| `expires_at`            | string  | 有効期限のタイムスタンプ。                             |
| `poll_interval_seconds` | integer | 推奨されるポーリング間隔。                             |

## Errors

| HTTP | Type                    | Code                       | Trigger                       |
| ---- | ----------------------- | -------------------------- | ----------------------------- |
| 400  | `invalid_request_error` | `channel_type_unsupported` | チャネルタイプが QR セッションをサポートしていません。 |
| 404  | `not_found_error`       | `channel_not_found`        | Channel が存在しません。              |
| 409  | `conflict_error`        | `channel_disabled`         | Channel が無効になっています。           |
| 502  | `api_error`             | `channel_auth_failed`      | サードパーティチャネルの認可に失敗しました。        |

## Notes

* QR セッションは現在 `wechat`、`feishu`、`dingtalk`、`wecom` をサポートしています。
* `qq` は現在、統一された QR セッションフローをサポートしていません。
* リクエストボディは省略するか `{}` にできます。

## Related

<CardGroup cols={2}>
  <Card title="チャネル QR セッションの取得" icon="arrows-rotate" href="/cloud-agents/api/forward/channels/get-qr-session" />

  <Card title="チャネルの取得" icon="file-lines" href="/cloud-agents/api/forward/channels/get" />
</CardGroup>
