Skip to main content
Channels

创建 Channel

POST /api/v1/forward/channels 创建外部消息平台的 Channel 实例,用于接收外部 IM 上行消息并发送回复。

请求头

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

请求体参数

参数类型是否必填说明
identity_idstring条件必填fixed 模式必填;pairing 模式不传。
identity_resolution.modestringIdentity 解析模式:fixed(默认)或 pairing
template_idstring条件必填fixed 模式必填;pairing 模式不传。
channel_typestring渠道类型,当前支持 wechatwecomfeishudingtalk
namestringChannel 展示名。
enabledboolean人工启停开关,默认 true。传 false 可创建后暂不处理上行消息。
channel_config.credentialsobject条件必填渠道运行凭据。扫码授权类渠道可省略;直连凭据类渠道按 channel_type 传入:feishuapp_id/app_secretdingtalkclient_id/client_secretwecombot_id/secret。凭据不明文回显。
channel_config.response_optionsobject回复内容可见性配置。

示例请求

curl -s -X POST 'https://api.qoder.com.cn/api/v1/forward/channels' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "identity_id": "idn_019eabc123",
  "identity_resolution": {
    "mode": "fixed"
  },
  "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
    }
  }
}'
pairing 模式只创建渠道连接,不在创建时指定 Identity 或 Template:
{
  "identity_resolution": {
    "mode": "pairing"
  },
  "channel_type": "feishu",
  "name": "Support Feishu channel"
}

示例响应

HTTP 201 Created
{
  "id": "channel_019eabc123",
  "type": "channel",
  "identity_id": "idn_019eabc123",
  "identity_resolution": {
    "mode": "fixed"
  },
  "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|nullfixed 模式为绑定的 Forward Identity ID;pairing 模式为 null
identity_resolution.modestringIdentity 解析模式:fixedpairing
template_idstring|nullfixed 模式为绑定的 Forward Template ID;pairing 模式为 null
channel_typestring外部渠道类型。
enabledboolean人工启停开关。
binding_statusstringunboundboundexpired

错误码

HTTPType触发条件
400invalid_request_error渠道类型不支持。
400invalid_request_errorIdentity 解析模式与 identity_id/template_id 组合不匹配。
400invalid_request_error缺少必要凭据。
401authentication_errorPAT 或 SAT 无效或已过期。
403permission_error渠道数量超出配额上限。
404not_found_errorTemplate 不存在或不可见。
404not_found_errorIdentity 不存在或不可见。
409conflict_errorIdentity 已停用。
409conflict_error凭证校验冲突。
502api_error渠道服务不可用。

注意事项

  • enabled 为可选入参,默认 true;传 false 可在绑定完成前暂不启用。
  • 只有 enabled=truebinding_status=bound 时才可处理上行消息。
  • 如果只是临时停止处理上行消息,优先使用 Update Channel 设置 enabled=false
  • fixed 模式始终使用创建时指定的 Identity 和 Template。
  • pairing 模式下 Channel 仅表示传输连接,Identity 和 Template 由 Pairing API 按消息范围绑定。
  • Identity 解析模式创建后不可修改。

相关