异步回调配置

001 当前实现的是 callback 配置 API:租户可以创建 webhook endpoint、轮换 secret、创建事件订阅、查询配置和删除订阅。 001 不执行 webhook 投递 worker。回调配置 API 负责保存 endpoint 与 subscription;实际 HTTPS 投递、签名、重试、失败补偿和投递审计属于 callback delivery 服务能力。

已实现配置接口

  • POST /api/v1/open/callbacks/endpoints:创建回调 endpoint,secret 只返回一次。
  • GET /api/v1/open/callbacks/endpoints:列出租户回调 endpoint,不返回 secret。
  • GET /api/v1/open/callbacks/endpoints/{endpoint_id}:获取 endpoint,不返回 secret。
  • PUT /api/v1/open/callbacks/endpoints/{endpoint_id}:更新 endpoint,或设置 rotate_secret=true 轮换 secret。
  • POST /api/v1/open/callbacks/endpoints/{endpoint_id}/subscriptions:创建事件订阅。
  • GET /api/v1/open/callbacks/endpoints/{endpoint_id}/subscriptions:列出事件订阅。
  • DELETE /api/v1/open/callbacks/endpoints/{endpoint_id}/subscriptions/{subscription_id}:删除事件订阅。

多租户边界

  • tenant_id 来自认证后的 API credential。
  • endpoint 和 subscription 都归属当前租户。
  • 查询、更新、删除只能作用于当前租户资源。
  • secret 只在创建或轮换响应中返回一次;列表和查询接口不会返回 secret。

配置对象

endpoint 字段:
字段说明
endpoint_id平台生成的 endpoint ID
nameendpoint 名称
urlHTTPS webhook URL
statusACTIVEDISABLED
timeout_seconds后续投递 worker 使用的超时配置
max_attempts后续投递 worker 使用的最大尝试次数
subscription 字段:
字段说明
subscription_id平台生成的订阅 ID
endpoint_id订阅所属 endpoint
event_type订阅的事件类型
statusACTIVEDISABLED

可订阅事件

当前开放平台已实现的 command 回调事件只有:
event_type说明
command.accepted平台已受理并持久化命令。该事件不表示设备执行成功。
command.completedadapter 或设备返回终态结果。成功、失败、超时、不支持、拒绝等具体结果在事件 payload 的 status 字段以及查询响应的状态字段中表达。
command.* 事件不是按每个状态拆分。command.succeededcommand.failedcommand.timed_outcommand.delivered 等不是当前可订阅事件类型。接入方应订阅 command.completed,再根据 payload 中的 statusadapter_statusdevice_execution_statuspublic_status 判断结果。

后续服务边界

后续 callback delivery 服务会消费平台事件,按 endpoint/subscription 配置投递 HTTPS webhook,并负责签名、重试、失败记录和投递审计。001 只保证配置事实是租户隔离、可查询、可轮换 secret 的。