SleepSessionRecord: Health Connect sleep session data
Read from Google’s documentation on 2026-10-03 · Google’s reference page last updated 2026-06-24
SleepSessionRecord is Health Connect's sleep session record — an Interval record in Google's Sleep category. Its read permission is android.permission.health.READ_SLEEP; its write permission is android.permission.health.WRITE_SLEEP. It supports 1 aggregate metric (SLEEP_DURATION_TOTAL). Mandatory fields per Google's table: endTime, metadata, stages and startTime.
What Google says SleepSessionRecord is
Captures the user's sleep length and its stages. Each record represents a time interval for a full sleep session.
All sleep stage time intervals should fall within the sleep session interval. Time intervals for stages don't need to be continuous but shouldn't overlap.
Example code demonstrate how to read sleep session:
Google’s example is reproduced under Read SleepSessionRecord in Kotlin.
Quoted from Google’s SleepSessionRecord Jetpack reference, last updated 2026-06-24, read 2026-10-03.
- Class
androidx.health.connect.client.records.SleepSessionRecord- Google's category
- Sleep
- Record type
- Interval
- Unit class
- none named in Google's table
- Mandatory fields
endTimemetadatastagesstartTime- Added in (Jetpack)
1.1.0
Permissions
The exact strings Google’s data-types table declares for SleepSessionRecord. Google’s page: “Before requesting any permissions, your app must declare them in the manifest.”
| Access | Permission string | Framework reference |
|---|---|---|
| Read | android.permission.health.READ_SLEEP | API 34 · U Ext 7 |
| Write | android.permission.health.WRITE_SLEEP | API 34 · U Ext 7 |
<uses-permission android:name="android.permission.health.READ_SLEEP" />
<uses-permission android:name="android.permission.health.WRITE_SLEEP" />import androidx.health.connect.client.permission.HealthPermission
import androidx.health.connect.client.records.SleepSessionRecord
val permissions = setOf(
HealthPermission.getReadPermission(SleepSessionRecord::class),
HealthPermission.getWritePermission(SleepSessionRecord::class),
)The 8 fields of SleepSessionRecord
Types and descriptions as Google’s reference prints them. The range column quotes Google’s own range annotation or sentence; a dash means Google states none, which is not the same as no validation.
| Field | Type | Allowed range | Google’s description |
|---|---|---|---|
endTimemandatory | Instant | — | End time of the record. |
endZoneOffset | ZoneOffset? | — | User experienced zone offset at endTime, or null if unknown. Providing these will help history aggregations results stay consistent should user travel. Queries with user experienced time filters will assume system current zone offset if the information is absent. |
metadatamandatory | Metadata | — | Set of common metadata associated with the written record. |
notes= null | String? | — | Additional notes for the session. Optional field. |
stagesmandatory= emptyList() | List<SleepSessionRecord.Stage> | — | Google gives no description. |
startTimemandatory | Instant | — | Start time of the record. |
startZoneOffset | ZoneOffset? | — | User experienced zone offset at startTime, or null if unknown. Providing these will help history aggregations results stay consistent should user travel. Queries with user experienced time filters will assume system current zone offset if the information is absent. |
title= null | String? | — | Title of the session. Optional field. |
Nested types
SleepSessionRecord.Stage— Captures the sleep stage the user entered during a sleep session.
Aggregate metrics
The AggregateMetric constants Google defines on SleepSessionRecord. The value type is the T in Google’s AggregateMetric<T> signature. Every aggregate metric across all records.
| Metric | Value type | Google’s description |
|---|---|---|
| SleepSessionRecord.SLEEP_DURATION_TOTAL | Duration | Metric identifier to retrieve the total sleep session duration from androidx.health.connect.client.aggregate.AggregationResult. |
Google’s read-data guide: “For cumulative types like StepsRecord, use aggregate() instead of readRecords() to avoid double counting from multiple sources and improve accuracy.” and “The aggregation API also contains logic to handle duplicate records, and lessens the chances of rate limiting.”
Constants
The 8 const val values Google’s reference lists on SleepSessionRecord, with the integer each maps to.
| Constant | Value | Google’s description |
|---|---|---|
SleepSessionRecord.STAGE_TYPE_AWAKE | 1 | The user is awake and either known to be in bed, or it is unknown whether they are in bed or not. |
SleepSessionRecord.STAGE_TYPE_AWAKE_IN_BED | 7 | The user is awake and in bed. |
SleepSessionRecord.STAGE_TYPE_DEEP | 5 | The user is in a deep sleep stage. |
SleepSessionRecord.STAGE_TYPE_LIGHT | 4 | The user is in a light sleep stage. |
SleepSessionRecord.STAGE_TYPE_OUT_OF_BED | 3 | The user is out of bed and assumed to be awake. |
SleepSessionRecord.STAGE_TYPE_REM | 6 | The user is in a REM sleep stage. |
SleepSessionRecord.STAGE_TYPE_SLEEPING | 2 | The user is asleep but the particular stage of sleep (light, deep or REM) is unknown. |
SleepSessionRecord.STAGE_TYPE_UNKNOWN | 0 | Use this type if the stage of sleep is unknown. |
Read SleepSessionRecord in Kotlin
The shape of Google’s own read example, with SleepSessionRecord and its names filled in. Get the client with HealthConnectClient.getOrCreate(context) after checking getSdkStatus.
import androidx.health.connect.client.HealthConnectClient
import androidx.health.connect.client.records.SleepSessionRecord
import androidx.health.connect.client.request.ReadRecordsRequest
import androidx.health.connect.client.time.TimeRangeFilter
import java.time.Instant
suspend fun readSleepSession(
client: HealthConnectClient,
startTime: Instant,
endTime: Instant,
): List<SleepSessionRecord> {
val response = client.readRecords(
ReadRecordsRequest(
SleepSessionRecord::class,
timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
)
)
// One page of up to pageSize records (default 1000); follow
// response.pageToken for the rest.
return response.records
}import androidx.health.connect.client.HealthConnectClient
import androidx.health.connect.client.records.SleepSessionRecord
import androidx.health.connect.client.request.AggregateRequest
import androidx.health.connect.client.time.TimeRangeFilter
import java.time.Instant
import java.time.Duration
suspend fun aggregateSleepSession(
client: HealthConnectClient,
startTime: Instant,
endTime: Instant,
): Duration? {
val response = client.aggregate(
AggregateRequest(
metrics = setOf(SleepSessionRecord.SLEEP_DURATION_TOTAL),
timeRangeFilter = TimeRangeFilter.between(startTime, endTime),
)
)
// get() is declared as returning a nullable value.
return response[SleepSessionRecord.SLEEP_DURATION_TOTAL]
}import androidx.health.connect.client.readRecord
import androidx.health.connect.client.records.SleepSessionRecord
import androidx.health.connect.client.request.ReadRecordsRequest
import androidx.health.connect.client.time.TimeRangeFilter
val response =
healthConnectClient.readRecords(
ReadRecordsRequest<SleepSessionRecord>(
timeRangeFilter = TimeRangeFilter.between(startTime, endTime)
)
)
for (sleepRecord in response.records) {
// Process each sleep record
}Reproduced from Google’s reference page , whose footer states its content and code samples are subject to the licenses described in Google’s Content License.
Setting up the client, the permission flow and Play Console declaration: integrating Health Connect step by step.
HealthKit counterpart
The verified cross-platform matrix pairs SleepSessionRecord with HKCategoryTypeIdentifier.sleepAnalysis (values: inBed, awake, asleepCore, asleepDeep, asleepREM, asleepUnspecified) in its Sleep row.
On the HealthKit reference: sleepAnalysis.
Watch out: Stage vocabularies differ and stages are estimated, not measured. Apple deprecated .asleep in iOS 16.0 and points to .asleepCore, .asleepDeep, .asleepREM or .asleepUnspecified instead (.asleepUnspecified is the rename).
The metric on other platforms
This guide lists SleepSessionRecord beside the types on the other platforms this site covers whose own descriptions name the same metric, each quoted, with how each one is read.
Questions
- What permission does SleepSessionRecord need?
- Google's Health Connect data-types table (read 2026-10-03) declares android.permission.health.READ_SLEEP for reading SleepSessionRecord and android.permission.health.WRITE_SLEEP for writing it, and says apps must declare permissions in the manifest before requesting them.
- Which aggregate metrics does SleepSessionRecord support?
- Google's Jetpack reference defines 1 on SleepSessionRecord: SLEEP_DURATION_TOTAL (AggregateMetric<Duration>). Pass it in the metrics set of an AggregateRequest and read it back from the AggregationResult.
- Which constants does SleepSessionRecord define?
- Google's reference lists 8 constants on SleepSessionRecord, including STAGE_TYPE_AWAKE = 1, STAGE_TYPE_AWAKE_IN_BED = 7, STAGE_TYPE_DEEP = 5, STAGE_TYPE_LIGHT = 4, STAGE_TYPE_OUT_OF_BED = 3, STAGE_TYPE_REM = 6, STAGE_TYPE_SLEEPING = 2 and STAGE_TYPE_UNKNOWN = 0. Store the constant name or the value it maps to, and treat values you do not recognise as unknown.
- What is the HealthKit equivalent of SleepSessionRecord?
- This site's verified cross-platform matrix pairs SleepSessionRecord with HKCategoryTypeIdentifier.sleepAnalysis (values: inBed, awake, asleepCore, asleepDeep, asleepREM, asleepUnspecified) in its Sleep row. The caveat recorded with that pairing: Stage vocabularies differ and stages are estimated, not measured. Apple deprecated .asleep in iOS 16.0 and points to .asleepCore, .asleepDeep, .asleepREM or .asleepUnspecified instead (.asleepUnspecified is the rename).
Sources checked
- Google — SleepSessionRecord (Jetpack reference) — last updated 2026-06-24 · read 2026-10-03
- Google — Health Connect data types · read 2026-10-03
- Google — HealthPermissions (framework reference) · read 2026-10-03
- Google — Read raw data (Health Connect guide) · read 2026-10-03
Google’s descriptions are quoted for identification; the page layout, the capsule and the cross-platform pairing are AIFitnessAPI’s. Generated from Google’s pages by a script, not typed by hand — the same data is behind every page in the Health Connect reference.