API 參考

會話

列出會話

即時列出會話。limit 範圍 1..100,預設 20;type 是以逗號分隔的 user / group / channel 精確值,不會 trim。WhatsApp 未傳 label_id 時只回傳「特別關注」會話。無效 cursor 的處理依渠道而異。

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

支援渠道

TelegramWhatsAppLINEXFacebookTikTok

呼叫前準備

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

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

請求參數

請求標頭

X-Api-Key
string必填

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

路徑參數

account_id
string必填

用於該 conversations 路由的識別字。

查詢參數

type
string

以逗號分隔的精確列舉值:user、group 或 channel。不去除空格、不轉換大小寫,也不忽略空項。無效值回傳 400 invalid_conversation_type。WhatsApp 的 group 包含社群公告群組,所有 WhatsApp 群組對話均回傳 type=group。

cursor
string

渠道不透明游標,應原樣回傳前一回應的 next_cursor;省略或留空從第一頁開始。偽造、過期或跨查詢重用的游標可能被忽略、重設為第一頁或回傳渠道錯誤,不得依賴統一的 400 回應。

limit
integer

單頁數量範圍 1..100;預設值見各端點說明。

minimum: 1 · maximum: 100

label_id
string

渠道標籤精確識別碼;WhatsApp 省略時回傳「特別關注」會話。

請求內容

此介面無需 JSON 請求內容。

如何理解結果

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

回應 200 OK

{
  "request_id": "<REQUEST_ID>",
  "data": {
    "items": [
      {
        "conversation_id": "peer_example",
        "type": "user",
        "title": "Display name",
        "avatar_url": "",
        "unread_count": 3,
        "last_message_at": "2026-05-13T10:00:00Z"
      }
    ],
    "next_cursor": "",
    "has_more": false
  }
}

回應內容

conversation_id
string

對話識別字。傳送訊息或呼叫對話相關路由時,請以此作為目標。

type
string

標準對話類型:user、group 或 channel。WhatsApp 社群公告群組繼續使用 group。

enum: user, group, channel

title
string

對話的顯示標題。

username
string

渠道有提供時回傳的對話 username。

avatar_url
string

頭像 URL;若未設定則為空字串。

description
string

群組或頻道描述(若有提供)。

last_message_at
string

最近一則訊息的 RFC3339 時間戳記。

format: date-time

last_message_text
string

最近一則訊息的文字預覽(若有)。

unread_count
integer

對話中的未讀訊息數量。

format: int64

members_count
integer

成員數量;針對群組對話回傳。

format: int64

subscribers_count
integer

頻道類對話的訂閱者數量(若有)。

format: int64

is_pinned
boolean

連接帳號是否已置頂此對話。

is_muted
boolean

連接帳號是否已將此對話靜音。

created_at
string

渠道有提供時回傳的對話建立時間。

format: date-time

extra
object

渠道擴充欄位;WhatsApp 群組對話可包含公告群組分類,對話列表不保證提供該分類。

is_announcement_group
boolean

僅 WhatsApp 群組提供。true 表示已確認為社群公告群組,false 表示本次資料已確認不符合公告群組條件;缺少表示未知,不回傳 null。此分類不表示目前帳號具備傳送訊息的權限。

next_cursor
string

指向下一頁的不透明游標。請以 cursor 原樣回傳;空字串表示已無更多分頁。

has_more
boolean

當本頁之外仍有更多結果時為 true。

回應

200

200 OK

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

400

請求錯誤

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

401

未授權

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

403

禁止存取

請求已識別,但不允許執行此操作。

404

找不到資源

找不到請求的資源;請結合 error.code 和目前操作核對。

409

衝突

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

500

伺服器錯誤

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

501

渠道尚未實作

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

502

上游閘道錯誤

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

失敗後如何處理

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

結合目前操作讀取 HTTP 狀態、error.code 和 error.numeric_code。數字碼以字串處理。保留 request_id 排查;它不是冪等鍵或任務識別碼。

invalid_conversation_type · 37000 · 400

type 必須為 user、group 或 channel。

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

示意 JSON;message 隨實際原因變化 · 400 · 37000
{
  "request_id": "req_example",
  "error": {
    "code": "invalid_conversation_type",
    "numeric_code": "37000",
    "message": "Field 'type' must be one of: user, group, channel"
  }
}
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"
  }
}
provider_invalid_request · 30001 · 400

檢查管道專屬欄位及格式。

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

示意 JSON;message 隨實際原因變化 · 400 · 30001
{
  "request_id": "req_example",
  "error": {
    "code": "provider_invalid_request",
    "numeric_code": "30001",
    "message": "Provider rejected the request"
  }
}
unsupported_conversation_type · 37001 · 400

管道不支援此操作,請選擇能力表中支援的操作。

處理與重試: 選擇文件列為支援的渠道與動作。重複請求不會增加能力或開通內測權限。

示意 JSON;message 隨實際原因變化 · 400 · 37001
{
  "request_id": "req_example",
  "error": {
    "code": "unsupported_conversation_type",
    "numeric_code": "37001",
    "message": "Operation not supported for this conversation type"
  }
}
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_binding_not_found · 30006 · 409

帳號尚無有效的管道連線綁定,請檢查帳號狀態。

處理與重試: 查詢授權與執行狀態,再按目標狀態和渠道支援選擇重新整理、啟動或重新連線。連線問題本身不證明已登出;執行依賴連線的業務操作前確認 running。

示意 JSON;message 隨實際原因變化 · 409 · 30006
{
  "request_id": "req_example",
  "error": {
    "code": "account_binding_not_found",
    "numeric_code": "30006",
    "message": "Account is not bound to an available server"
  }
}
egress_configuration_pending · 20032 · 409

目前無法確認或讀取平台預設網路設定;這不代表帳號已登出。

觸發條件: 此操作使用平台分配的網路容量或帳號固定的預設網路設定。

處理與重試: 保留 request_id,再次寫入前確認帳號或建立結果。等待容量或設定恢復,或聯絡支援;不要自動反覆建立帳號、更換網路或重新啟動帳號。

示意 JSON;message 隨實際原因變化 · 409 · 20032
{
  "request_id": "req_example",
  "error": {
    "code": "egress_configuration_pending",
    "numeric_code": "20032",
    "message": "Account network configuration is pending verification"
  }
}
provider_not_ready · 30009 · 409

連線尚未就緒,請檢查授權及 runtime_status 後再決定是否重試。

處理與重試: 查詢授權與執行狀態,再按目標狀態和渠道支援選擇重新整理、啟動或重新連線。連線問題本身不證明已登出;執行依賴連線的業務操作前確認 running。

示意 JSON;message 隨實際原因變化 · 409 · 30009
{
  "request_id": "req_example",
  "error": {
    "code": "provider_not_ready",
    "numeric_code": "30009",
    "message": "Provider client is not ready"
  }
}
provider_not_ready · 30014 · 409

此帳號所需的渠道執行個體缺失。這是執行個體可用性問題,不證明授權已過期。

處理與重試: 查詢授權與執行狀態,再按目標狀態和渠道支援選擇重新整理、啟動或重新連線。連線問題本身不證明已登出;執行依賴連線的業務操作前確認 running。

適用渠道: WhatsApp

示意 JSON;message 隨實際原因變化 · 409 · 30014
{
  "request_id": "req_example",
  "error": {
    "code": "provider_not_ready",
    "numeric_code": "30014",
    "message": "Provider instance is missing"
  }
}
provider_not_ready · 30015 · 409

渠道執行程序已停止。啟動前確認這是否為預期狀態;執行狀態停止本身不等於已登出。

處理與重試: 查詢授權與執行狀態,再按目標狀態和渠道支援選擇重新整理、啟動或重新連線。連線問題本身不證明已登出;執行依賴連線的業務操作前確認 running。

適用渠道: WhatsApp

示意 JSON;message 隨實際原因變化 · 409 · 30015
{
  "request_id": "req_example",
  "error": {
    "code": "provider_not_ready",
    "numeric_code": "30015",
    "message": "Provider runtime is stopped"
  }
}
list_conversations_failed · 20020 · 500

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

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

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

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

渠道未能完成本次操作。message 可能在「Provider operation failed:」後附帶原始原因;原因文字可變,不是穩定的程式介面。

觸發條件: 適用於渠道未提供更具體失敗分類的情況,保留目前操作的錯誤。

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

適用渠道: WhatsApp

示意 JSON;message 隨實際原因變化 · 500 · 30010
{
  "request_id": "req_example",
  "error": {
    "code": "list_conversations_failed",
    "numeric_code": "30010",
    "message": "Provider operation failed"
  }
}
list_conversations_failed · 37003 · 500

列出會話:服務未能產生有效的查詢結果。

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

示意 JSON;message 隨實際原因變化 · 500 · 37003
{
  "request_id": "req_example",
  "error": {
    "code": "list_conversations_failed",
    "numeric_code": "37003",
    "message": "Failed to list conversations"
  }
}
unsupported_by_provider · 30003 · 501

管道不支援此操作,請選擇能力表中支援的操作。

處理與重試: 選擇文件列為支援的渠道與動作。重複請求不會增加能力或開通內測權限。

範例 · 501 · 30003
{
  "request_id": "req_xxx",
  "error": {
    "code": "unsupported_by_provider",
    "numeric_code": "30003",
    "message": "Operation not supported by this provider"
  }
}
provider_adapter_not_found · 30004 · 502

管道服務暫時無法使用,請檢查狀態或稍後再試;重試寫入操作前先確認上次結果。

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

示意 JSON;message 隨實際原因變化 · 502 · 30004
{
  "request_id": "req_example",
  "error": {
    "code": "provider_adapter_not_found",
    "numeric_code": "30004",
    "message": "Provider adapter unavailable"
  }
}
provider_unavailable · 30002 · 502

管道服務暫時無法使用,請檢查狀態或稍後再試;重試寫入操作前先確認上次結果。

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

範例 · 502 · 30002
{
  "request_id": "req_example_provider_unavailable",
  "error": {
    "code": "provider_unavailable",
    "numeric_code": "30002",
    "message": "Provider service unavailable"
  }
}
provider_unavailable · 30010 · 502

渠道未能完成本次操作。message 可能在「Provider operation failed:」後附帶原始原因;原因文字可變,不是穩定的程式介面。

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

適用渠道: WhatsApp

範例 · 502 · 30010
{
  "request_id": "req_example_operation_failed",
  "error": {
    "code": "provider_unavailable",
    "numeric_code": "30010",
    "message": "Provider operation failed: Example operation could not be completed"
  }
}
provider_unavailable · 30021 · 502

本次請求時帳號未連線至訊息平台。WhatsApp 新增聯絡人可回傳 500 / create_contact_failed / 30021。這不代表帳號已登出,也不保證目前執行狀態仍為 disconnected;請先查詢目前狀態,再選擇復原操作。

處理與重試: 暫停依賴連線的業務操作。先呼叫 POST /v1/accounts/{account_id}/runtime/refresh,按最新狀態恢復,確認 runtime_status=running 後再請求業務介面。重送前確認上一次寫入結果。

適用渠道: WhatsApp

範例 · 502 · 30021
{
  "request_id": "req_example_connection_disconnected",
  "error": {
    "code": "provider_unavailable",
    "numeric_code": "30021",
    "message": "example operation: websocket not connected"
  }
}