Skip to main content

创建 Channel

创建绑定 Identity 和 Template 的外部 IM Channel。

请求头

Header是否必填说明
AuthorizationBearer <PAT>
Content-Typeapplication/json
Idempotency-Key有副作用请求可选的幂等键。

请求体参数

参数类型是否必填说明
identity_idstringForward Identity ID,必须属于当前调用方且已启用。
template_idstring收到消息并创建 Session 时使用的 Forward Template ID。
channel_typestring渠道类型,P0 支持 wechatwecomfeishudingtalk
namestringChannel 展示名。
enabledboolean人工启停开关,默认 true。传 false 可创建后暂不处理上行消息。
channel_config.credentialsobject条件必填渠道运行凭据。扫码授权类渠道可省略;直连凭据类渠道按 channel_type 传入:feishu 为 app_id/app_secret,dingtalk 为 client_id/client_secret,wecom 为 bot_id/secret。凭据不明文回显。
channel_config.response_optionsobject回复内容可见性配置。

示例请求

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_key": "...",
      "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"
}

响应字段

字段类型说明
idstringChannel ID,示例前缀 channel-
typestring固定为 channel
identity_idstring绑定的 Forward Identity ID。
template_idstring绑定的 Forward Template ID。
channel_typestring外部渠道类型。
enabledboolean人工启停开关。
binding_statusstringunboundboundexpired

错误

HTTPTypeCode触发条件
400invalid_request_errorchannel_type_unsupported渠道类型不支持。
404not_found_errorchannel_template_not_foundTemplate 不存在或不可见。
404not_found_errorchannel_identity_not_foundIdentity 不存在或不可见。
409conflict_errorchannel_identity_disabledIdentity 已停用。
409conflict_errorchannel_auth_required缺少必要凭据或需要先扫码授权。
502api_errorchannel_auth_failed渠道授权失败。
401authentication_errorTOKEN_INVALIDPAT 无效或已过期。

备注

  • user_id 由鉴权上下文内部解析,不对外暴露。
  • enabled 为可选入参,默认 true;传 false 可在绑定完成前暂不启用。
  • 只有 enabled=truebinding_status=bound 时才可处理上行消息。
  • P0 不支持删除或归档 Channel;需要停用时使用 Update Channel。

相关