API 参考
账号POST

创建账号

创建一个渠道账号。支持的 provider 包括 telegram、whatsapp、twitter、line、zalo 等;按账号连接流程选择对应 auth_mode。当所选 provider 与 auth_mode 组合需要手机号时(例如 WhatsApp + auth_mode=code),手机号必须通过 provider_data.phone 在此处提供 —— 会被持久化到账号,并在后续认证步骤中自动回放。

https://api.unifyport.ai/v1/accounts

请求头

X-Api-Key
string必填

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

Content-Type
string必填

发送 JSON 请求体时使用 application/json。

路径参数

该接口没有路径参数。

请求体

name
string必填

可读的账号名称。

provider
string必填

渠道方标识,例如 telegram、whatsapp、line 或 zalo。

region
string必填

用于分配的渠道区域。请通过 列出渠道区域 选择 allocatable: true 的区域。

auth_mode
string

认证流程:code、qrcode 或 session。

provider_data
object

渠道专属配置,请勿在日志中暴露其中的密钥字段。

metadata
object

平台侧的环境标签元数据。

响应体

id
string

账号唯一标识(acc_...),用于账号维度的路由。

name
string

可读的账号名称。

provider
string

渠道标识,例如 telegram、whatsapp、line、twitter 或 zalo。

region
string

该账号被分配到的渠道区域。

status
string

账号生命周期状态,例如 active。

runtime_status
string

标准化的运行时状态,取值之一:unknown、starting、running、stopping、stopped、reconnecting、disconnected 或 error。

auth_mode
string

账号使用的认证流程:code、qrcode 或 session。

capabilities
string[]

账号已启用的能力,例如 send_message 与 receive_message。

provider_account_ref
string

渠道侧标识,可附加用于将该账号与你自有系统关联。

响应

201
201 Created

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

400
请求错误

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

401
未授权

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

409
冲突

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

500
服务端错误

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

请求

curl -X POST https://api.unifyport.ai/v1/accounts \
  -H "X-Api-Key: <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Telegram Production",
  "provider": "telegram",
  "region": "global",
  "status": "active",
  "auth_mode": "qrcode",
  "capabilities": ["send_message", "receive_message"],
  "provider_data": {},
  "metadata": {
    "env": "production"
  },
  "provider_account_ref": "provider-side-identifier"
}'

响应

{
  "data": {
    "id": "acc_example",
    "name": "Telegram Production",
    "provider": "telegram",
    "region": "global",
    "status": "active",
    "runtime_status": "stopped",
    "auth_mode": "qrcode",
    "capabilities": ["send_message", "receive_message"],
    "provider_account_ref": "provider-side-identifier"
  }
}