API 參考
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-Key
string必填

工作區 API Key,工作區會由呢個標頭解析得出嚟。

Content-Type
string必填

發送 JSON 請求內容嘅時候請用 application/json。

路徑參數

呢個介面冇路徑參數。

請求內容

url
string必填

接收 Webhook 事件嘅 HTTPS 端點。

status
string

端點嘅狀態,通常係 active 或者 inactive。

subscribed_events
string[]

推送到呢個端點嘅事件類型,用 ["*"] 就訂閱所有事件;想睇齊所有事件名,去標準事件類型同載荷

signing_secret
string

可選嘅 Webhook 簽名密鑰,例子入面請用佔位符。

retry_policy
object

可選嘅重試政策。max_attempts 預設係 3,只接受 0 到 5 嘅整數;0 表示關閉重試。

回應內容

id
string

Webhook 端點識別碼(we_...)。

url
string

接收 webhook 派送嘅 HTTPS URL。

status
string

端點狀態:active 或者 inactive。

subscribed_events
string[]

派去呢個端點嘅事件類型;["*"] 即係所有事件。

signing_enabled
boolean

設咗簽名密鑰、派送會簽名嗰陣會係 true。

retry_policy
object

API 回傳嘅重試設定。max_attempts 預設係 3,範圍係 0 到 5。

回應

201
201 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
    }
  }
}