API 參考
聯絡人POST

新增聯絡人

向渠道帳號新增聯絡人。phone_number 與 username 至少提供一個;whatsapp_options 僅適用於 WhatsApp,不支援的渠道回傳 501 unsupported_by_provider。

https://api.unifyport.ai/v1/accounts/{account_id}/contacts/add

請求標頭

X-Api-Key
string必填

工作區 API Key,工作區會由此標頭解析得到。

Content-Type
string必填

傳送 JSON 請求內容時請使用 application/json。

路徑參數

account_id
string必填

用於該 contacts 路由的識別字。

請求內容

phone_number
string

包含國家或地區代碼的純數字電話號碼,不含加號、空格或分隔符;與 username 至少提供一個。

username
string

渠道使用者名稱;與 phone_number 至少提供一個,格式以目標渠道為準。

whatsapp_options
object

可選的 WhatsApp 聯絡人設定;first_name、full_name、sync_to_device_contacts 只能嵌套在 whatsapp_options 內傳入,其他渠道應省略此物件。

first_name
string

可選的 WhatsApp 聯絡人名字。

full_name
string

可選的 WhatsApp 聯絡人全名。

sync_to_device_contacts
boolean

是否同時儲存到當前 WhatsApp 帳號關聯裝置的系統通訊錄,預設為 false。

回應內容

id
string

聯絡人識別字。

conversation_id
string

此聯絡人的對話識別字;可用於傳送訊息或定位該對話。

display_name
string

聯絡人顯示名稱;若缺少則為空字串。

avatar_url
string

聯絡人頭像 URL;若缺少則為空字串。

provider_user_id
string

此聯絡人於渠道側的使用者識別字。

is_blocked
boolean

此聯絡人是否已被連接帳號封鎖。

extra
object

渠道專屬的額外欄位,例如 phone。

回應

200
200 OK

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

400
請求錯誤

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

401
未授權

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

409
衝突

目前操作與既有的渠道帳號或資源衝突。

500
伺服器錯誤

服務遇到了未預期的錯誤。

501
渠道尚未實作

所選渠道尚未實作此操作。

502
上游閘道錯誤

渠道轉接器或上游渠道未能完成此操作。

請求

curl -X POST https://api.unifyport.ai/v1/accounts/{account_id}/contacts/add \
  -H "X-Api-Key: <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "phone_number": "8600000000000",
  "username": "alice_user",
  "whatsapp_options": {
    "first_name": "Alice",
    "full_name": "Alice Example",
    "sync_to_device_contacts": false
  }
}'

回應

{
  "data": {
    "id": "8600000000000@s.whatsapp.net",
    "conversation_id": "123456789012345@lid",
    "display_name": "Alice Example",
    "avatar_url": "",
    "provider_user_id": "8600000000000@s.whatsapp.net",
    "extra": { "phone": "8600000000000" }
  }
}