账号连接
重连运行时
当账号在线但运行时连接异常时,重建与渠道的连接。
https://api.unifyport.ai/v1/accounts/{account_id}/runtime/reconnect支持的渠道
调用前准备
在服务端使用资源所属工作区的 X-Api-Key。运行示例前替换所有占位符。
先查询当前授权和运行态,再按目标选择操作。启动、停止、刷新和重连的用途不同;账号离线本身不代表需要重新授权。
参数从哪里取得
- account_id
- 从创建或查询账号的响应取得 data.id。账号标识属于 X-Api-Key 对应的工作区。 获取账号
请求参数
请求头
X-Api-Key工作区 API Key,工作区由该请求头解析得到。
Content-Type发送 JSON 请求体时使用 application/json。
路径参数
account_id用于该 runtime 路由的标识符。
请求体
该接口接收空 JSON 对象;请按请求示例发送 {}。
如何理解结果
读取 operation_status 和 runtime_status。reconnecting 仍需后续查询,发送前确认 running;auth_required 为 true 时继续对应渠道的授权流程。
响应 200 OK
{
"request_id": "<REQUEST_ID>",
"data": {
"runtime_status": "reconnecting"
}
}
响应体
account_id该响应所对应的渠道账号。
provider渠道标识。调用其他接口时原样使用 API 返回的值;此接口的返回范围见下方枚举。
enum: telegram, whatsapp, line, twitter, facebook, zalo, tiktok, whatsapp-protocol
action本次请求的动作。
enum: refresh_status, start, stop, reconnect
operation_status运行时动作被接受或完成的状态。
runtime_status标准化的运行时状态,取值之一:unknown、starting、running、stopping、stopped、reconnecting、disconnected 或 error。
enum: unknown, starting, running, stopping, stopped, reconnecting, disconnected, error
runtime_error动作未完成时的渠道运行时错误。
auth_required为 true 时,继续对应渠道的授权流程。仅在渠道返回授权材料,或已有经确认的授权流程尚未完成时返回此提示。未返回或为 false 不代表在线,连接状态请查看 runtime_status;仅有 disconnected 不能推断需要重新授权。运行态接口不返回 code、qrcode、auth_payload 或 provider_data,请从对应渠道的授权接口获取授权材料。
auth_status可选的授权状态,例如 pending、awaiting_qr_scan 或 passkey_required。有授权材料或经确认的未完成授权流程时才会返回。按渠道指南继续操作;完整状态与授权材料从授权接口查询,连接状态查看 runtime_status。
响应
200200 OK
请求成功,响应体示例如上。
400请求错误
请求体、路径或参数不合法。
401未授权
X-Api-Key 请求头缺失或无效。
403禁止访问
请求已识别,但不允许执行该操作。
404未找到
未找到请求的资源;请结合 error.code 和当前操作核对。
409冲突
当前操作与已有的渠道账号或资源冲突。
500服务端错误
服务端遇到了未预期的错误。
502上游网关错误
渠道适配器或上游渠道未能完成该操作。
失败后怎么处理
检查 HTTP 状态、error.code/numeric_code 和当前状态,保留 request_id。核对所选动作及渠道支持范围;有明确授权提示时才继续授权,重试前先确认运行态。 错误码参考
结合当前操作读取 HTTP 状态、error.code 和 error.numeric_code。数字码按字符串处理。保留 request_id 排障;它不是幂等键或任务标识。
- 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_action · 30005 · 400
无法识别此账号操作,请使用文档列出的操作。
处理与重试: 选择文档列为支持的渠道与动作。重复请求不会增加能力或开通内测权限。
示意 JSON;message 随实际原因变化 · 400 · 30005
{ "request_id": "req_example", "error": { "code": "unsupported_action", "numeric_code": "30005", "message": "Action not supported" } }- 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" } }- run_runtime_action_failed · 20008 · 500
调整运行态:运行态动作失败,本次响应本身不能确认连接最终状态。
处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。
示意 JSON;message 随实际原因变化 · 500 · 20008
{ "request_id": "req_example", "error": { "code": "run_runtime_action_failed", "numeric_code": "20008", "message": "Failed to run runtime action" } }- run_runtime_action_failed · 20020 · 500
核对 account_id,并使用账号所属工作区的 X-Api-Key。此工作区下未找到的账号不能用当前 Key 访问。
触发条件: 适用于账号不存在的情况;保留原 HTTP 状态和操作 code,通过 numeric_code 细分账号缺失。
处理与重试: 核对目标标识、资源归属与当前工作区。不要把已确认缺失或无法访问的目标当作临时服务故障自动重试。
示意 JSON;message 随实际原因变化 · 500 · 20020
{ "request_id": "req_example", "error": { "code": "run_runtime_action_failed", "numeric_code": "20020", "message": "Account not found" } }- run_runtime_action_failed · 30010 · 500
渠道未能完成本次操作。message 可能在 “Provider operation failed:” 后附带原始原因;原因文本可变,不是稳定的程序接口。
触发条件: 适用于渠道未提供更具体失败分类的情况,保留当前操作的错误。
处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。
适用渠道: WhatsApp
示意 JSON;message 随实际原因变化 · 500 · 30010
{ "request_id": "req_example", "error": { "code": "run_runtime_action_failed", "numeric_code": "30010", "message": "Provider operation failed" } }- provider_adapter_not_found · 30004 · 502
渠道服务暂不可用,请检查状态或稍后再试;重试写操作前先确认上次结果。
处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。
示意 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
渠道服务暂不可用,请检查状态或稍后再试;重试写操作前先确认上次结果。
处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。
示例 · 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:” 后附带原始原因;原因文本可变,不是稳定的程序接口。
处理与重试: 查询授权与运行态,再按目标状态和渠道支持选择刷新、启动或重连。连接问题本身不证明已登出;依赖连接的业务操作前确认 running。
适用渠道: 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 · 30020 · 502
whatsapp-protocol 同步请求以 numeric_code=30020 标识账号登录受限,可影响会话导入、运行态、发送与联系人查询,并保留当前操作的 HTTP 状态与 code。不要将 WhatsApp 的 20102 回调契约套用到此渠道。
处理与重试: 停止自动发送与重试,引导用户前往官方 WhatsApp 客户端检查并处理限制。问题解决并完成必要的重新授权后再恢复;此前为 running 不证明限制已解除。
适用渠道: WhatsApp Protocol
示例 · 502 · 30020
{ "request_id": "req_example_account_restricted", "error": { "code": "provider_unavailable", "numeric_code": "30020", "message": "Account login is restricted. Check the official WhatsApp app for details." } }- 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" } }