← Back to Cadence

Sleep from Apple Health to Cadence

Apple doesn't let websites read Health data directly. This Shortcut bridges the gap: it reads last night's sleep from the Health app and opens Cadence with the numbers in the link. One tap each morning.

Privacy: your sleep data travels in the URL hash fragment (the part after #), not a query string. Hash fragments are never sent to any server and never appear in Cloudflare logs. Cadence reads it on your device, saves it locally, then strips it from the address bar.

Build the Shortcut

Sleep Analysis returns many samples per night (In Bed, Core, Deep, REM, Awake). We filter to just the asleep stages.

  1. Open the Shortcuts app on your iPhone.
  2. Tap + to create a new shortcut. Name it "Send sleep to Cadence".
  3. Add Find Health Samples: Type Sleep Analysis, Start Date in the last 18 hours, sorted by Start Date (oldest first).
  4. Add Filter: keep samples where Value is one of Asleep Core, Asleep Deep, Asleep REM. (This drops In Bed and Awake.)
[Screenshot: Find + Filter for asleep stages]
  1. Add Get Details of Health Sample: get Duration from the filtered samples.
  2. Add Calculate Statistics: Sum of the durations. This is total asleep seconds.
  3. Add Calculate: sum ÷ 3600, then Round to 1 decimal. This is your hours (e.g. 7.2).
  4. Bed time: from the filtered samples, Get Details Start Date, then Get Minimum (earliest). Format as HH:mm (23:10).
  5. Wake time: from the filtered samples, Get Details End Date, then Get Maximum (latest). Format as HH:mm (06:40).
  6. Add a Text action:
    https://cadence24.com/#sleep=7.2&bed=23:10&wake=06:40
    Replace the numbers with your variables.
[Screenshot: Text action with the cadence24.com URL]
  1. Add Open URLs with that text.
  2. Fallback (recommended): also add Copy with just sleep=7.2&bed=23:10&wake=06:40 (no URL). If the Home Screen app and Safari keep separate data, tap Paste from Shortcut on the Today tab instead.
  3. Tap Done. Run once to grant Health access.

Run it automatically when your alarm stops

  1. In Shortcuts, go to the Automation tab.
  2. Tap +, choose Alarm, then When an alarm is stopped. Pick your morning alarm.
  3. Choose Run Immediately (no confirmation), and select your "Send sleep to Cadence" shortcut.
  4. Now each morning when you stop your alarm, Cadence opens with last night's sleep ready to confirm.
[Screenshot: Alarm automation configured]

What Cadence does with it

When the page loads, Cadence reads the hash, checks the numbers are sane (0 to 14 hours of sleep, valid times), saves them on your device, and removes the hash from the address bar with history.replaceState. Nothing leaves your phone.

Open Cadence