帳號
建立帳號
建立渠道帳號。auth_mode 必填,淨係可以係 qrcode、code 或 session。當 provider 配 auth_mode 需要手機號(例如 WhatsApp + auth_mode=code),一定要經 provider_data.phone 提供;之後認證動作會重用。 餘額模式直接建號,無須先取得報價;201 表示建號與扣款已提交,授權前仍須核對 billing.state。同工作區建號進行中會回傳 409 wallet_account_creation_in_progress。Idempotency-Key 可選;逾時應先核對,只有沿用原鍵重試才可避免重複購買。
https://api.unifyport.ai/v1/accounts支援渠道
呼叫前準備
在伺服器端使用資源所屬工作區的 X-Api-Key,執行範例前替換所有預留位置。
使用目標工作區的 API Key。餘額模式帳號按 30 天以 USD 計費;錢包餘額與儲值請在 Dashboard 查看。
請求參數
請求標頭
X-Api-Key工作區 API Key,工作區會由呢個標頭解析得出嚟。
Content-Type發送 JSON 請求內容嘅時候請用 application/json。
Idempotency-Key餘額建號可選帶單一 Idempotency-Key;未知結果重試請沿用原鍵。不帶時,前一筆完成後再次請求會新建帳號。
請求內容
name可讀嘅帳號名稱。
provider客戶可用嘅渠道標識:telegram、whatsapp、whatsapp-protocol、line、twitter、zalo 或 tiktok。
enum: telegram, whatsapp, line, twitter, zalo, tiktok, whatsapp-protocol, x, x_client, twitter_client
region用嚟分配嘅渠道區域。記住經 列出渠道區域 揀返個 allocatable: true 嘅區域。
minLength: 1
status帳號業務狀態,例如 active 或者 inactive。
runtime_status渠道支援經帳號設定更改時,要求設定嘅運行狀態。
enum: unknown, starting, running, stopping, stopped, reconnecting, disconnected, error
auth_mode建立帳號時必填;淨係可以係 qrcode、code 或 session。
enum: qrcode, code, session
capabilities[]帳號能力。PATCH 時唔傳代表保留,傳 [] 代表清空,null 無效。
metadata平台側中繼資料。PATCH 時唔傳代表保留,傳 {} 代表清空,null 無效。
provider_account_ref渠道側帳號識別碼,通常會喺授權完成之後寫入。
provider_data渠道設定。PATCH 時唔傳代表保留,{} 清空而且唔補預設憑證,null 無效。TikTok provider_data.enable_comment 只接受 Boolean,預設 false;字串、數字、null 回傳 400 invalid_request。在線修改要 reconnect,start 成功唔代表設定已套用;關閉唔會撤回已排隊事件。Telegram 嘅 code、qrcode、session 都可以省略 api_id 同 api_hash;自訂憑證要係同一應用程式嘅成對字串。建立時冇指定自訂憑證、非空設定替換時缺省憑證欄位,都用平台預設值;所需預設設定唔可用就會請求失敗。平台預設憑證變更唔會替換現有帳號憑證。唔好記錄金鑰。
proxy呢個帳號可選嘅對外 proxy 設定。
如何理解結果
餘額模式直接建號,無須先取得報價;201 表示建號與扣款已提交,授權前仍須核對 billing.state。同工作區建號進行中會回傳 409 wallet_account_creation_in_progress。Idempotency-Key 可選;逾時應先核對,只有沿用原鍵重試才可避免重複購買。
回應 201 · PREPAID_QUOTA
{
"request_id": "<REQUEST_ID>",
"data": {
"id": "acc_example",
"name": "Telegram Production",
"provider": "telegram",
"region": "<REGION>",
"status": "active",
"runtime_status": "stopped",
"auth_mode": "qrcode",
"capabilities": [
"send_message",
"receive_message"
]
}
}
回應 201 · ACCOUNT_WALLET_30D
{
"request_id": "<REQUEST_ID>",
"data": {
"id": "acc_example",
"name": "Messaging account",
"provider": "telegram",
"region": "<REGION>",
"status": "active",
"runtime_status": "stopped",
"auth_mode": "qrcode",
"capabilities": [
"send_message",
"receive_message"
],
"billing": {
"period_start_at": "2026-10-19T00:00:00Z",
"period_end_at": "2026-11-18T00:00:00Z",
"amount_minor": 1000,
"currency": "USD",
"operation_id": "op_example",
"state": "ACTIVE"
}
}
}
回應內容
provider_profileobject渠道回報嘅資料,例如 display_name。帳號未認證之前唔會有。
provider_profile渠道回報嘅資料,例如 display_name。帳號未認證之前唔會有。
id渠道側帳號識別碼。WhatsApp 回傳 LID;帳號資料同步完成前可能省略。
device_id僅 WhatsApp 帳號詳情在可確認目前工作階段時提供的可選登入裝置編號;重新授權後可能改變,不作永久裝置識別。
minimum: 0 · maximum: 65535
phone已歸一化嘅帳號電話號碼,冇空格、連字號同開頭加號。
username渠道回報嘅 username(如有)。
display_name帳號展示名稱;WhatsApp 按 BusinessName 優先、PushName 回退嘅規則生成。
push_nameWhatsApp 目前帳號設定嘅 PushName;其他渠道冇定義呢個欄位嘅語義。
business_nameWhatsApp BusinessName;渠道冇回傳時呢個欄位會缺失。
first_name渠道回報嘅名(如有)。
last_name渠道回報嘅姓(如有)。
avatar_url渠道回報嘅帳號頭像 URL(如有)。
bio渠道回報嘅帳號簡介或狀態文字(如有)。
platformWhatsApp 配對時回報嘅登入平台識別碼。請當佢係不透明字串並兼容未知值;其他渠道冇定義呢個欄位嘅語義。呢個欄位同 device_platform 唔同。
billingobject訊息帳號已付週期,僅餘額帳號存在;不能依錢包餘額推斷已購買。
billing訊息帳號已付週期,僅餘額帳號存在;不能依錢包餘額推斷已購買。
period_start_at伺服器回傳的已付週期起點。
format: date-time
period_end_at伺服器回傳的已付週期終點。
format: date-time
amount_minor伺服器不可變金額,單位為 USD 分,須以精確整數處理。
minimum: 1 · format: int64
currency僅 USD。
operation_id來自 billing.operation_id 或刪除回應的公開標識,於原工作區原樣重用。
state計費或操作狀態,不證明帳號已授權、上線或退款已入帳。
enum: ACTIVE, DELETING, DELETED, COMPENSATED, REVIEW
id帳號嘅唯一識別碼(acc_...)。喺帳號層級嘅路由入面用佢。
name可讀嘅帳號名稱。
provider管道識別碼。呼叫其他介面時原樣使用 API 回傳的值;此介面的回傳範圍請看下方列舉。
enum: telegram, whatsapp, line, twitter, zalo, tiktok, whatsapp-protocol
region帳號分配落去嘅渠道區域。
status帳號嘅生命週期狀態,例如 active。
runtime_status標準化嘅運行狀態,係 unknown、starting、running、stopping、stopped、reconnecting、disconnected 或者 error 其中一個。
enum: unknown, starting, running, stopping, stopped, reconnecting, disconnected, error
auth_mode帳號用嘅認證流程:code、qrcode 或者 session。
capabilities[]帳號開咗嘅能力,例如 send_message 同 receive_message。
metadata你自己存喺帳號上面嘅環境標籤。
provider_account_ref渠道側嘅識別碼,你可以扣返上去,攞嚟同你自己系統嘅帳號對應。
proxy帳號綁定嘅對外 proxy 設定,未設定就唔會回。
回應
201201 Created
請求成功,回應內容嘅例子如上。
400請求錯誤
請求內容、路徑或者參數無效。
401未授權
X-Api-Key 請求標頭缺少或者無效。
403禁止存取
請求已識別,但唔允許執行呢個操作。
404搵唔到資源
搵唔到請求嘅資源;請結合 error.code 同目前操作核對。
409衝突
目前操作同現有嘅渠道帳號或者資源衝突。
500伺服器錯誤
服務遇到咗未預期嘅錯誤。
503服務不可用
所需嘅後端服務暫時不可用。
失敗後如何處理
檢查 HTTP 狀態和 error.code/numeric_code,保留 request_id。依原因修正參數、繼續授權或檢查狀態。重試傳送及寫入前確認上次結果,避免重複操作。 錯誤碼參考
請按目前操作一併讀取 HTTP 狀態、error.code 同 error.numeric_code。數字碼以字串處理。保留 request_id 排查;佢唔係冪等鍵或任務識別碼。
- auth_mode_phone_required · 20019 · 400
此授權方式要求建立帳戶時填寫 provider_data.phone。
處理與重試: 按目前操作同渠道條件修正參數後再請求。重複提交相同嘅無效請求唔會解決錯誤。
示意 JSON;message 會隨實際原因變化 · 400 · 20019
{ "request_id": "req_example", "error": { "code": "auth_mode_phone_required", "numeric_code": "20019", "message": "Phone number is required for this auth mode" } }- 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" } }- unsupported_provider_auth_mode · 20018 · 400
請使用此渠道支援的 auth_mode。
處理與重試: 選擇文件列為支援嘅渠道同動作。重複請求唔會增加能力或開通內測權限。
示意 JSON;message 會隨實際原因變化 · 400 · 20018
{ "request_id": "req_example", "error": { "code": "unsupported_provider_auth_mode", "numeric_code": "20018", "message": "Auth mode not supported by this provider" } }- wallet_invalid_request · 20021 · 400
請核對餘額建號參數及可選的 Idempotency-Key 請求標頭。
處理與重試: 按目前操作同渠道條件修正參數後再請求。重複提交相同嘅無效請求唔會解決錯誤。
示意 JSON;message 會隨實際原因變化 · 400 · 20021
{ "request_id": "req_example", "error": { "code": "wallet_invalid_request", "numeric_code": "20021", "message": "Invalid wallet account request" } }- 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_allocation_busy · 20011 · 409
帳戶正在分配,請稍後重試。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20011
{ "request_id": "req_example", "error": { "code": "account_allocation_busy", "numeric_code": "20011", "message": "Allocation is busy in the current region; please retry later" } }- duplicate_provider_account · 20015 · 409
工作區內已有另一個帳戶綁定相同渠道身分。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20015
{ "request_id": "req_example", "error": { "code": "duplicate_provider_account", "numeric_code": "20015", "message": "A provider account with the same identity already exists in this workspace" } }- no_allocatable_server · 20013 · 409
此區域暫無可分配資源,請查詢其他可分配區域。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20013
{ "request_id": "req_example", "error": { "code": "no_allocatable_server", "numeric_code": "20013", "message": "No allocatable server in the current region" } }- wallet_account_creation_in_progress · 20030 · 409
現時工作區已有餘額帳號正在建立,請等待完成後再試。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20030
{ "request_id": "req_example", "error": { "code": "wallet_account_creation_in_progress", "numeric_code": "20030", "message": "Account creation is in progress; please wait" } }- wallet_idempotency_conflict · 20024 · 409
冪等鍵已綁定其他業務參數,請先核對原操作結果,避免重複建號。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20024
{ "request_id": "req_example", "error": { "code": "wallet_idempotency_conflict", "numeric_code": "20024", "message": "Idempotency key was used for a different request" } }- wallet_insufficient_funds · 20023 · 409
錢包餘額不足,擁有者可增值後確認原請求。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20023
{ "request_id": "req_example", "error": { "code": "wallet_insufficient_funds", "numeric_code": "20023", "message": "Insufficient wallet balance" } }- wallet_workspace_disabled · 20022 · 409
新餘額消費已關閉,不代表現有帳號操作已取消。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20022
{ "request_id": "req_example", "error": { "code": "wallet_workspace_disabled", "numeric_code": "20022", "message": "New wallet purchases are disabled" } }- workspace_account_quota_exceeded · 20014 · 409
工作區訊息帳戶額度已用滿,請檢查用量與額度。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 409 · 20014
{ "request_id": "req_example", "error": { "code": "workspace_account_quota_exceeded", "numeric_code": "20014", "message": "Workspace account quota exceeded" } }- create_account_failed · 20002 · 500
建立帳號:資源建立失敗或無法確認建立結果。
處理與重試: 再次建立前先列出或查詢已有資源,確認上次建立是否生效。修正原因並保留 request_id,唔好自動建立重複資源。
示意 JSON;message 會隨實際原因變化 · 500 · 20002
{ "request_id": "req_example", "error": { "code": "create_account_failed", "numeric_code": "20002", "message": "Failed to create account" } }- allocation_service_unavailable · 20012 · 503
帳戶分配服務暫時無法使用,請稍後重試。
處理與重試: 保留 request_id 同結構化錯誤碼,先排查目前操作,再決定下一步。
示意 JSON;message 會隨實際原因變化 · 503 · 20012
{ "request_id": "req_example", "error": { "code": "allocation_service_unavailable", "numeric_code": "20012", "message": "Allocation service is temporarily unavailable" } }- wallet_unavailable · 20028 · 503
錢包資料或設定暫時無法使用;寫入失敗可能結果未知,請核對原操作。
處理與重試: 先讀取資源目前狀態,確認上次改動結果,再決定是否重試。保留 request_id;結果未知時唔好自動重複寫入。
示意 JSON;message 會隨實際原因變化 · 503 · 20028
{ "request_id": "req_example", "error": { "code": "wallet_unavailable", "numeric_code": "20028", "message": "Wallet service is unavailable" } }