Webhook注册 webhook

Webhook

注册 webhook

注册 Sofia 以带签名 JSON 事件调用的 https URL,失败最多重试五次。密钥仅显示一次,最多 10 个。

POSThttps://api.sofia-post.com/api/v1/webhooks
POST/v1/webhooks

此请求将作用于你的真实账户。

curl -X POST 'https://api.sofia-post.com/api/v1/webhooks' \
  -H "Authorization: Bearer $SOFIA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://crm.example.com/hooks/sofia","events":["post.published"]}'

授权

  • Authorizationstring必填

    你的个人密钥或 OAuth 访问令牌,以 Bearer <token> 发送。

请求体

application/json

  • urlstring必填

    Sofia 调用的 https 地址。解析到私有、回环或链路本地地址的主机会被拒绝

  • eventsstring[]必填

    要接收的事件

响应

201application/json

webhook 及其签名密钥,仅显示一次。

  • idstring必填

    webhook 的标识符

  • urlstring必填

    Sofia 调用的地址

  • eventsstring[]必填

    已订阅的事件

  • createdAtstring<date-time>必填

    webhook 的注册时间

  • secretstring必填

    为每次投递签名的 HMAC-SHA256 密钥(Sofia-Signature)。仅此一次显示

400

webhook_url_invalid:不是 https,或是私有、回环或链路本地主机。webhook_event_invalid:未知事件,或没有事件。

401

令牌缺失、未知、已过期或已被撤销。

403

令牌没有 webhooks:write scope。

409

webhook_limit_reached:已有 10 个 webhook。

4XXapplication/json

其他任何错误,以错误结构返回。