Insights

Apple HealthKit Integration: Complete Developer Guide

Author
Piotr Ratkowski
Published
December 3, 2026
Last update
December 4, 2026

Table of Contents

Key Takeaways

  1. HealthKit is an on-device store with no server API, so your iOS app must read the data and upload it to your backend.
  2. Reliable sync combines HKObserverQuery with background delivery, anchored queries with persisted anchors, and retries for locked-device errors.
  3. App Store rules prohibit using HealthKit data for advertising, marketing or data mining and storing personal health data in iCloud.
  4. Once HealthKit data reaches a covered entity or business associate it is PHI, so plan BAAs, encryption, audit logs and FHIR mapping early.
  5. Google Health Connect and cloud aggregators solve different parts of the problem; aggregators still rely on an SDK inside your iOS app.

Is Your HealthTech Product Built for Success in Digital Health?

Download the Playbook
Playbook ebook illustration

Apple HealthKit integration is usually the first technical decision a digital health product makes on iOS, and an often misunderstood one. HealthKit is not a cloud service you call from your backend. It is an encrypted, on-device store that aggregates data from the iPhone, Apple Watch and third-party apps and devices, and it only hands that data to a native app the user has explicitly authorized, one data type at a time.

That design has real consequences for remote monitoring, clinical trials, coaching and care management products. You need a native iOS client, a background sync strategy, a privacy model that satisfies App Review, and a backend ready to treat the data as protected health information once it arrives. This guide covers each of those layers, compares HealthKit with Google Health Connect and aggregator APIs, and ends with an implementation checklist built around the pitfalls teams most often hit.

What Apple HealthKit is and which data you can access

HealthKit is a framework in the iOS SDK that gives apps controlled access to the Health app's data. Apple Watch, the iPhone's own motion sensors, and any app or connected device that writes to HealthKit all feed the same store. Your app reads from it and, if the user allows, writes back to it.

The data model is typed, and the type determines which query you use:

  • Quantity types (HKQuantityType): numeric samples with units, such as step count, heart rate, heart rate variability, resting heart rate, blood glucose, oxygen saturation and active energy. Blood pressure is stored as a correlation of two quantity samples.
  • Category types (HKCategoryType): enumerated values such as sleep analysis stages, mindful sessions or menstrual flow.
  • Workouts (HKWorkout): activity sessions with duration, energy, distance and associated samples and routes.
  • Clinical records: FHIR-based records that users download from supported providers into the Health app. Access requires an additional entitlement and its own usage description.

Every sample carries a source and device, start and end dates, and optional metadata. Keep them when you sync. Provenance matters when you explain a reading to a clinician or resolve duplicates.

Permissions, privacy and App Store rules for HealthKit apps

HealthKit authorization is granular. Your app calls requestAuthorization(toShare:read:) with explicit sets of types to write and read, and the user can approve or deny each type individually. The project needs the HealthKit capability enabled, plus NSHealthShareUsageDescription and NSHealthUpdateUsageDescription strings in Info.plist that explain in plain language why you need the data. Background delivery needs its own entitlement.

One rule surprises almost every team: for read permissions, HealthKit does not tell your app whether the user said no. A denied read simply returns no data, which looks identical to a user who has no data of that type. Design your UX and your analytics around that ambiguity instead of treating empty results as an error, and only request the types your feature actually uses, at the moment it needs them.

Apple's App Store Review Guidelines add policy constraints on top of the API:

  • Health data obtained through HealthKit may not be used for advertising, marketing or use-based data mining, and may not be sold or disclosed to third parties for those purposes. Permitted uses are improving health management or health research, and research use requires the user's permission.
  • You must not write false or inaccurate data into HealthKit.
  • Personal health information may not be stored in iCloud.
  • You need a privacy policy that explains what you collect and how you use it, and the HealthKit integration should be clearly visible in your app.

Practically, keep health data out of any marketing or product analytics pipeline from day one.

HealthKit architecture: syncing on-device data to your backend

Apple does not offer a server-side HealthKit API. Every byte that reaches your servers is read by your iOS app on the user's device and uploaded by that app. Your sync layer is therefore a mobile engineering problem as much as a backend one.

Apple HealthKit integration architecture: Apple Watch and iPhone write to the on-device HealthKit store, the iOS app reads it with observer and anchored queries and uploads over HTTPS to a secure backend that feeds EHR and FHIR systems
HealthKit data never leaves the device on its own: your iOS app is the only path to your backend.

A reliable pattern combines three mechanisms:

  • Observer queries with background delivery. Register an HKObserverQuery for each type and call enableBackgroundDelivery(for:frequency:). iOS wakes your app when new samples are written. The frequency is a request, not a guarantee, and Apple caps some types at hourly delivery. Always call the observer's completion handler, or the system will back off.
  • Anchored object queries for incremental reads. Inside the observer callback, run an HKAnchoredObjectQuery with the anchor saved from the last successful sync. It returns new samples and deleted objects, so your backend can mirror deletions instead of keeping data the user removed. Persist the new anchor only after the upload succeeds.
  • Statistics queries for aggregates. For daily step totals or energy, HKStatisticsCollectionQuery merges overlapping sources the way the Health app does, which avoids double counting when both the iPhone and the watch recorded steps.

Plan for the constraints of the device. The HealthKit store is encrypted while the phone is locked, so background reads can fail with a protected-data error and must be retried later. Background execution time is short, so batch uploads, keep payloads small, and queue them locally when the network is unavailable. Run a catch-up sync on every foreground launch, because background wake-ups are not guaranteed.

On the server side, accept idempotent uploads keyed by the HealthKit sample UUID, store source and device metadata, and normalize units before data reaches downstream consumers. If you also ingest data from other wearables, the same challenges appear across providers; our guide to multi-device wearable data normalization and deduplication covers how to decide which source wins.

HIPAA considerations once HealthKit data reaches your backend

HealthKit itself is a consumer platform, and data sitting on a user's own iPhone is not automatically covered by HIPAA. The picture changes when the data flows to a covered entity, such as a provider or health plan, or to a business associate building software on its behalf. At that point it is protected health information and the HIPAA Privacy, Security and Breach Notification Rules apply to the systems that store and process it.

For a HealthKit-connected product in that situation, the backend typically needs:

  • Business associate agreements with every vendor that touches PHI, including hosting, logging, error tracking and any data aggregator.
  • Encryption in transit and at rest, role-based access control, and audit logs of who accessed which patient's data.
  • A documented risk analysis and data retention policy, including what happens to data when a user revokes HealthKit access or deletes their account.
  • Consent records that capture what the user agreed to share and when.

Direct-to-consumer apps that are not covered by HIPAA are not free of obligations. In the United States, the FTC Health Breach Notification Rule can apply to health apps that collect data from consumers. If data will flow into an EHR, map it to FHIR resources such as Observation early.

HealthKit vs Google Health Connect vs wearable aggregator APIs

Most health products need both mobile platforms, and many also need direct device APIs such as Garmin, Oura or Withings.

Aspect Apple HealthKit Google Health Connect Cloud wearable aggregators
Where data lives On the iPhone (and Apple Watch), encrypted on-device On the Android device Vendor cloud, pulled from device makers' APIs and mobile SDKs
Server-side API None. Your iOS app must read and upload data None. Your Android app must read and upload data Yes, REST APIs and webhooks
Consent model Per data type, read and write requested separately; app cannot see if read access was denied Per data type via Android permissions; Google Play declaration required OAuth per provider plus on-device permissions for Apple and Android sources
Historical data Readable once access is granted Limited window before grant unless the app holds the history permission Depends on each provider's API and backfill limits
Main trade-off Richest Apple Watch data, but you build the sync layer Android coverage, but a separate client implementation Faster start, but per-user fees and a third party in your PHI data flow

Note that even cloud aggregators cannot read HealthKit from a server. They ship an iOS SDK that runs inside your app and performs the same on-device read and upload described above. The aggregator decision is really about who maintains the sync code and the provider connections, and whether you accept an extra processor in your PHI flow. We cover that trade-off in more depth in wearable API integration vs SaaS aggregators.

Apple HealthKit integration checklist and common pitfalls

Use this checklist before sprint planning:

  1. Define the data contract. List the exact HealthKit types, units, sampling needs and history depth each feature requires. Fewer types mean simpler permission prompts and an easier App Review.
  2. Design the permission flow. Ask in context, explain the benefit, and handle empty results gracefully because denied reads are invisible.
  3. Build the sync engine. Observer queries, background delivery, anchored queries with persisted anchors, a local upload queue and retry logic for locked-device errors.
  4. Handle deletions and duplicates. Mirror deleted objects, keep source metadata and use statistics queries for cumulative metrics.
  5. Separate health data from analytics. No HealthKit values in advertising, attribution or general product analytics tools.
  6. Prepare the compliant backend. BAAs, encryption, audit logging, retention and a FHIR mapping if clinical systems are in scope.
  7. Test on real devices. The simulator does not reproduce Apple Watch data or real background wake-up behavior. Test locked-device reads, offline periods and large backfills.

Common pitfalls: treating background delivery as real-time, losing anchors, double counting steps from iPhone and watch, backfills that time out for users with years of data, and analytics SDKs that capture health values. Each is cheaper to design out than to fix after launch. If HealthKit is joining an app that already has a backend, see how to add a wearable API to an existing backend.

Build your HealthKit integration with Momentum

Momentum is a healthcare software engineering company. We build iOS and Android health apps, HIPAA-ready backends and EHR/FHIR integrations, and we work on wearable data integration every day. We also maintain Open Wearables, our open-source platform for integrating wearable health data, so the sync, normalization and multi-provider problems described in this guide are ones our team works on directly.

If you are planning an Apple HealthKit integration, adding Health Connect alongside it, or moving wearable data into a clinical workflow, we can help you scope the architecture, compliance and delivery plan. Talk to our team.

Frequently Asked Questions

Does Apple HealthKit have a server-side API?
No. HealthKit is an encrypted, on-device store with no REST API, so your backend cannot pull data from it directly. Your iOS app has to read the data on the device with the user's permission and upload it to your servers. Even cloud wearable aggregators rely on an SDK running inside your iOS app to do this.
What data can you access through Apple HealthKit?
HealthKit exposes quantity types such as steps, heart rate, heart rate variability, blood glucose and oxygen saturation, category types such as sleep stages, and workouts. With an additional entitlement, apps can also read FHIR-based clinical records that users download from supported providers. Users grant access one data type at a time.
Can an app tell if a user denied HealthKit read access?
No. For read permissions HealthKit does not reveal whether the user said no, and a denied read simply returns no data. That looks the same as a user who has no data of that type, so design your UX and analytics around empty results and request only the types a feature needs, at the moment it needs them.
How do you sync HealthKit data to a backend in the background?
Register an HKObserverQuery for each data type with background delivery enabled, then run an HKAnchoredObjectQuery from the last saved anchor to fetch new and deleted samples. Save the new anchor only after the upload succeeds, queue uploads locally, and retry reads that fail while the phone is locked. Run a catch-up sync on every foreground launch because background wake-ups are not guaranteed.
Is HealthKit data covered by HIPAA?
Data sitting on a user's own iPhone is not automatically covered by HIPAA. Once it flows to a covered entity or a business associate building software on its behalf, it becomes protected health information and needs business associate agreements, encryption, access control and audit logs. Consumer apps outside HIPAA can still fall under the FTC Health Breach Notification Rule.
What App Store rules apply to apps that use HealthKit?
HealthKit data may not be used for advertising, marketing or use-based data mining, or sold to third parties for those purposes. Apps may not store personal health information in iCloud or write false data into HealthKit, and they need a privacy policy that explains what they collect. Research use requires the user's permission.
Should you integrate HealthKit directly or use a wearable aggregator?
A direct integration gives you full control and keeps an extra vendor out of your PHI data flow, but your team builds and maintains the sync layer. Aggregators offer a faster start and multi-provider coverage through REST APIs and webhooks, at the cost of per-user fees and a third-party processor. Android still needs a separate Health Connect client either way.

Written by Piotr Ratkowski

Head of Growth
Grows Momentum's client portfolio and advises HealthTech teams on product strategy, market positioning, and where AI actually makes a difference. Writes about the trends and decisions shaping digital health.

See related articles

Green background with decorative circles

Planning an Apple HealthKit integration?

Let's Create the Future of Health Together

We build HealthKit and Health Connect integrations, background sync pipelines and HIPAA-ready backends for digital health apps. Tell us what data you need and we will help you scope the architecture.

Looking for a partner who not only understands your challenges but anticipates your future needs? Get in touch, and let’s build something extraordinary in the world of digital health.

Newsletter

Piotr Ratkowski