Apple Healthkit sleep data includes a few different data types. The iPhone itself can only track time in bed (value: InBed) while the Apple Watch tracks time asleep (Values: Awake, AsleepREM, AsleepCore, AsleepDeep) and also in bed.
A visual representation of the Apple sleep data types (refer to Apple's documentation for further detail):
The iPhone calculates "InBed" by analyzing your motion and device usage, using the parameters the user sets in the Apple BedTime app. The Apple Watch calculates "Asleep" time using movement and also your heart rate. By comparing the start and end times of these samples, a number of secondary statistics can be calculated by projects: the amount of time it took for the user to fall asleep, the percentage of time in bed that the user actually spent sleeping, the number of times the user woke while in bed, and the total amount of time spent both in bed and asleep. As seen in the above diagram, samples overlap with "InBed", but not with one another.
3rd party (non-Apple) applications can also write data to the Apple Healthkit variables (using sensors and methodology of their choosing). However, the source "identifier" listed in MyDataHelps Designer (i.e. in the participant viewer Apple Healthkit tab) would be different - that is, iOS first-party should have an identifier “com.apple.Health” or “com.apple.Health.(random identifier)”. An example of a 3rd party app would be “com.tenminutewait.PinnacleApp” (a workout app called Pinnacle).
Devices running older iOS/watchOS or third party devices may only write "InBed", "Asleep", and "Awake" values, without further details on sleep stages. If you are conducting a study that requires this level of granularity, we recommend researching FitBit devices.