Skip to main content

Authentication

Saturday has three authentication methods, one per principal type: Most partner integrations start with API keys. Add OAuth2 when you need athletes or coaches to connect their existing Saturday accounts. Coaches automating against their roster use a coach API key, covered in the Coach API.

API keys

All server-to-server requests pass the key in the Authorization header as a Bearer token.

Key types

The prefix encodes both the principal and the environment, so a key sent to the wrong environment is refused.
Coach API keys aren’t available right now. Write to api@saturday.fit to ask about access. Until then the portal mints no coach key, and a request with a cp_ key is refused with 403 coach_keys_closed.
Coach keys (cp_*) come from the coach portal’s API Keys page. They authenticate the coach to the Coach API and are confined to that coach’s roster and configuration. A coach whose subscription lapses below Pro Coach loses cp_ key access on the next request. Coach keys use a separate scope vocabulary, chosen at mint time in the portal: roster:read, roster:write, reports:read, org:read, org:write, org:admin, webhooks:manage, billing:read. That is a different model from the partner-key scopes below, and the two do not mix. The portal offers each coach only the scopes their role and plan can mint.
Keep live keys out of client-side code: API keys belong in server-to-server requests. If a key may have leaked, revoke it.

Getting your keys

Your own key comes with any paid Saturday plan: sign in at saturday.fit/api to make it. It is shown once and emailed to your sign-in address once it is verified. If you lose it, make a new one there; the old one stops working at once. Platform partners get keys with their agreement: write to api@saturday.fit with your platform name and what you’re building. Getting Access compares the ways in.

Using your key

Key management

Creating additional keys. With one key per service or deployment stage, a leaked key reaches less, and you can rotate one without touching the others.
scopes accepts ["*"] for unrestricted, ["read"] for GET/HEAD/OPTIONS, and ["write"] for POST/PUT/PATCH/DELETE. A read-write key needs both listed: write does not imply read. A request outside a key’s scopes gets a 403 with code insufficient_scope. environment is optional and defaults to the environment of the host you call: live on api.saturday.fit, test on the sandbox host. Naming the other environment, or any other value, is a 400 with code invalid_value, because a key record only ever authenticates on the host that issued it.
Save the key immediately. The full value is returned once at creation. The id in that response is what the rotate and revoke endpoints take, so store it with the key.
Rotating keys. Rotation mints a replacement and revokes the old key in the same call, with no grace period. The old key stops working immediately.
For a cutover with no downtime, do not rotate. Create a second key, deploy it everywhere, confirm traffic has moved, then revoke the first. Revoking keys. Revocation takes effect immediately.

Environments

The key prefix and the base URL travel together. Each environment keeps separate key records, so a key issued by the sandbox does not authenticate against api.saturday.fit, and the reverse.

Sandbox behavior

  • Athlete data is isolated. Sandbox athletes are not real people
  • Nutrition calculations run the same engine as production, on sandbox profiles
  • POST /v1/test/athletes/{athlete_id}/simulate-subscription flips an athlete between tiers and fires the matching webhook, for up to 10 athletes a day per key. It exists only in sandbox
  • Teaser subscribe links carry test=1 so the whole checkout loop resolves against sandbox
  • Rate limits are enforced by the same code path as production, from your account’s configured limits. Sandbox is not exempt
  • No billing impact

Security practices

  1. Store keys in environment variables, not in source code
  2. Use separate keys for different services and deployment stages
  3. Rotate on a schedule you can keep, and immediately on any suspected exposure
  4. Watch /v1/partner/usage for patterns you cannot account for
  5. Revoke immediately if a key appears in logs, repos, or client code

Error responses

Authentication and authorization failures share the standard error envelope:
A key used against the wrong environment fails closed as invalid_api_key, and the message names the environment the key was issued for. Each environment keeps separate key records, and a record whose environment is not the host’s is refused even if it is present.