Skip to content

HealthKit 日摘要 ​

热爱 App 上报 HealthKit 日摘要。与探活 GET /health 不是同一个路径。

源码: apps/backend/src/routes/user/health-daily.ts

生产同域(ReAI 部署后):https://block2-api.wainao.chat

本接口只落库。不转发 Alice。

POST /user/health/daily ​

认证方式 ​

Authorization: Bearer <access_token>

  • OAuth access token,scope 含 mobile:full(通常同时有 profile:read)
  • 或用户会话 JWT

不新开 health scope。API Key 与 Agent token 不能调用。

请求体 ​

上限 256KiB。schema_version 必填,只接受 "1.0"。timezone 默认 Asia/Singapore。user_id 若填写,必须等于当前用户。

信封:

json
{
  "schema_version": "1.0",
  "timezone": "Asia/Singapore",
  "user_id": "oauth_sub_or_user_id",
  "generated_at": "2026-10-28T07:05:00+08:00",
  "days": [{ "date": "2026-10-27" }]
}

兼容:不传 days,把单日字段放在顶层,仍要 schema_version。

permission.code:HK_OK | HK_DENIED | HK_PARTIAL。指标可以为 null,也可以带 missing。

幂等 ​

同一用户、同一 date 再次 POST 覆盖该日,返回 200。首次写入返回 201。单日响应包含 idempotency_key(health-daily:{userId}:{date})。

响应 ​

成功 200 或 201:

json
{ "ok": true, "accepted_dates": ["2026-10-27"], "idempotency_key": "health-daily:user:2026-10-27" }
状态说明
400{ "ok": false, "error": "validation_error", "message": "...", "fields": {} }
401未登录或 token 过期
413正文超过 256KiB
503{ "ok": false, "error": "server_error", "retryable": true }

AI Workflow Editor