Webhook 端點
停用 Webhook 端點
將 Webhook 端點嘅狀態設為 inactive,但係唔會刪除端點。
https://api.unifyport.ai/v1/webhook-endpoints/{endpoint_id}/deactivate支援渠道
呼叫前準備
在伺服器端使用資源所屬工作區的 X-Api-Key,執行範例前替換所有預留位置。
參數從哪裡取得
- account_id
- 從建立或查詢帳號的回應取得 data.id。帳號屬於 X-Api-Key 對應的工作區。 攞帳號
請求參數
請求標頭
X-Api-Key工作區 API Key,工作區會由呢個標頭解析得出嚟。
路徑參數
endpoint_id用嚟識別嗰條 webhook endpoints 路由嘅 ID。
查詢參數
account_id可選嘅公開帳號 ID,例如 acc_example。唔可以為空、只含空白或重複出現。參數名稱必須精確使用 account_id;大小寫變體會回傳 400 invalid_request,唔會當作省略。列表省略時只回傳工作空間端點;指定時只回傳帳號獨立設定(冇獨立設定就 data=[],唔會混入繼承嘅工作空間設定)。詳情、停用、刪除只驗證現有帳號歸屬;唔匹配會回傳 400 invalid_request。明確指定嘅帳號唔存在或唔屬於目前工作空間會回傳 404 account_not_found (20020)。
minLength: 1 · pattern: \S
請求內容
呢個介面唔需要 JSON 請求內容。
如何理解結果
確認回應中的 status=inactive。此端點不再用於新投遞,但停用不保證取消已在途的請求。
回應 200 OK
{
"request_id": "<REQUEST_ID>",
"data": {
"id": "we_example",
"url": "https://example.com/webhook-updated",
"status": "inactive",
"subscribed_events": [
"message.delivered",
"message.read"
],
"signing_enabled": false,
"retry_policy": {
"max_attempts": 1
}
}
}
回應內容
idWebhook 端點識別碼(we_...)。
account_id帳號獨立端點嘅公開帳號 ID;工作空間端點會省略呢個欄位,唔會回傳 null。
minLength: 1
url接收 webhook 派送嘅絕對 HTTP(S) URL;正式環境建議 HTTPS。
format: uri
status端點狀態:active 或者 inactive。
enum: active, inactive
subscribed_events[]派去呢個端點嘅公開標準事件類型;["*"] 即係工作區可接收嘅公開事件,唔包括 provider.raw_event。
signing_enabled設咗簽名密鑰、派送會簽名嗰陣會係 true。
retry_policyobjectAPI 回傳嘅重試設定。max_attempts 統計首次投遞之後嘅重試次數,預設 3,範圍 0 到 5。
retry_policyAPI 回傳嘅重試設定。max_attempts 統計首次投遞之後嘅重試次數,預設 3,範圍 0 到 5。
max_attempts已設定嘅首次投遞後重試次數,範圍係 0 到 5。
回應
200200 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 請求內容與必填欄位。
處理與重試: 按目前操作同渠道條件修正參數後再請求。重複提交相同嘅無效請求唔會解決錯誤。
示意 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" } }- 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" } }- account_not_found · 20020 · 404
核對 account_id,並使用帳號所屬工作區的 X-Api-Key。此工作區下未找到的帳號無法使用目前 Key 存取。
處理與重試: 核對目標識別碼、資源歸屬同目前工作區。唔好將已確認缺少或無法存取嘅目標當成暫時服務故障自動重試。
示意 JSON;message 會隨實際原因變化 · 404 · 20020
{ "request_id": "req_example", "error": { "code": "account_not_found", "numeric_code": "20020", "message": "Account not found" } }- 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" } }- deactivate_webhook_endpoint_failed · 40004 · 500
停用 Webhook 端點:無法確認停止或停用結果,恢復時應保留原本停止目標。
處理與重試: 查詢目前狀態,確認停止或停用是否生效。唔好為咗恢復本次操作而啟動或重連本來要停止嘅資源。
示意 JSON;message 會隨實際原因變化 · 500 · 40004
{ "request_id": "req_example", "error": { "code": "deactivate_webhook_endpoint_failed", "numeric_code": "40004", "message": "Failed to deactivate webhook endpoint" } }- deactivate_webhook_endpoint_failed · 40006 · 500
呢個歸屬範圍內搵唔到目標 Webhook 端點。GET、PATCH 同停用保留各自操作 code 及 HTTP 500,數字原因係 40006。此細分唔適用於冪等 DELETE;端點不存在時刪除傳回 204。
處理與重試: 核對目標識別碼、資源歸屬同目前工作區。唔好將已確認缺少或無法存取嘅目標當成暫時服務故障自動重試。
示意 JSON;message 會隨實際原因變化 · 500 · 40006
{ "request_id": "req_example", "error": { "code": "deactivate_webhook_endpoint_failed", "numeric_code": "40006", "message": "Webhook endpoint not found" } }