Can watchOS apps access Apple-generated sleep stages in real time for a smart alarm?

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:

  1. 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?

  2. 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?

  3. 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?

  4. 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.

Answered by DTS Engineer in 908220022

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.

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.

Technically, if by being an alarm or similar, you were able to run in the background on watchOS, could you not use the CoreMotion framework to access the same data Apple uses to base it's sleep stages off?

I think this would be a big uphill battle as the algorithms aren't public, you'd need to make your own. But just wanted to voice the option if it was possible?