Skip to main content
Channels

完成 Channel 配对

使用配对码或待配对记录 ID,为 Channel 消息范围绑定 Identity 与 Template。

POST /api/v1/forward/channel_pairings 仅适用于 identity_resolution.mode=pairing 的 Channel。

请求头

Header是否必填说明
AuthorizationBearer <PAT 或 SAT>
Content-Typeapplication/json
Idempotency-Key客户端生成的幂等键,用于安全重试。

请求体参数

参数类型是否必填说明
codestring二选一Channel 消息中显示的有效配对码,与 channel_pairing_id 恰好传一个。
channel_pairing_idstring二选一配对列表 返回的 id。按 ID 管理授权不受配对码过期影响。
identity_idstring要绑定的 Forward Identity ID。
template_idstring要绑定的 Forward Template ID。

示例请求

curl -s -X POST 'https://api.qoder.com/api/v1/forward/channel_pairings' \
  -H "Authorization: Bearer $QODER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: pairing-K7MP92" \
  -d '{
    "code": "K7MP92",
    "identity_id": "idn_019eabc123",
    "template_id": "tmpl_workspace_dev"
  }'
也可按 ID 完成配对,使用相同接口和鉴权:
{
  "channel_pairing_id": "pair_019eabc123",
  "identity_id": "idn_019eabc123",
  "template_id": "tmpl_workspace_dev"
}

示例响应

HTTP 200 OK
{
  "id": "pair_019eabc123",
  "type": "channel_pairing",
  "channel_id": "channel_019eabc123",
  "scope_type": "direct",
  "scope_external_id": "external_user_id",
  "scope_display_name": "测试用户",
  "identity_id": "idn_019eabc123",
  "template_id": "tmpl_workspace_dev",
  "status": "active",
  "paired_at": "2026-07-16T10:00:00Z"
}

响应字段

字段类型说明
idstringPairing ID。列表、详情、解除配对使用此值;定时任务 Sink 通过 channel_pairing_id 引用。
typestring固定为 channel_pairing
channel_idstringChannel ID。
scope_typestring配对范围:direct 私聊用户,room 群聊。
scope_external_idstring范围对应的外部用户或群 ID。
scope_display_namestring用户昵称或群名,未获取到时为空字符串。仅供展示,不作为授权依据。
identity_idstring绑定的 Forward Identity ID。
template_idstring绑定的 Forward Template ID。
statusstring配对成功时为 active
paired_atstring配对完成时间。

错误码

HTTPType触发条件
400invalid_request_errorcodechannel_pairing_id 未满足二选一、配对码无效/过期,或 Channel 不是 pairing 模式。
401authentication_errorPAT 或 SAT 无效或已过期。
404not_found_errorPair、Channel、Identity 或 Template 不存在或当前调用方不可见。
409conflict_errorPair 已绑定到其他 Identity/Template,或已解绑。

注意事项

  • 调用方须具备对应 Channel 的管理权限。
  • 重复绑定相同 Identity、Template 会返回成功;修改已有绑定请使用更新配对
  • 配对码已使用但绑定未完成时,可从配对列表获取 Pair ID 后重试。
  • 配对成功前发送的消息不会自动重放,请重新发送。

相关