全部產品
Search
文件中心

Qoder CN 系列:建立 Channel

更新時間:Jul 16, 2026

建立綁定 Identity 和 Template 的外部 IM Channel。

要求標頭

Header

是否必填

說明

Authorization

Bearer <PAT>

Content-Type

application/json

Idempotency-Key

有副作用請求可選的等冪鍵。

請求體參數

參數

類型

是否必填

說明

identity_id

string

Forward Identity ID,必須屬於當前調用方且已啟用。

template_id

string

收到訊息並建立 Session 時使用的 Forward Template ID。

channel_type

string

渠道類型,當前支援 wechatwecomfeishudingtalk

name

string

Channel 展示名。

enabled

boolean

人工啟停開關,預設 true。傳 false 可建立後暫不處理上行訊息。

channel_config.credentials

object

條件必填

渠道運行憑據。掃碼授權類渠道可省略;直連憑據類渠道按 channel_type 傳入:feishu 為 app_id/app_secret,dingtalk 為 client_id/client_secret,wecom 為 bot_id/secret。憑據不明文回顯。

channel_config.response_options

object

回複內容可見度配置。

樣本請求

curl -s -X POST 'https://api.qoder.com.cn/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",
  "enabled": true,
  "channel_config": {
    "credentials": {
      "app_id": "...",
      "app_secret": "..."
    },
    "response_options": {
      "include_tool_calls": false,
      "include_thinking": false
    }
  }
}'

樣本響應

HTTP 201 Created

{
  "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"
}

響應欄位

欄位

類型

說明

id

string

Channel 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

unboundboundexpired

錯誤

HTTP

Type

觸發條件

400

invalid_request_error

渠道類型不支援。

400

invalid_request_error

缺少必要憑據。

404

not_found_error

Template 不存在或不可見。

404

not_found_error

Identity 不存在或不可見。

409

conflict_error

Identity 已停用。

409

conflict_error

憑證校正衝突。

502

api_error

渠道服務不可用。

401

authentication_error

PAT 無效或已到期。

403

permission_error

渠道數量超出配額上限。

備忘

  • enabled 為可選入參,預設 true;傳 false 可在綁定完成前暫不啟用。

  • 只有 enabled=truebinding_status=bound 時才可處理上行訊息。

  • 如果只是臨時停止處理上行訊息,優先使用 Update Channel 設定 enabled=false

相關