异步回调配置
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 |
name | endpoint 名称 |
url | HTTPS webhook URL |
status | ACTIVE 或 DISABLED |
timeout_seconds | 后续投递 worker 使用的超时配置 |
max_attempts | 后续投递 worker 使用的最大尝试次数 |
| 字段 | 说明 |
|---|---|
subscription_id | 平台生成的订阅 ID |
endpoint_id | 订阅所属 endpoint |
event_type | 订阅的事件类型 |
status | ACTIVE 或 DISABLED |
可订阅事件
当前开放平台已实现的 command 回调事件只有:| event_type | 说明 |
|---|---|
command.accepted | 平台已受理并持久化命令。该事件不表示设备执行成功。 |
command.completed | adapter 或设备返回终态结果。成功、失败、超时、不支持、拒绝等具体结果在事件 payload 的 status 字段以及查询响应的状态字段中表达。 |
command.* 事件不是按每个状态拆分。command.succeeded、command.failed、command.timed_out、command.delivered 等不是当前可订阅事件类型。接入方应订阅 command.completed,再根据 payload 中的 status、adapter_status、device_execution_status 或 public_status 判断结果。