HealthSave API Contract
HealthSave can sync Apple Health data to any self-hosted server that implements this contract. Set the base URL in the app, and optionally add an API key. The reference project is HealthSave Observatory, a self-hosted dashboard you run on your own server. The Observatory core is source-available under Elastic License 2.0.
Updated November 2026
HealthSave can sync Apple Health data to any self-hosted server that implements this contract. Configure the app with the base server URL only, such as https://health.example.com; HealthSave appends the endpoint paths below. The reference project is HealthSave Observatory, a self-hosted dashboard you run on your own server. The Observatory core is source-available under Elastic License 2.0. Its protocol and SDK are under Apache-2.0. Any server that speaks this contract works, including community implementations such as health-data-to-mqtt.
- Base URL: enter only the origin or base path in the app.
- Authentication: optional
x-api-keyheader on protected requests and on the compatibility check. - Core compatibility:
GET /api/health,GET /api/apple/status, andPOST /api/apple/batchfor v1 uploads. - v2 batches: see the HealthSave data format v2 for schemas, a real batch, and Python and Node.js receivers.
Versioning
The v1 contract is frozen. HealthSave for iPhone first sent v2 batches in version 1.7.2. If the v2 batch route answers 404 or 405, the app falls back to v1 for batches that can use that format. Features that require v2, such as delivering deletion UUIDs, need a v2 receiver.
Sync receipts are a separate extension under /api/v2/sync/. In iOS 1.7.2 and earlier, a receipt-less server can show “needs retry” after a run that had nothing new to send. This was fixed in 1.8.0. See the v1.5.3 compatibility notes.
Endpoints
| Method | Path | Tier | Purpose |
|---|---|---|---|
GET |
/api/health |
v1 | App-friendly liveness probe. iOS calls this first. |
GET |
/health |
v1 | Fallback for the compatibility check if /api/health returns 404. |
POST |
/api/apple/batch |
v1 | Receives one HealthKit metric batch. |
POST |
/api/v2/apple/batch |
v2 (optional) | Versioned batch (schema_version=2). It adds the optional X-HealthSave-Schema-Version header. Observatory echoes wire_schema_version and includes deletion counts for non-empty batches. |
GET |
/api/apple/status |
v1 | Returns per-metric server counts for the sync status screen. |
GET |
/api/v2/setup/diagnostics |
v2 (optional) | Unauthenticated, no health data. Helps the user tell a HealthSave-compatible API apart from a wrong port (Grafana, Homepage, etc.). |
GET |
/api/v2/sync/runs/latest |
v2 (optional) | Returns a receipt or summary for the most recent known run. |
GET |
/api/v2/sync/runs/{sync_run_id} |
v2 (optional) | Per-run delivery receipt. The iOS app uses this to mark a run as "delivery-receipt verified." |
PUT |
/api/v2/sync/runs/{sync_run_id}/summary |
v2 (optional) | Receives the app’s completed run summary, including runs that sent no records. |
GET |
/api/v2/sync/coverage |
v2 (optional) | Metric-level receipt coverage and destination sample coverage for operators. |
Authentication
If your backend requires an API key, HealthSave sends it with protected requests as an x-api-key header.
x-api-key: your-api-key
The compatibility check also sends the key on /api/health and its /health fallback. A 401 or 403 on that check points to an authentication problem. The separate background reachability probe uses /api/health without the key.
Health Checks
The compatibility check accepts these liveness responses.
- Endpoint discovery. Serve
GET /api/healthfor setup and background reachability. During setup, iOS retries once atGET /healthif/api/healthreturns404. HealthSave Observatory exposes both routes. - Status. Return a
2xxJSON response. The app trims whitespace and acceptsok,healthy,alive,ready, orupin thestatusfield, ignoring case. - Timeout. The compatibility liveness request has a 10-second timeout.
A minimal successful response is just:
{
"status": "ok"
}
Receiving a v1 batch
POST /api/apple/batch receives one metric at a time. Return 2xx once you have saved the batch. The response example shows the core acknowledgement fields. See the receipt example below for more fields returned by Observatory.
{
"metric": "heart_rate",
"batch_index": 0,
"total_batches": 1,
"samples": [
{
"date": "2026-04-10T12:00:00Z",
"qty": 72,
"source": "Apple Watch"
}
]
}
{
"status": "processed",
"metric": "heart_rate",
"batch": 0,
"total_batches": 1,
"records": 1
}
Quantity Samples
Quantity-like metrics use date, qty, and source. V1 clients can include unit. It is not required on every v1 sample. See the v2 format for the rules on v2 units.
Sleep Samples
{
"metric": "sleep_analysis",
"samples": [
{
"startDate": "2026-04-09T23:20:00Z",
"endDate": "2026-04-10T06:45:00Z",
"value": 3,
"source": "Apple Watch"
}
]
}
Workout Samples
On iOS 1.9.4 and later, elevationGain is sent in metres when the recording includes it.
{
"metric": "workouts",
"samples": [
{
"name": "Running",
"start": "2026-04-10T07:00:00Z",
"end": "2026-04-10T07:45:00Z",
"duration": 2700,
"source": "Apple Watch",
"activeEnergy": 420,
"distance": 6500,
"elevationGain": 84.5,
"avgHeartRate": 145,
"maxHeartRate": 178,
"heartRateData": [
{"date": "2026-04-10T07:01:00Z", "qty": 132}
],
"route": [
{
"latitude": 41.01,
"longitude": 28.97,
"altitude": 42.0,
"speed": 2.8,
"timestamp": "2026-04-10T07:01:00Z"
}
]
}
]
}
Activity Summary Samples
{
"metric": "activity_summaries",
"samples": [
{
"date": "2026-04-10",
"activeEnergyBurned": 540,
"activeEnergyBurnedGoal": 600,
"appleExerciseTime": 42,
"appleExerciseTimeGoal": 30,
"appleStandHours": 12,
"appleStandHoursGoal": 12
}
]
}
Blood Pressure Correlations
Blood pressure batches use metric: "blood_pressure" at the batch level. Samples can carry an inner metric value to identify systolic or diastolic readings.
{
"metric": "blood_pressure",
"samples": [
{
"metric": "blood_pressure_systolic",
"date": "2026-04-10T09:00:00Z",
"qty": 120,
"source": "Blood Pressure Monitor"
},
{
"metric": "blood_pressure_diastolic",
"date": "2026-04-10T09:00:00Z",
"qty": 80,
"source": "Blood Pressure Monitor"
}
]
}
Category Event Samples
Category events use date, qty, source, and, when available, endDate plus rawValue. For duration-based events, qty is the duration in seconds and rawValue keeps the raw HealthKit category value. For instant events, qty is the raw category value.
{
"metric": "mindful_session",
"samples": [
{
"date": "2026-04-10T08:00:00Z",
"endDate": "2026-04-10T08:15:00Z",
"qty": 900,
"rawValue": 0,
"source": "Apple Watch"
}
]
}
ECG Samples
ECG batches can include start, end, classification, numberOfVoltageMeasurements, samplingFrequency, and averageHeartRate. Store them if your backend has an ECG model, or accept the batch for compatibility.
Status Contract
GET /api/apple/status must return a flat JSON object. Every top-level key is treated as a metric name, and every top-level value should be an object with at least count. oldest and newest are optional. An empty object is valid before the first sync.
{
"heart_rate": {
"count": 123,
"oldest": "2026-04-01T08:00:00Z",
"newest": "2026-04-10T12:00:00Z"
},
"heart_rate_variability": {
"count": 45,
"oldest": "2026-04-01T08:00:00Z",
"newest": "2026-04-10T12:00:00Z"
},
"quantity_samples": {
"count": 900
}
}
Do not return {"status":"ok","counts":{...}} from this endpoint. That wrapped shape makes status look like a metric and makes counts look like one metric instead of the metric dictionary.
Sync Receipt Evidence (v2, optional)
Receipts let the app verify which batches arrived. A basic receiver can omit the receipt endpoints. The app can also send a completed-run summary, including for a run with no new records.
Request headers HealthSave sends
HealthSave includes batch identity and sync evidence on uploads. Current iPhone uploads use the body hash for Idempotency-Key. X-HealthSave-Batch-ID still carries the batch UUID. Some headers depend on the batch, such as the sample times. The v2 route adds the advisory X-HealthSave-Schema-Version header.
Idempotency-Key: sha256:<hex>
X-HealthSave-Sync-Run-ID: <run UUID>
X-HealthSave-Batch-ID: <batch UUID>
X-HealthSave-Payload-Hash: sha256:<hex>
X-HealthSave-Metric: heart_rate
X-HealthSave-Batch-Index: 0
X-HealthSave-Total-Batches: 1
X-HealthSave-Sync-Mode: incremental
X-HealthSave-Anchor-Present: true
X-HealthSave-Lower-Bound-Reason: anchor
X-HealthSave-Full-Export: false
X-HealthSave-Query-Lower-Bound: 2026-04-10T00:00:00Z
X-HealthSave-Sample-Min-Time: 2026-04-10T07:00:00Z
X-HealthSave-Sample-Max-Time: 2026-04-10T07:13:00Z
Use the headers to handle retries even if you do not expose receipts. See the pinned v1 header list, v2 header list, and reference API notes.
Idempotency contract
Save the acknowledgement with the Idempotency-Key and the SHA-256 hash of the exact request bytes. For a repeat key with the same hash, return the saved acknowledgement without writing the data again. Return 409 Conflict for a repeat key with a different body. Observatory also returns 409 when a supplied X-HealthSave-Payload-Hash does not match the request bytes.
Additive batch response fields
The core v1 success fields are unchanged. A receiver can add fields such as these for delivery receipts. The reference implementation also includes storage outcome fields when available.
{
"status": "processed",
"metric": "heart_rate",
"batch": 0,
"total_batches": 1,
"records": 1,
"receipt_id": "run_01HY:heart_rate:0",
"sync_run_id": "run_01HY",
"batch_id": "...",
"idempotency_key": "...",
"records_received": 1,
"records_accepted": 1,
"records_rejected": 0,
"verification_level": "delivery_receipt",
"sample_window": {
"min_sample_time": "2026-04-10T07:00:00Z",
"max_sample_time": "2026-04-10T07:13:00Z"
},
"per_metric": {
"heart_rate": {
"received": 1,
"accepted": 1,
"rejected": 0,
"sample_window": { "min_sample_time": "...", "max_sample_time": "..." }
}
}
}
Metric Catalog
Use the HealthSave export metric index for identifiers and the versioned sync capability list to check which platforms send them. Accept additive fields and keep the metric identifier with each batch you store.