API Endpoint
API Endpoint is an export target for users who want Health.md data to flow into their own server, webhook, database, dashboard, or automation. The iPhone still reads Apple Health. Instead of writing files, it POSTs JSON to the endpoint you configure.
This target intentionally sends selected health data to the URL you enter. Use an endpoint you control or trust, prefer HTTPS, and limit metrics to what your service actually needs.
Set up the target
Section titled “Set up the target”- Open Health.md on iPhone.
- Go to Export.
- In Export Target, choose API Endpoint.
- Enter a URL such as
https://api.example.com/healthmd/ingest. - Optional: enter a bearer token. Health.md stores it in Keychain.
- Tap Done, choose your date range and metrics, then tap Export.
If you enter a plain token, Health.md sends it as Authorization: Bearer <token>. If the value already starts with Bearer or Basic , Health.md sends it as entered.
Payload shape
Section titled “Payload shape”Health.md sends one POST per export action. The body is an independently versioned healthmd.api_export envelope containing public schema-v8 healthmd.health_data daily records. API envelope v1 carries the daily records. V2 can additionally carry provider sidecars without changing the daily-record schema.
Inspect the complete production-generated API v1 envelope and API v2 provider-sidecar envelope. The API and CLI contract documents every field, version boundary, and acceptance rule.
Endpoint requirements
Section titled “Endpoint requirements”For reliable ingestion, make your endpoint idempotent by date. A user may repeat the same export range after changing metrics or fixing a server error.
- Test with one day before uploading a long backfill.
- Keep Lossless Health Records enabled when source completeness matters. Reduce the date range for dense routes, clinical documents, ECGs, or attachments.
- Validate the token server-side before storing any payload.
- Use
records[].dateas the primary per-day key. - Return a concise error body. Health.md only displays a short preview.
Troubleshooting
Section titled “Troubleshooting”| Problem | Usually means | Fix |
|---|---|---|
| API target is not ready | URL is empty or invalid | Reopen API Endpoint settings and enter a valid HTTP(S) URL. |
| HTTP 401 or 403 | Token missing or rejected | Update the token or server auth rules. |
| HTTP 404 | URL path is wrong | Check the route on your server. |
| HTTP 413 | Payload is too large | Export fewer days; use summary-only output only when your receiver does not require canonical source records. |
| Some dates are missing | No enabled HealthKit data for those dates | Check failed_date_details and your metric selection. |