API 参考

会话

列出会话

实时列出账号下的会话。limit 范围 1..100,默认 20;type 是逗号分隔的 user / group / channel 精确值,不会 trim。WhatsApp 未传 label_id 时只返回“特别关注”会话。cursor 不透明,失效或伪造游标可能被拒绝,也可能按渠道重新从头分页。

GEThttps://api.unifyport.ai/v1/accounts/{account_id}/conversations

支持的渠道

TelegramWhatsAppLINEXFacebookTikTok

调用前准备

在服务端使用资源所属工作区的 X-Api-Key。运行示例前替换所有占位符。

参数从哪里取得
account_id
从创建或查询账号的响应取得 data.id。账号标识属于 X-Api-Key 对应的工作区。 获取账号

请求参数

请求头

X-Api-Key
string必填

工作区 API Key,工作区由该请求头解析得到。

路径参数

account_id
string必填

用于该 conversations 路由的标识符。

查询参数

type
string

逗号分隔的精确枚举值:user、group 或 channel。不去除空格、不转换大小写,也不忽略空项。非法值返回 400 invalid_conversation_type。WhatsApp 的 group 包含社群公告群,所有 WhatsApp 群会话均返回 type=group。

cursor
string

渠道不透明游标,应原样回传上一响应的 next_cursor;省略或留空从第一页开始。伪造、失效或跨查询复用的游标可能被忽略、重置为第一页或返回渠道错误,不得依赖统一的 400 响应。

limit
integer

单页数量范围 1..100;各列表接口的默认值见对应页面说明。

minimum: 1 · maximum: 100

label_id
string

渠道标签精确标识;WhatsApp 省略时返回“特别关注”会话。

请求体

该接口无需 JSON 请求体。

如何理解结果

按本接口的响应字段和 HTTP 状态判断结果,再通过相关操作选择下一步。

响应 200 OK

{
  "request_id": "<REQUEST_ID>",
  "data": {
    "items": [
      {
        "conversation_id": "peer_example",
        "type": "user",
        "title": "Display name",
        "avatar_url": "",
        "unread_count": 3,
        "last_message_at": "2026-05-13T10:00:00Z"
      }
    ],
    "next_cursor": "",
    "has_more": false
  }
}

响应体

conversation_id
string

会话标识,发送消息或调用会话路由时作为目标使用。

type
string

标准会话类型:user、group 或 channel。WhatsApp 社群公告群继续使用 group。

enum: user, group, channel

title
string

会话的显示标题。

username
string

渠道提供时返回的会话用户名。

avatar_url
string

头像 URL,未设置时为空字符串。

description
string

群组或频道描述,存在时返回。

last_message_at
string

最近一条消息的 RFC3339 时间戳。

format: date-time

last_message_text
string

最近一条消息的文本摘要,存在时返回。

unread_count
integer

会话中的未读消息数。

format: int64

members_count
integer

成员数量;群组会话时返回。

format: int64

subscribers_count
integer

频道类会话的订阅者数量,存在时返回。

format: int64

is_pinned
boolean

该会话是否被当前账号置顶。

is_muted
boolean

该会话是否被当前账号静音。

created_at
string

渠道提供时返回的会话创建时间。

format: date-time

extra
object

渠道扩展字段;WhatsApp 群会话可包含公告群分类,会话列表不保证提供该分类。

is_announcement_group
boolean

仅 WhatsApp 群提供。true 表示已确认是社群公告群,false 表示本次资料已确认不符合公告群条件;缺失表示未知,不返回 null。此分类不表示当前账号具备发送消息的权限。

next_cursor
string

指向下一页的不透明游标,回传作为 cursor 使用;空字符串表示没有更多页。

has_more
boolean

当本页之外还有更多结果时为 true。

响应

200

200 OK

请求成功,响应体示例如上。

400

请求错误

请求体、路径或参数不合法。

401

未授权

X-Api-Key 请求头缺失或无效。

403

禁止访问

请求已识别,但不允许执行该操作。

404

未找到

未找到请求的资源;请结合 error.code 和当前操作核对。

409

冲突

当前操作与已有的渠道账号或资源冲突。

500

服务端错误

服务端遇到了未预期的错误。

501

渠道未实现

所选渠道尚未实现该操作。

502

上游网关错误

渠道适配器或上游渠道未能完成该操作。

失败后怎么处理

检查 HTTP 状态和 error.code/numeric_code,保存 request_id 用于排查。按原因修正参数、继续授权或检查运行态。重试发送及其他写操作前先确认上一次结果,避免重复操作。 错误码参考

结合当前操作读取 HTTP 状态、error.code 和 error.numeric_code。数字码按字符串处理。保留 request_id 排障;它不是幂等键或任务标识。

invalid_conversation_type · 37000 · 400

type 必须为 user、group 或 channel。

处理与重试: 按当前操作与渠道条件修正参数后再请求。重复提交相同的无效请求不会解决错误。

示意 JSON;message 随实际原因变化 · 400 · 37000
{
  "request_id": "req_example",
  "error": {
    "code": "invalid_conversation_type",
    "numeric_code": "37000",
    "message": "Field 'type' must be one of: user, group, channel"
  }
}
invalid_request · 10000 · 400

检查 JSON 请求体和必填字段。

处理与重试: 按当前操作与渠道条件修正参数后再请求。重复提交相同的无效请求不会解决错误。

示意 JSON;message 随实际原因变化 · 400 · 10000
{
  "request_id": "req_example",
  "error": {
    "code": "invalid_request",
    "numeric_code": "10000",
    "message": "Invalid request parameters"
  }
}
invalid_target_workspace · 11003 · 400

工作区覆盖目标为空或格式无效。移除覆盖请求头,改用目标工作区所属的 API Key。

触发条件: 适用于携带 X-Workspace-Id 工作区覆盖请求头的请求。

处理与重试: 按当前操作与渠道条件修正参数后再请求。重复提交相同的无效请求不会解决错误。

示意 JSON;message 随实际原因变化 · 400 · 11003
{
  "request_id": "req_example",
  "error": {
    "code": "invalid_target_workspace",
    "numeric_code": "11003",
    "message": "Invalid target workspace"
  }
}
provider_invalid_request · 30001 · 400

检查渠道专属字段及其格式。

处理与重试: 按当前操作与渠道条件修正参数后再请求。重复提交相同的无效请求不会解决错误。

示意 JSON;message 随实际原因变化 · 400 · 30001
{
  "request_id": "req_example",
  "error": {
    "code": "provider_invalid_request",
    "numeric_code": "30001",
    "message": "Provider rejected the request"
  }
}
unsupported_conversation_type · 37001 · 400

渠道不支持此操作,请选择能力表中支持的操作。

处理与重试: 选择文档列为支持的渠道与动作。重复请求不会增加能力或开通内测权限。

示意 JSON;message 随实际原因变化 · 400 · 37001
{
  "request_id": "req_example",
  "error": {
    "code": "unsupported_conversation_type",
    "numeric_code": "37001",
    "message": "Operation not supported for this conversation type"
  }
}
invalid_api_key · 11001 · 401

检查 API Key 是否正确且已启用。

处理与重试: 保留 request_id 与结构化错误码,先排查当前操作,再决定下一步。

示意 JSON;message 随实际原因变化 · 401 · 11001
{
  "request_id": "req_example",
  "error": {
    "code": "invalid_api_key",
    "numeric_code": "11001",
    "message": "Invalid API key"
  }
}
missing_api_key · 11000 · 401

请添加 X-Api-Key 请求头。

处理与重试: 保留 request_id 与结构化错误码,先排查当前操作,再决定下一步。

示例 · 401 · 11000
{
  "request_id": "req_xxx",
  "error": {
    "code": "missing_api_key",
    "numeric_code": "11000",
    "message": "Missing X-Api-Key header"
  }
}
workspace_override_forbidden · 11002 · 403

请求尝试使用此 API Key 无权使用的工作区覆盖。移除覆盖请求头,改用目标工作区所属的 API Key。

触发条件: 适用于携带 X-Workspace-Id 工作区覆盖请求头的请求。

处理与重试: 保留 request_id 与结构化错误码,先排查当前操作,再决定下一步。

示意 JSON;message 随实际原因变化 · 403 · 11002
{
  "request_id": "req_example",
  "error": {
    "code": "workspace_override_forbidden",
    "numeric_code": "11002",
    "message": "Workspace override is not allowed"
  }
}
target_workspace_not_found · 11004 · 404

覆盖指定的工作区不存在或不可用。核对工作区归属,移除覆盖请求头并使用目标工作区 API Key;重复请求不会增加访问权限。

触发条件: 适用于携带 X-Workspace-Id 工作区覆盖请求头的请求。

处理与重试: 核对目标标识、资源归属与当前工作区。不要把已确认缺失或无法访问的目标当作临时服务故障自动重试。

示意 JSON;message 随实际原因变化 · 404 · 11004
{
  "request_id": "req_example",
  "error": {
    "code": "target_workspace_not_found",
    "numeric_code": "11004",
    "message": "Target workspace not found"
  }
}
account_binding_not_found · 30006 · 409

账号尚无有效的渠道连接绑定,请检查账号状态。

处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。

示意 JSON;message 随实际原因变化 · 409 · 30006
{
  "request_id": "req_example",
  "error": {
    "code": "account_binding_not_found",
    "numeric_code": "30006",
    "message": "Account is not bound to an available server"
  }
}
egress_configuration_pending · 20032 · 409

当前无法确认或读取平台默认网络配置;这不表示账号已退出登录。

触发条件: 本操作使用平台分配的网络容量或账号固定的默认网络配置。

处理与重试: 保留 request_id,再次写入前核对账号或创建结果。等待容量或配置恢复,或联系支持;不要自动反复创建账号、更换网络或重启账号。

示意 JSON;message 随实际原因变化 · 409 · 20032
{
  "request_id": "req_example",
  "error": {
    "code": "egress_configuration_pending",
    "numeric_code": "20032",
    "message": "Account network configuration is pending verification"
  }
}
provider_not_ready · 30009 · 409

连接尚未就绪,请检查授权及 runtime_status 后再决定是否重试。

处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。

示意 JSON;message 随实际原因变化 · 409 · 30009
{
  "request_id": "req_example",
  "error": {
    "code": "provider_not_ready",
    "numeric_code": "30009",
    "message": "Provider client is not ready"
  }
}
provider_not_ready · 30014 · 409

此账号所需的渠道实例缺失。这是运行实例可用性问题,不证明授权已过期。

处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。

适用渠道: WhatsApp

示意 JSON;message 随实际原因变化 · 409 · 30014
{
  "request_id": "req_example",
  "error": {
    "code": "provider_not_ready",
    "numeric_code": "30014",
    "message": "Provider instance is missing"
  }
}
provider_not_ready · 30015 · 409

渠道运行进程已停止。启动前确认这是否为预期状态;运行态停止本身不等于已登出。

处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。

适用渠道: WhatsApp

示意 JSON;message 随实际原因变化 · 409 · 30015
{
  "request_id": "req_example",
  "error": {
    "code": "provider_not_ready",
    "numeric_code": "30015",
    "message": "Provider runtime is stopped"
  }
}
list_conversations_failed · 20020 · 500

核对 account_id,并使用账号所属工作区的 X-Api-Key。此工作区下未找到的账号不能用当前 Key 访问。

触发条件: 适用于账号不存在的情况;保留原 HTTP 状态和操作 code,通过 numeric_code 细分账号缺失。

处理与重试: 核对目标标识、资源归属与当前工作区。不要把已确认缺失或无法访问的目标当作临时服务故障自动重试。

示意 JSON;message 随实际原因变化 · 500 · 20020
{
  "request_id": "req_example",
  "error": {
    "code": "list_conversations_failed",
    "numeric_code": "20020",
    "message": "Account not found"
  }
}
list_conversations_failed · 30010 · 500

渠道未能完成本次操作。message 可能在 “Provider operation failed:” 后附带原始原因;原因文本可变,不是稳定的程序接口。

触发条件: 适用于渠道未提供更具体失败分类的情况,保留当前操作的错误。

处理与重试: 保留 request_id,核对目标标识与账号访问范围。查明原因后再重试查询;查询失败不等于结果为空或资源不存在。

适用渠道: WhatsApp

示意 JSON;message 随实际原因变化 · 500 · 30010
{
  "request_id": "req_example",
  "error": {
    "code": "list_conversations_failed",
    "numeric_code": "30010",
    "message": "Provider operation failed"
  }
}
list_conversations_failed · 37003 · 500

列出会话:服务未能产生有效的查询结果。

处理与重试: 保留 request_id,核对目标标识与账号访问范围。查明原因后再重试查询;查询失败不等于结果为空或资源不存在。

示意 JSON;message 随实际原因变化 · 500 · 37003
{
  "request_id": "req_example",
  "error": {
    "code": "list_conversations_failed",
    "numeric_code": "37003",
    "message": "Failed to list conversations"
  }
}
unsupported_by_provider · 30003 · 501

渠道不支持此操作,请选择能力表中支持的操作。

处理与重试: 选择文档列为支持的渠道与动作。重复请求不会增加能力或开通内测权限。

示例 · 501 · 30003
{
  "request_id": "req_xxx",
  "error": {
    "code": "unsupported_by_provider",
    "numeric_code": "30003",
    "message": "Operation not supported by this provider"
  }
}
provider_adapter_not_found · 30004 · 502

渠道服务暂不可用,请检查状态或稍后再试;重试写操作前先确认上次结果。

处理与重试: 保留 request_id,核对目标标识与账号访问范围。查明原因后再重试查询;查询失败不等于结果为空或资源不存在。

示意 JSON;message 随实际原因变化 · 502 · 30004
{
  "request_id": "req_example",
  "error": {
    "code": "provider_adapter_not_found",
    "numeric_code": "30004",
    "message": "Provider adapter unavailable"
  }
}
provider_unavailable · 30002 · 502

渠道服务暂不可用,请检查状态或稍后再试;重试写操作前先确认上次结果。

处理与重试: 保留 request_id,核对目标标识与账号访问范围。查明原因后再重试查询;查询失败不等于结果为空或资源不存在。

示例 · 502 · 30002
{
  "request_id": "req_example_provider_unavailable",
  "error": {
    "code": "provider_unavailable",
    "numeric_code": "30002",
    "message": "Provider service unavailable"
  }
}
provider_unavailable · 30010 · 502

渠道未能完成本次操作。message 可能在 “Provider operation failed:” 后附带原始原因;原因文本可变,不是稳定的程序接口。

处理与重试: 保留 request_id,核对目标标识与账号访问范围。查明原因后再重试查询;查询失败不等于结果为空或资源不存在。

适用渠道: WhatsApp

示例 · 502 · 30010
{
  "request_id": "req_example_operation_failed",
  "error": {
    "code": "provider_unavailable",
    "numeric_code": "30010",
    "message": "Provider operation failed: Example operation could not be completed"
  }
}
provider_unavailable · 30021 · 502

本次请求时账号未连接到消息平台。WhatsApp 添加联系人可返回 500 / create_contact_failed / 30021。这不证明账号已退出登录,也不保证当前运行态仍为 disconnected;先查询当前状态,再选择恢复动作。

处理与重试: 暂停依赖连接的业务操作。先调用 POST /v1/accounts/{account_id}/runtime/refresh,按最新状态恢复,确认 runtime_status=running 后再请求业务接口。重发前确认上一次写入结果。

适用渠道: WhatsApp

示例 · 502 · 30021
{
  "request_id": "req_example_connection_disconnected",
  "error": {
    "code": "provider_unavailable",
    "numeric_code": "30021",
    "message": "example operation: websocket not connected"
  }
}