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

接口返回的重试设置。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
    }
  }
}