API 參考

會話

為會話增刪標籤

為一批會話加上或移除標籤。action 為 add 或 remove;conversation_ids 至少包含一個 id。目前僅 WhatsApp 支援——其他 provider 回傳 501 unsupported_by_provider。

POSThttps://api.unifyport.ai/v1/accounts/{account_id}/conversations/labels

呼叫前準備

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

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

請求參數

請求標頭

X-Api-Key
string必填

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

Content-Type
string必填

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

路徑參數

account_id
string必填

用於該 conversations 路由的識別字。

請求內容

label_id
string必填

標籤識別字。

action
string必填

標籤成員操作:add 或 remove。

enum: add, remove

conversation_ids[]
string[]必填

要變更標籤關係的對話識別字。

minItems: 1

如何理解結果

依文件解讀回應欄位與 HTTP 狀態。204 成功沒有回應本文,排查時使用 X-Request-Id。下一步請參閱相關操作。

回應 200 OK

{
  "request_id": "<REQUEST_ID>",
  "data": {
    "label_id": "label_example",
    "action": "add",
    "conversation_ids": [
      "peer_example"
    ]
  }
}

回應內容

label_id
string

已刪除或已修改的標籤識別字。

action
string

已執行的標籤成員操作。

enum: add, remove

conversation_ids[]
string[]

本次操作影響的對話識別字。

回應

200

200 OK

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

400

請求錯誤

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

401

未授權

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

409

衝突

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

500

伺服器錯誤

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

501

渠道尚未實作

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

502

上游閘道錯誤

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

失敗後如何處理

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

invalid_request · 10000 · 400
檢查必填欄位、格式與渠道條件,修正請求後再呼叫。
invalid_api_key · 11001 · 401
檢查 X-Api-Key 與工作區是否有效。