API 參考

帳號

攞帳號

回傳單一帳號嘅設定。出於安全考量,provider_data 入面嘅渠道憑證會被特登剔除唔返回。認證狀態(包括待掃嘅 QR 同驗證碼)會經 Authentication 系列介面單獨公開。

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

支援渠道

all

呼叫前準備

在伺服器端使用資源所屬工作區的 X-Api-Key,執行範例前替換所有預留位置。

參數從哪裡取得
account_id
從建立或查詢帳號的回應取得 data.id。帳號屬於 X-Api-Key 對應的工作區。 攞帳號

請求參數

請求標頭

X-Api-Key
string必填

工作區 API Key,工作區會由呢個標頭解析得出嚟。

路徑參數

account_id
string必填

用嚟識別嗰條 accounts 路由嘅 ID。

請求內容

呢個介面唔需要 JSON 請求內容。

如何理解結果

依本介面的回應欄位與 HTTP 狀態判斷結果,再透過相關操作選擇下一步。

回應 200 OK

{
  "request_id": "<REQUEST_ID>",
  "data": {
    "id": "acc_example",
    "name": "Telegram Production",
    "provider": "telegram",
    "region": "global",
    "status": "active",
    "runtime_status": "running",
    "auth_mode": "qrcode",
    "capabilities": [
      "send_message",
      "receive_message"
    ],
    "metadata": {
      "env": "production"
    },
    "provider_account_ref": "provider-side-identifier",
    "provider_profile": {
      "id": "778899",
      "phone": "8600000000000",
      "username": "production_bot",
      "display_name": "Production Bot",
      "first_name": "Production",
      "last_name": "Bot",
      "avatar_url": "https://example.com/avatar.jpg",
      "bio": "Customer support"
    }
  }
}

回應內容

provider_profile
object

渠道回報嘅資料,例如 display_name。帳號未認證之前唔會有。

id
string

渠道側帳號識別碼。WhatsApp 回傳 LID;帳號資料同步完成前可能省略。

device_id
integer

僅 WhatsApp 帳號詳情在可確認目前工作階段時提供的可選登入裝置編號;重新授權後可能改變,不作永久裝置識別。

minimum: 0 · maximum: 65535

phone
string

已歸一化嘅帳號電話號碼,冇空格、連字號同開頭加號。

username
string

渠道回報嘅 username(如有)。

display_name
string

帳號展示名稱;WhatsApp 按 BusinessName 優先、PushName 回退嘅規則生成。

push_name
string

WhatsApp 目前帳號設定嘅 PushName;其他渠道冇定義呢個欄位嘅語義。

business_name
string

WhatsApp BusinessName;渠道冇回傳時呢個欄位會缺失。

first_name
string

渠道回報嘅名(如有)。

last_name
string

渠道回報嘅姓(如有)。

avatar_url
string

渠道回報嘅帳號頭像 URL(如有)。

bio
string

渠道回報嘅帳號簡介或狀態文字(如有)。

platform
string

WhatsApp 配對時回報嘅登入平台識別碼。請當佢係不透明字串並兼容未知值;其他渠道冇定義呢個欄位嘅語義。呢個欄位同 device_platform 唔同。

billing
object

訊息帳號已付週期,僅餘額帳號存在;不能依錢包餘額推斷已購買。

period_start_at
string

伺服器回傳的已付週期起點。

format: date-time

period_end_at
string

伺服器回傳的已付週期終點。

format: date-time

amount_minor
integer

伺服器不可變金額,單位為 USD 分,須以精確整數處理。

minimum: 1 · format: int64

currency
string

僅 USD。

operation_id
string

來自 billing.operation_id 或刪除回應的公開標識,於原工作區原樣重用。

state
string

計費或操作狀態,不證明帳號已授權、上線或退款已入帳。

enum: ACTIVE, DELETING, DELETED, COMPENSATED, REVIEW

id
string

帳號嘅唯一識別碼(acc_...)。喺帳號層級嘅路由入面用佢。

name
string

可讀嘅帳號名稱。

provider
string

管道識別碼。呼叫其他介面時原樣使用 API 回傳的值;此介面的回傳範圍請看下方列舉。

enum: telegram, whatsapp, line, twitter, facebook, zalo, tiktok, whatsapp-protocol

region
string

帳號選擇嘅預設網絡出口地區。

status
string

帳號嘅生命週期狀態,例如 active。

runtime_status
string

標準化嘅運行狀態,係 unknown、starting、running、stopping、stopped、reconnecting、disconnected 或者 error 其中一個。

enum: unknown, starting, running, stopping, stopped, reconnecting, disconnected, error

auth_mode
string

帳號用嘅認證流程:code、qrcode 或者 session。TikTok 支援 qrcode 同 session,但唔支援兩種模式原地切換。

capabilities[]
string[]

帳號開咗嘅能力,例如 send_message 同 receive_message。

metadata
object

你自己存喺帳號上面嘅環境標籤。

provider_account_ref
string

渠道側嘅識別碼,你可以扣返上去,攞嚟同你自己系統嘅帳號對應。

proxy
object

客戶明確設定嘅代理;唔會回傳平台預設出口憑證。

回應

200

200 OK

請求成功,回應內容嘅例子如上。

400

請求錯誤

請求內容、路徑或者參數無效。

401

未授權

X-Api-Key 請求標頭缺少或者無效。

403

禁止存取

請求已識別,但唔允許執行呢個操作。

404

搵唔到資源

搵唔到請求嘅資源;請結合 error.code 同目前操作核對。

500

伺服器錯誤

服務遇到咗未預期嘅錯誤。

失敗後如何處理

檢查 HTTP 狀態和 error.code/numeric_code,保留 request_id。依原因修正參數、繼續授權或檢查狀態。重試傳送及寫入前確認上次結果,避免重複操作。 錯誤碼參考

請按目前操作一併讀取 HTTP 狀態、error.code 同 error.numeric_code。數字碼以字串處理。保留 request_id 排查;佢唔係冪等鍵或任務識別碼。

invalid_request · 10000 · 400

檢查 JSON 請求內容與必填欄位。

觸發條件: 適用於請求內容非空,但 Content-Type 唔係 application/json 嘅請求。

處理與重試: 按目前操作同渠道條件修正參數後再請求。重複提交相同嘅無效請求唔會解決錯誤。

示意 JSON;message 會隨實際原因變化 · 400 · 10000
{
  "request_id": "req_example",
  "error": {
    "code": "invalid_request",
    "numeric_code": "10000",
    "message": "Content-Type must be application/json"
  }
}
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"
  }
}
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"
  }
}
get_account_failed · 20001 · 500

攞帳號:服務未能產生有效嘅查詢結果。

處理與重試: 保留 request_id,核對目標識別碼同帳號存取範圍。查明原因後再試查詢;查詢失敗唔代表結果為空或資源不存在。

示意 JSON;message 會隨實際原因變化 · 500 · 20001
{
  "request_id": "req_example",
  "error": {
    "code": "get_account_failed",
    "numeric_code": "20001",
    "message": "Failed to get account"
  }
}
get_account_failed · 20020 · 500

核對 account_id,並使用帳號所屬工作區的 X-Api-Key。此工作區下未找到的帳號無法使用目前 Key 存取。

觸發條件: 適用於帳號不存在嘅情況;保留原 HTTP 狀態同操作 code,透過 numeric_code 細分帳號缺失。

處理與重試: 核對目標識別碼、資源歸屬同目前工作區。唔好將已確認缺少或無法存取嘅目標當成暫時服務故障自動重試。

示意 JSON;message 會隨實際原因變化 · 500 · 20020
{
  "request_id": "req_example",
  "error": {
    "code": "get_account_failed",
    "numeric_code": "20020",
    "message": "Account not found"
  }
}