Skip to main content
Channels

完成 Channel 配对

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

请求头

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

请求体参数

参数类型是否必填说明
codestringChannel 消息中展示的 6 位 Pairing Code。
identity_idstring要绑定的 Forward Identity ID。
template_idstring要绑定的 Forward Template ID。

示例请求

curl -s -X POST 'https://api.qoder.com.cn/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"
  }'

示例响应

HTTP 200 OK
{
  "id": "pair_019eabc123",
  "type": "channel_pairing",
  "channel_id": "channel_019eabc123",
  "identity_id": "idn_019eabc123",
  "template_id": "tmpl_workspace_dev",
  "status": "active",
  "paired_at": "2026-07-16T10:00:00Z"
}

响应字段

字段类型说明
idstringPairing ID,解除配对时使用。
typestring固定为 channel_pairing
channel_idstringChannel ID。
identity_idstring绑定的 Forward Identity ID。
template_idstring绑定的 Forward Template ID。
statusstring配对成功时为 active
paired_atstring配对完成时间。

错误码

HTTPType触发条件
400invalid_request_errorPairing Code 格式无效、不存在,或 Channel 不是 pairing 模式。
401authentication_errorPAT 或 SAT 无效或已过期。
404not_found_errorChannel、Identity 或 Template 不存在或对当前调用方不可见。
409conflict_errorPairing Code 已绑定到不同的 Identity 或 Template。

注意事项

  • 服务端使用 PAT 解析出的 user_id 与规范化后的 code 定位待配对记录——请求中无需传 channel_id
  • Pairing Code 在单个用户范围内唯一;响应中返回服务端解析的 channel_id
  • 使用相同 code、相同 Identity 和 Template 重复提交是幂等的,返回已有 Pairing;任何不同的绑定值将返回冲突。
  • Channel 是传输连接;Pairing 是该 direct/room scope 的实际执行上下文绑定。
  • 配对成功后 Forward 会尽力向原始会话发送成功通知;通知失败不会回滚 Pairing。

相关