I’m evaluating a native watchOS smart-alarm app and would like to clarify whether public APIs support its core requirement before building a prototype.
The app would wake the user during a 20–30-minute window before their selected alarm time, using Apple Watch’s own sleep-stage classifications available through HealthKit’s sleepAnalysis category: Core, Deep, REM, and Awake.
I have reviewed HKCategoryValueSleepAnalysis, HKAnchoredObjectQuery, HKObserverQuery, background delivery, and WKExtendedRuntimeSession’s Smart Alarm mode. However, I haven’t found documentation establishing when Apple-generated sleep-stage samples become available during an ongoing sleep session.
Could you clarify:
-
Are Apple-generated sleep-stage samples written to the Watch’s local HealthKit store during sleep, or only after the sleep session ends or subsequent processing?
-
If available during sleep, is there any documented update cadence or latency that would make them suitable for a smart alarm? Should the latest sample be treated only as a retrospective classification rather than the current sleep stage?
-
Can an app query these samples during a Smart Alarm extended runtime session while the Watch is worn and unlocked, with its display off and Sleep Focus enabled? Are there relevant execution or data-access restrictions?
-
If this use case is unsupported, is there any public API that exposes Apple’s current sleep-stage estimate? If not, which Feedback Assistant category is appropriate for requesting this capability?
The intended approach queries HealthKit directly on Apple Watch, without depending on Watch-to-iPhone synchronization, and retains a fixed latest wake-up time as a fallback.
This is an API feasibility question, not a reproduced bug. I haven’t yet built or tested a prototype.
Thank you.
No, the sleep-stage samples are not written incrementally to the Apple Watch’s local HealthKit store during sleep. They are written in a batch after the sleep session ends and post-session processing is completed, and after that, are available in the device's HealthKit store. There is no API that exposes more information other than what you can get from the HealthKit store.
As always, please feel free to file a feedback report with your use case. Select "Developer Technologies & SDKs" as your Topic when filing your report.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.