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

# チャネルの作成

> Identity と Template に紐づく外部 IM チャネルを作成します。

`POST /api/v1/forward/channels`

外部メッセージングプラットフォーム向けのチャネルインスタンスを作成します。チャネルは受信 IM メッセージを受け取り、設定されたプロバイダーを通じて返信を送信します。

## Headers

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

## Body parameters

| Parameter                         | Type   | Required    | Description                                                                                                                                                                                     |
| --------------------------------- | ------ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `identity_id`                     | string | Yes         | Forward Identity ID。呼び出し元に属し、有効になっている必要があります。                                                                                                                                                   |
| `template_id`                     | string | Yes         | チャネルがセッションを作成する際に使用する Forward Template ID。                                                                                                                                                      |
| `channel_type`                    | string | Yes         | チャネルタイプ。現在は `wechat`、`wecom`、`feishu`、`dingtalk` をサポートします。                                                                                                                                      |
| `name`                            | string | No          | チャネルの表示名。                                                                                                                                                                                       |
| `channel_config.credentials`      | object | Conditional | チャネルの実行時認証情報。QR 認可チャネルでは省略できます。直接認証情報を使うチャネルはプロバイダー固有のフィールドを使用します。`feishu` は `app_id`/`app_secret`、`dingtalk` は `client_id`/`client_secret`、`wecom` は `bot_id`/`secret` を使用します。認証情報は平文では返されません。 |
| `channel_config.response_options` | object | No          | 返信の表示設定。                                                                                                                                                                                        |

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/channels' \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "identity_id": "idn_019eabc123",
    "template_id": "tmpl_support",
    "channel_type": "feishu",
    "name": "Support Feishu channel",
    "channel_config": {
      "credentials": {
        "app_id": "...",
        "app_secret": "..."
      },
      "response_options": {
        "include_tool_calls": false,
        "include_thinking": false
      }
    }
  }'
```

## Example response

**HTTP 201 Created**

```json theme={null}
{
  "id": "channel_019eabc123",
  "type": "channel",
  "identity_id": "idn_019eabc123",
  "template_id": "tmpl_support",
  "channel_type": "feishu",
  "name": "Support Feishu channel",
  "enabled": true,
  "binding_status": "bound",
  "channel_config": {
    "response_options": {
      "include_tool_calls": false,
      "include_thinking": false
    }
  },
  "created_at": "2026-06-18T10:00:00Z",
  "updated_at": "2026-06-18T10:00:00Z"
}
```

## Response fields

| Field                             | Type    | Description                       |
| --------------------------------- | ------- | --------------------------------- |
| `id`                              | string  | チャネル ID。プレフィックスの例は `channel_` です。 |
| `type`                            | string  | 常に `channel`。                     |
| `identity_id`                     | string  | 紐づけられた Forward Identity ID。       |
| `template_id`                     | string  | 紐づけられた Forward Template ID。       |
| `channel_type`                    | string  | 外部チャネルタイプ。                        |
| `enabled`                         | boolean | 手動での有効化・無効化スイッチ。                  |
| `binding_status`                  | string  | `unbound`、`bound`、または `expired`。  |
| `channel_config.response_options` | object  | 返信の表示設定。                          |

## Errors

| HTTP | Type                    | Code                         | Trigger                   |
| ---- | ----------------------- | ---------------------------- | ------------------------- |
| 400  | `invalid_request_error` | `channel_type_unsupported`   | チャネルタイプがサポートされていません。      |
| 404  | `not_found_error`       | `channel_template_not_found` | Template が存在しないか、参照できません。 |
| 404  | `not_found_error`       | `channel_identity_not_found` | Identity が存在しないか、参照できません。 |
| 409  | `conflict_error`        | `channel_identity_disabled`  | Identity が無効になっています。      |
| 409  | `conflict_error`        | `channel_auth_required`      | 必要な認証情報または QR 認可が不足しています。 |
| 502  | `api_error`             | `channel_auth_failed`        | 基盤となるチャネルの認可に失敗しました。      |

## Notes

* 新規チャネルはデフォルトで `enabled=true` になります。
* チャネルが受信メッセージを処理できるのは、`enabled=true` かつ `binding_status="bound"` の場合のみです。
* 受信処理を一時的に停止するには、Update Channel で `enabled=false` を指定することをおすすめします。

## Related

<CardGroup cols={2}>
  <Card title="チャネル QR セッションの作成" icon="qrcode" href="/cloud-agents/api/forward/channels/create-qr-session" />

  <Card title="チャネルの一覧取得" icon="list" href="/cloud-agents/api/forward/channels/list" />
</CardGroup>
