Webhook 端點POST
建立 Webhook 端點
建立一個 Webhook 接收端。subscribed_events 接受平台標準事件名稱(例如 message.received、account.status.updated),可使用 ["*"] 訂閱所有事件;未知的事件名稱會被拒絕。signing_secret 為選填 — 留空或省略時等同關閉端點簽章。retry_policy 為選填;max_attempts 預設為 3,必須是 0 到 5 的整數;填 0 表示關閉重試。
https://api.unifyport.ai/v1/webhook-endpoints請求標頭
X-Api-Keystring必填
工作區 API Key,工作區會由此標頭解析得到。
Content-Typestring必填
傳送 JSON 請求內容時請使用 application/json。
路徑參數
此介面沒有路徑參數。
請求內容
urlstring必填
接收 Webhook 事件的 HTTPS 端點。
statusstring
端點狀態,通常為 active 或 inactive。
subscribed_eventsstring[]
推送到此端點的事件類型,可使用 ["*"] 訂閱所有事件;完整事件名稱參見標準事件類型與載荷。
signing_secretstring
可選的 Webhook 簽章密鑰,範例中請使用佔位符。
retry_policyobject
可選的重試政策。max_attempts 預設為 3,僅接受 0 到 5 的整數;填 0 表示關閉重試。
回應內容
idstring
Webhook 端點識別字(we_...)。
urlstring
接收 Webhook 投遞的 HTTPS URL。
statusstring
端點狀態:active 或 inactive。
subscribed_eventsstring[]
投遞至此端點的事件類型;["*"] 表示所有事件。
signing_enabledboolean
當已設定簽章密鑰且投遞會被簽章時為 true。
retry_policyobject
API 回傳的重試設定。max_attempts 預設為 3,範圍為 0 到 5。
回應
201201 Created
請求成功,回應內容範例如上。
400請求錯誤
請求內容、路徑或參數無效。
401未授權
X-Api-Key 請求標頭缺少或無效。
409衝突
目前操作與既有的渠道帳號或資源衝突。
500伺服器錯誤
服務遇到了未預期的錯誤。
請求
curl -X POST https://api.unifyport.ai/v1/webhook-endpoints \
-H "X-Api-Key: <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhook",
"status": "active",
"subscribed_events": ["*"],
"signing_secret": "<WEBHOOK_SIGNING_SECRET>"
}'回應
{
"data": {
"id": "we_example",
"url": "https://example.com/webhook",
"status": "active",
"subscribed_events": ["*"],
"signing_enabled": true,
"retry_policy": {
"max_attempts": 3
}
}
}