Webhooks
Register a webhook URL and Saturday POSTs events to it as they happen, so you do not have to poll the API for changes. The examples read your key from aSATURDAY_API_KEY environment variable, as in Quickstart. Sandbox keys are issued with a separate base URL; using one against api.saturday.fit returns 401 invalid_api_key.
Registering a webhook
url and events; any other field is refused with 400, code unsupported_field and the field in param: a description answers "description" is not a webhook field. A webhook takes url and events. The response is 201 with the new webhook under webhook and a request_id beside it. The webhook carries id, url, events, active, fail_count, created_at and updated_at in Unix seconds, and secret, a 64-character hex string.
A partner may hold up to 20 webhooks. Registration rejects URLs that resolve to private, loopback, or cloud-metadata addresses, and URLs on ports other than 443 and 80. The scheme must be https in production; the test environment also accepts http. Each of these rejections, and the 21st webhook, is a 400 with code webhook_error and the reason in message. If Saturday’s key service is briefly unavailable at creation time the request returns 503 with Retry-After: 30 rather than storing an unencrypted secret, so retry on 503.
Available events
These event types are emitted today:
Registration also accepts four names that will not reach a partner webhook.
subscription.updated and partner.rate_limit_approaching are reserved and have no emitter at all. concern.detected and athlete.needs_attention are live, but they are delivered on the separate coach webhook lane, to endpoints a coach registers against the coach’s account, never to a partner webhook; see the Coach API. Subscribing to any of the four on a partner webhook is accepted and then silent, so do not build against them here.
Any name outside this list is rejected with 400, and one bad name fails the entire registration rather than the single event, so register only the names above.
Subscription event payloads
subscription.created fires once per unlock, after the purchase record exists and never before. A resubscribe after cancellation fires it again.
source values: checkout_subscription, checkout_lifetime (no expires_at), existing_subscription_linked (a subscribed Saturday account tapped your CTA and was linked without being charged), email_match (a paying Saturday account was linked to your athlete automatically by email, see Freemium Model, Automatic linking by email), simulated (test env only). expires_at is in Unix seconds.
subscription.cancelled means the athlete’s next calculate returns teaser ranges:
reason is the Stripe event type that ended access, such as customer.subscription.deleted, or one of expired, refund, dispute, email_match_decayed (an email-matched link that stopped matching), account_deleted (the athlete’s linked Saturday account was deleted), and simulated (test env only).
When a Saturday account is deleted
What you receive when an athlete deletes their Saturday account depends on how your athlete record relates to that account.- The record’s
athlete_idis the Saturday account id. Saturday deletes the record and sendsathlete.deleted, withdataholdingathlete_idonly and the eventidset toathlete_deleted_followed by the athlete id, the same on every send. - You created the record, and the athlete connected it to their Saturday account (a checkout from your subscribe link, or a confirmed email match). The record is yours and stays; no
athlete.deletedis sent. Saturday removes the connection to the account. If you had receivedsubscription.createdfor that connection, you receivesubscription.cancelledwith"tier": "teaser"and"reason": "account_deleted", and the athlete’s next calculation returns teaser ranges. If the athlete was sharing their Saturday app answers with you, you also receiveathlete.profile_sharing_changed, whose record showsprofile_sharing: "not_linked".
Profile sharing event payloads
Like the otherathlete.* events, both sharing events carry the athlete record, as GET /v1/athletes/{athlete_id} returns it when the event is sent. The athlete’s id is data.id. Unlike athlete.created and athlete.updated, the record includes the two fields computed on read, subscription_status and profile_sharing.
athlete.profile_sharing_changed says the athlete’s sharing state changed; profile_sharing is the new state, on, off, or not_linked:
- the athlete turns sharing with you on or off, in the Saturday app or on the hosted onboarding page (
onafter they confirm the hosted page’s email), or their account now reads as under 18 (off); - a Saturday account that shares with you is linked to the athlete (
on); - the link goes, or moves to another Saturday account, while the athlete shared with you (
not_linked, or the new account’sonoroff).
GET /v1/athletes/{athlete_id} then reads off.
athlete.fueling_profile_updated adds changed_fields to the record: the names of the shared answers that changed, never their values.
changed_fields uses the entry names of the fueling-profile response (sex, age, athlete_weight_kg, sweat_level, saltiness, satiety_level, fitness_level, carb_experience, usual_carb_consumption, concerns), in that order. The record’s settings are what you store, not the Saturday app answers; read those from GET /v1/athletes/{athlete_id}/fueling-profile. The save that turns sharing on sends only athlete.profile_sharing_changed, so read the profile then.
Both events go to each athlete record linked to the Saturday account, one event per record. Treat them as a cue to read the fueling-profile route, the source of truth, rather than as an ordered log: the record is read when the event is sent, so a late redelivery shows the athlete as they are then. Their ids are evt_ and 32 hex characters, the same on a redelivery, so a repeat can be dropped by id.
Don’t cache tier from webhooks alone.
GET /v1/athletes/{id} returns a computed subscription_status (full | trial | teaser) whenever you need ground truth, for example when an athlete returns from checkout.Webhook payload format
Every delivery has this envelope.id identifies the event and created_at is when it happened, in Unix seconds, like every time in the payload and the t of the signature header. This one carries a full-tier prescription from POST /v1/nutrition/calculate:
data carries depends on the event:
A calculation with no athlete (a
POST /v1/nutrition/calculate without athlete_id) carries neither id; tier tells you which tier the caller received.
Athlete and activity identifiers are UUIDs with no prefix. Treat an event id as an opaque string: most are UUIDs, an athlete.deleted sent because the athlete deleted their Saturday account is athlete_deleted_ and the athlete id, and the two sharing events are evt_ and 32 hex characters. Do not pattern-match on any of them.
Verifying webhook signatures (HMAC-SHA256)
Every delivery carries these headers:
Verify the signature on every request. It is the only thing distinguishing a Saturday delivery from anyone who has guessed your endpoint URL.
The signature is computed as
HMAC-SHA256(webhook_secret, timestamp + "." + raw_body), where timestamp is the t value from the header in Unix seconds and raw_body is the exact bytes received. Parsing and re-serializing the JSON before verifying will change the bytes and break the comparison.
Verification steps
- Extract the timestamp and signature from the header
- Reconstruct the signed payload:
{timestamp}.{raw_body} - Compute HMAC-SHA256 using your webhook secret
- Compare with constant-time equality
Retry behavior
A delivery counts as failed if your endpoint returns a non-2xx status, times out, or cannot be reached. Saturday then retries on this schedule:
Retries are scheduled durably, so they survive a restart on Saturday’s side. Each retry re-reads your webhook’s current URL and secret, which means fixing a bad URL mid-schedule lets the remaining retries land. After the 5th retry the delivery is marked exhausted and is not attempted again. A webhook you delete or deactivate mid-schedule stops retrying.
Redirects are not followed: a
3xx counts as a failure, so register the final URL rather than a redirector.
Auto-disable
Each exhausted delivery increments a consecutive-failure counter on the webhook. Any successful delivery resets it to zero. At 15 consecutive exhausted deliveries Saturday sets the webhook inactive, stampsdisabled_at, and stops sending to it. Given the retry schedule above, that is roughly three days of an endpoint being consistently down, though the exact wall time depends on your event volume.
Re-enable it from the API once the endpoint is healthy. Re-enabling resets fail_count to zero and clears disabled_at:
Best practices
- Return 200 immediately, then process asynchronously. Saturday closes the connection 10 seconds after the request starts, and a slow handler burns retries.
- Handle duplicates using the
idfield. Delivery is at-least-once, so the same event can arrive more than once. - Verify the signature on every request before acting on the payload.
- Serve HTTPS on port 443. Production registration requires
https; the test environment also acceptshttp, and both environments reject non-standard ports. - Log the raw body and the event
idbefore parsing. Signature failures are almost always a body-mutation problem, and the raw bytes are what let you prove it.
Managing webhooks
PATCH /v1/webhooks/{webhook_id} takes any of url, events, and active, validates a new URL and event list the same way registration does, and returns the updated webhook. A body naming none of the three returns 400 with code no_changes. DELETE returns 204.
POST /v1/webhooks/{webhook_id}/test delivers synchronously and returns the delivery record under delivery, including the status code your endpoint returned. Use it to confirm signature verification works before you depend on live events. The test event has type webhook.test and a data object holding a single message string. Subscribing to it is valid but unnecessary: the test delivery reaches your endpoint regardless. Your handler should still ignore event types it does not recognize rather than erroring on them.
GET /v1/webhooks/{webhook_id}/deliveries returns the 50 most recent attempts for that webhook, newest first, under deliveries. Each carries status (pending, delivered, failed, or exhausted), status_code, attempts, created_at, next_retry_at and completed_at (Unix seconds), and response_body, the first kilobyte of your endpoint’s response body, which is usually enough to see why a delivery failed.