> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/help-center/help-topics/data-api-sdk/webhooks-dedup-and-sync-reliability/sleep-dedup-summary-id.md).

# How do I dedupe sleep webhooks with the same start time?

Use the summary\_id field under metadata to uniquely identify and update sleep records, rather than the start\_time/end\_time pair.

**Use the `summary_id` field under `metadata` to uniquely identify and update sleep records**, rather than the `start_time`/`end_time` pair. A sleep session can be re-sent with an extended end time but the same `summary_id`, which is why the timestamp pair breaks dedup.

Recommended approach:

* **Match on `summary_id` first**, falling back to start/end times only when `summary_id` is absent. Apple Health is the exception, see below.
* Sleep payloads return one record per session.
* For daily summaries (where steps, distance, calories, and temperature delta live), query `/v2/daily` with `to_webhook=false` and `with_samples=false`.
* To compute a day's total sleep, use the session whose `end_time` falls in the morning of the target date (filtering naps via the `is_nap` flag), rather than summing overlapping sessions. This matches how providers report nightly sleep.

## Apple Health sleep

**For Apple Health, match sleep to a night by overlapping start and end times, not by `summary_id`.** Apple Health sleep has no ID of its own, so its `summary_id` is generated from the session's start time. Sleep samples can keep reaching Apple Health after the user wakes. If a later sample starts earlier, the session start moves and the night comes back with a new `summary_id`.

The iOS SDK groups sleep samples that are less than an hour apart into one session.

No field marks an Apple Health night as final. `upload_type` isn't one: it only says whether the data was recorded automatically or entered manually. To act once per night, wait until no new payload for that night has arrived for a period you choose.
