Dr Peter Woods
← Work
API Integration · 2025

WHOOP → WhatsApp

A small, dependable bridge between a wearable API and the place conversation already happens. Each morning it authenticates, pulls the latest recovery data and posts a tidy briefing to a WhatsApp group — no app to open, no dashboard to check.

Architecture
01
WHOOP API
OAuth 2.0 · scoped read access
02
Token service
Daily refresh, encrypted at rest
03
Webhook parser
HRV · strain · sleep filters
04
Messaging gateway
Formatted broadcast to WhatsApp
The layers
AUTH

OAuth 2.0 authentication

Authorisation-code grant against the WHOOP OAuth server, exchanging a one-time code for a scoped access and refresh token pair. Scopes are limited to the recovery, cycle and sleep read endpoints — nothing writeable.

REFRESH

Automated token rotation

A scheduled job rotates the access token each morning before the first read, using the long-lived refresh token. Tokens are encrypted at rest; a failed refresh raises an alert rather than silently dropping the day's update.

PARSE

Webhook parsing & filters

Incoming webhooks are validated, de-duplicated and filtered down to the physiological metrics that matter — heart-rate variability, day strain, resting heart rate and sleep performance — discarding partial or in-progress records.

GATEWAY

Messaging gateway layer

Clean metrics are rendered into a single, readable briefing and pushed through the messaging gateway to a WhatsApp group, so the morning summary lands in the same place everyone already talks.

Sample payload

The parser collapses a verbose webhook into a stable, presentation-ready shape before it ever reaches the gateway.

{
  "date": "2025-06-18",
  "recovery": 71,        // %
  "hrv_ms": 64,
  "resting_hr": 48,      // bpm
  "sleep_performance": 88,
  "day_strain": 12.4
}

Notes

The integration is read-only and rate-limit aware: it backs off gracefully, never blocks on a single failed fetch, and degrades to a plain “no data yet” message rather than posting half-formed numbers.