---
url: /docs/api/core/variables/sleepRecordSchema.md
---
[**@kaiord/core**](../README.md)

***

[@kaiord/core](../README.md) / sleepRecordSchema

# Variable: sleepRecordSchema

> `const` **sleepRecordSchema**: `ZodObject`<{ `endTime`: `ZodISODateTime`; `externalId`: `ZodOptional`<`ZodString`>; `kaiordRecordId`: `ZodOptional`<`ZodString`>; `kind`: `ZodLiteral`<`"sleep"`>; `restingHeartRate`: `ZodOptional`<`ZodNumber`>; `score`: `ZodOptional`<`ZodNumber`>; `sourceBridgeId`: `ZodOptional`<`ZodString`>; `stages`: `ZodArray`<`ZodObject`<{ `durationSeconds`: `ZodNumber`; `stage`: `ZodEnum`<{ `awake`: `"awake"`; `deep`: `"deep"`; `light`: `"light"`; `rem`: `"rem"`; }>; `startTime`: `ZodISODateTime`; }, `$strip`>>; `startTime`: `ZodISODateTime`; `totalDurationSeconds`: `ZodOptional`<`ZodNumber`>; `version`: `ZodString`; }, `$strip`>

Defined in: [packages/core/src/domain/schemas/health/sleep.ts:35](https://github.com/pablo-albaladejo/kaiord/blob/3eacbe62ef72342d970523967cc5155b5935bb85/packages/core/src/domain/schemas/health/sleep.ts#L35)

Zod schema for `extensions.health.sleep` — a single overnight sleep
session with REM/deep/light/awake stages, total duration, and optional
sleep score / resting heart rate.

`stages: []` means the stages were not recorded (e.g. a hand-entered
night), so the stage-sum check only applies when stages are present.
An absent `totalDurationSeconds` means the duration was not recorded
(e.g. only a score was entered); it is never stored as `0`.

`version` is constrained to `2.x` so future additive evolution within
the v2 line is accepted without bumping the canonical KRD version.
