From c3f41711b91233445f8223c619144a8ae4b2188f Mon Sep 17 00:00:00 2001 From: Alex Harrison Date: Thu, 19 Nov 2026 10:20:09 -0700 Subject: [PATCH 1/2] 0.8.0: match the partner API as it stands after this week's fixes The sync route takes intervals.icu tokens only and answers {result, request_id}; external_id is unique (409 athlete_exists, ConflictError); trial bounds and the trial's length on GET /v1/partner; fit and compare spend a trial call (plan_basis.source trial_allowance); simulated subscribers are bounded on the test environment (simulated_subscriber_daily_limit_reached); a PATCH that changes the session removes the stored prescription; prep refuses products beside legs; erase's scope and its 503; discovery's get_a_key in place of the key purchase. README: a key comes with any paid Saturday plan. Recordings from a local partner-api built from fuel-backend main with #2324, #2326, #2328, #2331 and #2330 merged. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 9 + README.md | 35 ++- saturday/__init__.py | 14 + saturday/client.py | 110 +++++-- saturday/errors.py | 33 +- saturday/types.py | 133 +++++++- tests/LIVE.md | 5 +- tests/fixtures/contracts.json | 56 +--- tests/fixtures/live.json | 561 ++++++++++++++++++---------------- tests/test_hidden_routes.py | 5 +- tests/test_live.py | 49 ++- tests/test_request.py | 42 ++- 12 files changed, 680 insertions(+), 372 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01fc062..7f2e4b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Breaking changes: +- `integrations.sync` takes `"intervals_icu"` only: the API refuses Strava and TrainingPeaks tokens with a `ValidationError` of code `invalid_provider`. Send TrainingPeaks workouts with `activities.import_activities` once the athlete agrees to share them. `sync` takes `date_range` (`{"start", "end"}`; it said `from` and `to`, which the API never read) and `sync_types` (default `["activities"]`, sent for you) as keyword arguments; `refresh_token` and other options are gone (the API did not use them). The answer is `IntegrationSyncResponse`, `{"result", "request_id"}`, with what the sync did under `result` (`IntegrationSyncResult`, whose `status` is `completed`, `partial` or `failed`). `integrations.disconnect` returns `IntegrationDisconnectResponse` (`message`, `provider`, `request_id`). `IntegrationProvider` and `SyncProvider` name the providers each route takes. +- `external_id` is unique within your account. `athletes.create` or `athletes.update` with an `external_id` another of your athletes holds changes nothing and raises the new `ConflictError` (409, code `athlete_exists`), whose `athlete_id` names that athlete; a `batch_create` item fails with `athlete_exists` and `errors[i]["athlete_id"]`. A retried create is safe. +- `meta.discovery()` returns `DiscoveryResponse`: `get_a_key` (`DiscoveryKeyInfo`) says how a key is had (any paid Saturday plan, made at saturday.fit/api, `athletes_per_key`, `api@saturday.fit`). The API no longer sells a key, so nothing in the package names a price or a signup route. - `products`, `gear` and `ai` are removed, with their types, `AIStreamError` and `AIStreamEvent`. Those routes are not open to partner keys. - `webhooks.create(url, events)` returns `WebhookCreateResponse`: the webhook, with its signing secret, is under `webhook`; read `response["webhook"]["secret"]`. `webhooks.list()`, `get()`, `update()` and `test()` are typed (`WebhookListResponse`, `Webhook`, `WebhookTestResponse`). The `description` argument is gone; the API does not take one. - `webhooks.update` takes `url`, `events` and `active` as keyword arguments; `organizations.add_member` takes `role` and `athlete_id` as keyword arguments; `activities.submit_feedback` takes `rating` and `notes`. @@ -21,6 +24,12 @@ Breaking changes: Added: +- `ConflictError` (409); `SaturdayError.athlete_id` and `BatchError["athlete_id"]`. +- The trial's bounds on calculate and the activity calculate (`TrialMetadata`): `trial_start_deferred` (your key has started its new trials for the UTC day), `trial_profile_limit_reached` (the athlete's trial covers its allowance of distinct profiles) and `trial_note`, words you can show the athlete; on the test environment, `simulated_limit_reached` and `simulation_note`. Product fit and compare answers carry `trial_start_deferred` and `trial_note` on the teaser tier. `PlanBasisSource` gains `trial_allowance` (product fit and compare spend one of the athlete's trial calls, as calculate does, and plan from ranges once today's calls are used) and `simulation_allowance`. +- `PartnerRateLimits` gains `trial_starts_per_day`, `trial_profiles_per_athlete` and `trial_days`, the trial's length. `PartnerAccount["plan"]` `individual` is a key that comes with a Saturday account's paid plan. +- `DAILY_LIMIT_CODES` gains `simulated_subscriber_daily_limit_reached`: on the test environment, `testing.simulate_subscription` marks at most 10 athletes per key per UTC day by default, then raises `RateLimitError` with `daily_limit` True and `resets_at`. +- `PermissionDeniedError` documents `plan_inactive` (the paid plan a key comes with has ended; the key works again, with its athletes, once the plan is active) and `resource_limit_exceeded` (the key's athletes are at their limit). +- Documented: `activities.update` with a change to the session removes the stored prescription, so `get_prescription` raises `NotFoundError` (`prescription_not_found`) until the activity is calculated again; `activities.prep` with both `products=` and `legs=` is refused (`invalid_value` on `products`); `athletes.erase` revokes the connections you supplied, deletes everything stored under the athlete and its link to a Saturday account, leaves the member's own Saturday account as it is, and answers 503 `provider_erasure_incomplete`, having deleted nothing, when a connection could not be revoked yet. The README's new "Get a key" section: a key comes with any paid Saturday plan, from saturday.fit/api, and covers 10 athletes; for more, write to api@saturday.fit. - `nutrition.product_fit`, `nutrition.compare_products` and `activities.prep`, with `PlanBasis` for plans made from the middle of the ranges, naming what is missing. - Prep, product fit and compare on a brick or triathlon: `product_fit` and `compare_products` take `legs`, and their answers carry `ProductFitLeg` and `ProductCompareLeg` under `legs`, each leg's share with the product or products sized against it; compare's `winner` is `ComparisonWinner`. `activities.prep(..., legs=[...])` takes a product list per leg, and `PrepLeg` comes under `PrepResponse["legs"]`, whose top level is the legs added up. - `Precision["missing_profile_fields"]` and `Precision["missing_session_inputs"]`: the profile answers and session inputs a calculation lacks, sent to a partner key on every tier. `MissingField["required"]` documents what it marks: the safety core, with every listed field needed for exact numbers. diff --git a/README.md b/README.md index 6f6c6e3..6d20fdd 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ pip install saturday Python 3.9 or later. One dependency: `httpx`. +## Get a key + +A key comes with any paid Saturday plan, member or coach: sign in at [saturday.fit/api](https://saturday.fit/api) to make yours. It is shown once and emailed to you. A new key covers 10 athletes; to cover more, write to [api@saturday.fit](mailto:api@saturday.fit) about what you're building. Platform partners get keys with their agreement. + ## Quick start Create an athlete with a complete profile, then calculate a session for them. Use an `sk_test_` key while you build. @@ -74,7 +78,7 @@ A calculation carries exact per-hour numbers and totals only when the athlete's - `precision["missing_session_inputs"]` names the session inputs your call left out. Send every session input on every call: `intensity_level`, `thermal_stress_level`, `meal_before_min` and `is_race`. One left out returns ranges even for a complete profile; `precision["onboarding"]` comes only when profile answers are missing. - Per-hour figures are whole numbers, as the Saturday app's Fuel card shows them, which is not always the total divided by the session's hours. Totals are for the whole session. - A zero may be omitted from the response, so read numbers with `.get(field, 0)`. -- A new athlete's first calculation starts a 30-day trial of the full tier: 15 calls on the first day, then 5 a day. `trial_calls_remaining_today` and `trial_ends_at` show where it stands. +- A new athlete's first calculation, product fit or compare starts a trial of the full tier: 15 calls on the first day, then 5 a day, each fit and compare spending one. `trial_calls_remaining_today` and `trial_ends_at` show where it stands, and `client.partner.get()` gives the trial's length in `rate_limits["trial_days"]`. Past a bound the answer is ranges with a flag and a note you can show the athlete: `trial_cap_reached` (today's calls are used), `trial_start_deferred` (your key has started its new trials for the day) or `trial_profile_limit_reached` (the trial covers a set number of distinct profiles), each with `trial_cap_note` or `trial_note`. ## Prep and product fit @@ -133,7 +137,9 @@ with Saturday(api_key="sk_test_...") as client: A stored activity uses `type` and `is_race_event`; a calculation uses `activity_type` and `is_race`. The API refuses the other spelling with a `ValidationError` whose `code` is `unsupported_field`. -When the athlete's profile or the session is missing inputs, prep, product fit and compare plan from the middle of the athlete's ranges and say so in `plan_basis`: its `source` is `profile_incomplete`, `session_incomplete` or both, `missing_profile_fields` and `missing_session_inputs` list what is missing, and `onboarding` comes only when profile answers are. Show `plan_basis["message"]` with the plan. Product answers follow the athlete's Saturday subscription or trial: without one, `tier` is `"teaser"` and the response carries product categories in place of the fit. +When the athlete's profile or the session is missing inputs, prep, product fit and compare plan from the middle of the athlete's ranges and say so in `plan_basis`: its `source` is `profile_incomplete`, `session_incomplete` or both, `missing_profile_fields` and `missing_session_inputs` list what is missing, and `onboarding` comes only when profile answers are. A trial past today's calls plans from ranges too, with `source` `trial_allowance`. Show `plan_basis["message"]` with the plan. Product answers follow the athlete's Saturday subscription or trial: without one, `tier` is `"teaser"` and the response carries product categories in place of the fit. + +`activities.update` with a change to the session (`type`, `legs`, `duration_min`, effort, heat, `is_race_event` or `meal_before_min`) removes the stored prescription: `get_prescription` raises `NotFoundError` (`prescription_not_found`) until you calculate the activity again. A field sent at its stored value changes nothing. ## Bricks and triathlons @@ -184,7 +190,7 @@ with Saturday(api_key="sk_test_...") as client: - A leg's sport is `activity_type` on a calculation and `type` on an activity, as for a single session. - `activities.update` with `legs` replaces them; a brick or triathlon refuses a top-level effort or heat. Changing `type` to a single sport drops the legs. - Prep, product fit and compare answer `legs` too: each leg's share with the products sized against it, as the Saturday app's Prep page for that leg sizes them. Fit and compare also size the whole session at the top level; prep's top level is its legs added up, each product once. A plan from ranges (`plan_basis`) carries no legs. -- `activities.prep` takes `products=`, sized against each leg with its `servings` counting per leg, or `legs=`, one product list per leg in order. Per-leg lists on a single session, or a count other than the activity's legs, raise a `ValidationError` on `legs`. +- `activities.prep` takes `products=`, sized against each leg with its `servings` counting per leg, or `legs=`, one product list per leg in order, never both (a `ValidationError` on `products`). Per-leg lists on a single session, or a count other than the activity's legs, raise a `ValidationError` on `legs`. - `client.reference.activity_types()` lists the rules under `linked_session_types`. ## Resources @@ -200,7 +206,7 @@ with Saturday(api_key="sk_test_...") as client: | `client.partner` | `get`, `usage`, `usage_daily`, `list_api_keys`, `create_api_key`, `revoke_api_key`, `rotate_api_key` | | `client.webhooks` | `create`, `list`, `get`, `update`, `delete`, `test`, `list_deliveries` | | `client.organizations` | `create`, `list`, `get`, `update`, `add_member`, `list_members`, `remove_member`, `set_offer`, `get_offer`, `delete_offer`, `create_subscription`, `list_subscriptions`, `update_subscription`, `add_licenses`, `list_licenses`, `remove_license` | -| `client.integrations` | `sync`, `status`, `disconnect` | +| `client.integrations` | `sync` (intervals.icu), `status`, `disconnect` | | `client.testing` | `simulate_subscription` (test keys only) | | `client.meta` | `discovery`, `errors`, `health` | | `client.knowledge` | `search`, `list_topics`, `get_article` (early access) | @@ -210,20 +216,24 @@ Every method returns the API's JSON as plain dictionaries, typed with the TypedD Every timestamp a partner key receives is an integer of Unix seconds: on athletes, activities, webhooks and their deliveries, API keys, your account, `trial_ends_at`, the fueling profile's `updated_at`, the export's `exported_at` and every time in its records. Coach routes answer in Unix milliseconds. -`athletes.update_settings` replaces the whole settings object: send every setting you want kept. `athletes.delete` removes the athlete and everything stored under them in your account. `athletes.erase` is for a right-to-erasure request: it also ends the athlete's connected-provider grants, erases what those providers sent, and keeps an audit record of the deletion. +`athletes.update_settings` replaces the whole settings object: send every setting you want kept. `athletes.delete` removes the athlete and everything stored under them in your account. `athletes.erase` is for a right-to-erasure request: it first revokes, at the provider, each connection you supplied for the athlete with `integrations.sync`, then deletes the athlete, everything stored under them and their link to a Saturday account. A linked athlete's own Saturday account is not changed. A 503 with code `provider_erasure_incomplete` means nothing was deleted yet: call `erase` again. + +`integrations.sync("intervals_icu", ...)` fetches the activities of the intervals.icu user an access token belongs to, a token your intervals.icu app obtained, and stores them under your athlete; it is the only provider sync takes. Send TrainingPeaks workouts with `activities.import_activities` once the athlete agrees to share them. `integrations.disconnect` ends the connection you supplied and keeps the activities already synced. Nutrition and knowledge sit behind [feature gates](https://docs.saturday.fit/guides/feature-gates) that Saturday opens per partner. Until a gate is open for your key, its routes answer `403` with code `feature_alpha` (`PermissionDeniedError`); ask api@saturday.fit to open one. -## Finding an athlete by your own id +## Your own athlete ids -`athletes.list(external_id=...)` returns the athletes you created with that `external_id`, newest first, in one page. The API does not deduplicate `external_id`, so look an athlete up this way before creating one when a create may have been interrupted. +`external_id` is unique within your account. A create, batch item or update with an `external_id` another of your athletes holds changes nothing and raises `ConflictError` (409, code `athlete_exists`) whose `athlete_id` names that athlete, so a retried create is safe. `athletes.list(external_id=...)` finds the athlete too. ```python -from saturday import Saturday +from saturday import ConflictError, Saturday with Saturday(api_key="sk_live_...") as client: - found = client.athletes.list(external_id="user-42")["athletes"] - athlete = found[0] if found else client.athletes.create(external_id="user-42", name="Sam") + try: + athlete = client.athletes.create(external_id="user-42", name="Sam") + except ConflictError as error: + athlete = client.athletes.get(error.athlete_id) print(athlete["id"]) ``` @@ -257,7 +267,7 @@ with Saturday(api_key="cp_live_...") as client: ## Errors, retries and limits -Every API error is a `SaturdayError` with `status`, `code`, `message`, `param`, `request_id` and `error_type`. Subclasses: `ValidationError` (400, with `suggestion` for a field the request does not take), `AuthenticationError` (401), `PermissionDeniedError` (403), `NotFoundError` (404), `RateLimitError` (429). +Every API error is a `SaturdayError` with `status`, `code`, `message`, `param`, `request_id` and `error_type`. Subclasses: `ValidationError` (400, with `suggestion` for a field the request does not take), `AuthenticationError` (401), `PermissionDeniedError` (403: `feature_alpha`; `plan_inactive` when the paid plan a key comes with has ended; `resource_limit_exceeded` when the key's athletes are at their limit), `NotFoundError` (404), `ConflictError` (409, with `athlete_id`), `RateLimitError` (429). ```python from saturday import RateLimitError, Saturday, ValidationError @@ -288,6 +298,7 @@ A `RateLimitError`'s `code` says which limit was hit: | `intelligence_daily_limit_reached` | Your daily ceiling on calculations, products, inference, knowledge and AI; your athletes, activities and other data keep working | Same | | `athlete_free_daily_limit_reached` | Your daily budget of calculations sent without an `athlete_id` | Same | | `distinct_lookup_daily_limit_reached` | Your daily budget of distinct product lookups; repeat lookups keep working | Same | +| `simulated_subscriber_daily_limit_reached` | Test environment: your key has marked its day's athletes with `testing.simulate_subscription`; athletes already marked keep their simulated subscription | Same | A 5xx is retried after its `Retry-After` (usually 5 seconds) or after 1 s, 2 s and 4 s, up to `max_retries` times, except on a `POST` that creates or changes a record (an athlete, an activity, an import, a webhook), since the server may have done the write; the calculation, product, inference, prep and export `POST`s are retried. The client never sleeps longer than 30 seconds inside one call. `client.partner.get()` shows your limits and `client.partner.usage()` what you have used. @@ -307,7 +318,7 @@ client = Saturday( delegated = Saturday(api_key="sk_live_...", bearer_token="eyJ...") ``` -Partner keys start `sk_live_` or `sk_test_`; coach keys start `cp_live_` or `cp_test_`. A test key reaches the test environment, where `client.testing.simulate_subscription(athlete_id)` gives an athlete the full tier. The client holds a connection pool: use it as a context manager or call `close()`. +Partner keys start `sk_live_` or `sk_test_`; coach keys start `cp_live_` or `cp_test_`. A test key reaches the test environment, where `client.testing.simulate_subscription(athlete_id)` gives an athlete the full tier: by default up to 10 athletes a key a UTC day, each with up to 100 exact answers over 3 distinct profiles, then ranges with `simulated_limit_reached`. The client holds a connection pool: use it as a context manager or call `close()`. ## Athlete profile sharing diff --git a/saturday/__init__.py b/saturday/__init__.py index c560115..5fe6712 100644 --- a/saturday/__init__.py +++ b/saturday/__init__.py @@ -24,6 +24,7 @@ RateLimitError, ValidationError, NotFoundError, + ConflictError, ) from saturday.types import ( Activity, @@ -71,6 +72,8 @@ CreatedApiKey, DailyUsage, DailyUsageResponse, + DiscoveryKeyInfo, + DiscoveryResponse, ErrorCatalogEntry, ErrorCatalogResponse, FuelingConcerns, @@ -90,9 +93,12 @@ HealthResponse, ImportActivityRequest, ImportPrescriptionItem, + IntegrationDisconnectResponse, + IntegrationProvider, IntegrationStatusDetail, IntegrationStatusResponse, IntegrationSyncResponse, + IntegrationSyncResult, LegPrescription, License, LicenseListResponse, @@ -143,6 +149,7 @@ SimulateSubscriptionResponse, StoredPrescriptionResponse, SubscriptionCTA, + SyncProvider, TrialMetadata, UsagePeriod, UsageResponse, @@ -168,6 +175,7 @@ "RateLimitError", "ValidationError", "NotFoundError", + "ConflictError", "Activity", "ActivityFeedback", "ActivityImportResponse", @@ -210,6 +218,8 @@ "CreatedApiKey", "DailyUsage", "DailyUsageResponse", + "DiscoveryKeyInfo", + "DiscoveryResponse", "ErrorCatalogEntry", "ErrorCatalogResponse", "FuelingConcerns", @@ -229,9 +239,12 @@ "HealthResponse", "ImportActivityRequest", "ImportPrescriptionItem", + "IntegrationDisconnectResponse", + "IntegrationProvider", "IntegrationStatusDetail", "IntegrationStatusResponse", "IntegrationSyncResponse", + "IntegrationSyncResult", "License", "LicenseListResponse", "LimitingFactor", @@ -276,6 +289,7 @@ "SimulateSubscriptionResponse", "StoredPrescriptionResponse", "SubscriptionCTA", + "SyncProvider", "TrialMetadata", "UsagePeriod", "UsageResponse", diff --git a/saturday/client.py b/saturday/client.py index 7b85830..7aa5e5a 100644 --- a/saturday/client.py +++ b/saturday/client.py @@ -40,10 +40,12 @@ ConsentRecord, CreatedApiKey, DailyUsageResponse, + DiscoveryResponse, ErrorCatalogResponse, FuelingProfile, HealthResponse, ImportActivityRequest, + IntegrationDisconnectResponse, IntegrationStatusResponse, IntegrationSyncResponse, LicenseListResponse, @@ -268,6 +270,10 @@ def product_fit(self, **request: Any) -> ProductFitResponse: ``meal_before_min`` and ``is_race`` too: one left out computes at its everyday value and the plan is the middle of the athlete's ranges, with ``plan_basis`` naming it. A session error names its field in ``ValidationError.param``. + + For an athlete on the trial, each call spends one of the athlete's trial calls, as + ``calculate`` does; past today's calls the plan is from ranges, with + ``plan_basis["source"]`` ``trial_allowance``. """ return self._client.request("POST", "/v1/nutrition/products/fit", json=request) @@ -275,7 +281,7 @@ def compare_products(self, **request: Any) -> ProductCompareResponse: """Size two products (``product_a``, ``product_b``: each ``{"product_id"}`` or ``{"product_query"}``) and name the better fit. The session fields are ``product_fit``'s; a brick or triathlon with ``legs`` is compared - for each leg under ``legs`` too. + for each leg under ``legs`` too. Spends one trial call, as ``product_fit`` does. """ return self._client.request("POST", "/v1/nutrition/products/compare", json=request) @@ -289,7 +295,12 @@ def __init__(self, client: Saturday): self._client = client def create(self, **athlete: Any) -> Athlete: - """Create an athlete. At least one of ``name``, ``email`` or ``external_id`` is required.""" + """Create an athlete. At least one of ``name``, ``email`` or ``external_id`` is required. + + ``external_id`` is unique within your partner account: one another of your athletes holds + creates nothing and raises ``ConflictError`` (``athlete_exists``) whose ``athlete_id`` names + that athlete, so a retried create is safe. + """ return self._client.request("POST", "/v1/athletes", json=athlete) def get(self, athlete_id: str) -> Athlete: @@ -306,20 +317,21 @@ def list( """One page of athletes. Pass ``pagination["next_cursor"]`` back as ``cursor``. ``external_id`` returns only the athletes you created with that id, newest first, in one - page. The API does not deduplicate ``external_id``, so look an athlete up this way before - creating one when a create may have been interrupted. + page. Athletes created before ``external_id`` became unique may share one. """ return self._client.request("GET", "/v1/athletes", params=_params( limit=limit, cursor=cursor, external_id=external_id, profile_complete=profile_complete, )) def update(self, athlete_id: str, **updates: Any) -> Athlete: - """Update the fields you send. Settings sent here replace the stored settings.""" + """Update the fields you send. Settings sent here replace the stored settings. An + ``external_id`` another of your athletes holds changes nothing and raises ``ConflictError`` + (``athlete_exists``).""" return self._client.request("PATCH", f"/v1/athletes/{_seg(athlete_id)}", json=updates) def delete(self, athlete_id: str) -> None: - """Delete the athlete and everything stored under them in your account. For a data-subject - erasure request use ``erase``.""" + """Delete the athlete and everything stored under them in your account. For a + right-to-erasure request use ``erase``.""" self._client.request("DELETE", f"/v1/athletes/{_seg(athlete_id)}") def get_settings(self, athlete_id: str) -> AthleteSettings: @@ -335,7 +347,9 @@ def get_fueling_profile(self, athlete_id: str) -> FuelingProfile: return self._client.request("GET", f"/v1/athletes/{_seg(athlete_id)}/fueling-profile") def batch_create(self, athletes: List[Dict[str, Any]]) -> BatchAthleteResponse: - """Create up to 100 athletes in one call.""" + """Create up to 100 athletes in one call. An item whose ``external_id`` one of your athletes + holds, an earlier item of the same batch included, fails with ``athlete_exists`` and that + athlete's id in ``errors[i]["athlete_id"]``.""" return self._client.request("POST", "/v1/athletes/batch", json={"athletes": athletes}) def export(self, athlete_id: str) -> AthleteDataExport: @@ -343,9 +357,16 @@ def export(self, athlete_id: str) -> AthleteDataExport: return self._client.request("POST", f"/v1/athletes/{_seg(athlete_id)}/export") def erase(self, athlete_id: str) -> None: - """Erase the athlete for a right-to-erasure request: everything ``delete`` removes, plus - ending the athlete's connected-provider grants and erasing the data those providers sent, - with an audit record of the deletion.""" + """Erase everything Saturday holds for you about the athlete, for a right-to-erasure request. + + Each provider connection you supplied for the athlete with ``integrations.sync`` is revoked + at the provider first; then the athlete and everything stored under them are deleted + (activities, those synced through your connections included, prescriptions, feedback, + consent records, usage logs) with the athlete's link to a Saturday account. A linked + athlete's own Saturday account is not changed. A ``SaturdayError`` with status 503 and code + ``provider_erasure_incomplete`` means a connection could not be revoked yet and nothing was + deleted: call ``erase`` again. + """ self._client.request("POST", f"/v1/athletes/{_seg(athlete_id)}/delete") def list_consent(self, athlete_id: str) -> ConsentListResponse: @@ -387,7 +408,13 @@ def update(self, athlete_id: str, activity_id: str, **updates: Any) -> Activity: ``duration_min`` to their total. Changing ``type`` to brick or triathlon needs ``legs`` in the same call unless the activity holds legs already; changing it to a single sport removes the legs. A brick or triathlon refuses ``intensity_level``, ``thermal_stress_level`` and a - ``duration_min`` other than its legs' total: change its legs instead.""" + ``duration_min`` other than its legs' total: change its legs instead. + + A change to ``type``, ``legs``, ``duration_min``, ``intensity_level``, + ``thermal_stress_level``, ``is_race_event`` or ``meal_before_min`` removes the stored + prescription: ``get_prescription`` raises ``NotFoundError`` (``prescription_not_found``) until + you calculate the activity again. A field sent at its stored value changes nothing, and + ``external_id`` alone keeps the prescription.""" return self._client.request("PATCH", f"/v1/athletes/{_seg(athlete_id)}/activities/{_seg(activity_id)}", json=updates) def delete(self, athlete_id: str, activity_id: str) -> None: @@ -398,7 +425,9 @@ def calculate_prescription(self, athlete_id: str, activity_id: str) -> Prescript return self._client.request("POST", f"/v1/athletes/{_seg(athlete_id)}/activities/{_seg(activity_id)}/calculate") def get_prescription(self, athlete_id: str, activity_id: str) -> StoredPrescriptionResponse: - """The stored prescription. ``NotFoundError`` until the activity has been calculated.""" + """The prescription calculated for the activity's session as it stands. ``NotFoundError`` + (``prescription_not_found``) until the activity has been calculated, and again after an + ``update`` that changes the session, until it is calculated again.""" return self._client.request("GET", f"/v1/athletes/{_seg(athlete_id)}/activities/{_seg(activity_id)}/prescription") def prep( @@ -418,8 +447,8 @@ def prep( A brick or triathlon with exact numbers is prepped leg by leg under ``legs``: ``products`` is sized against each leg, its ``servings`` counting per leg, or send ``legs``, one ``{"products": [...]}`` per leg of the activity in order, for a list per leg. Send one or - the other. ``legs`` on a single session, or with another count, raises ``ValidationError`` - with ``param`` ``legs``. + the other: both raise ``ValidationError`` (``invalid_value`` on ``products``). ``legs`` on a + single session, or with another count, raises ``ValidationError`` with ``param`` ``legs``. """ body: Dict[str, Any] = {"legs": legs} if legs is not None else {} if products is not None or legs is None: @@ -491,7 +520,7 @@ def __init__(self, client: Saturday): self._client = client def get(self) -> PartnerAccount: - """Your account and its limits.""" + """Your account and its limits, the trial's length and bounds included (``rate_limits``).""" return self._client.request("GET", "/v1/partner") def usage(self, *, from_date: Optional[str] = None, to_date: Optional[str] = None) -> UsageResponse: @@ -632,20 +661,38 @@ class _IntegrationsResource: def __init__(self, client: Saturday): self._client = client - def sync(self, provider: str, *, athlete_id: str, access_token: str, **options: Any) -> IntegrationSyncResponse: - """Pull the athlete's activities from the provider (``strava``) into Saturday. - - Options: ``refresh_token``, ``sync_types``, ``date_range`` (``{"from", "to"}``). + def sync( + self, + provider: str, + *, + athlete_id: str, + access_token: str, + date_range: Optional[Dict[str, str]] = None, + sync_types: Optional[List[str]] = None, + ) -> IntegrationSyncResponse: + """Fetch the activities of the intervals.icu user an access token belongs to and store each + as an activity of your athlete. + + ``provider`` is ``"intervals_icu"``, the only one: Strava and TrainingPeaks tokens raise + ``ValidationError`` (``invalid_provider``). Send an OAuth access token your intervals.icu app + obtained from that user; the calls count against your app's intervals.icu limit. + ``date_range`` is ``{"start": "YYYY-MM-DD", "end": "YYYY-MM-DD"}``, both or neither; without + it, the last 7 days. ``sync_types`` defaults to ``["activities"]``. The result is under + ``result``. """ - return self._client.request( - "POST", f"/v1/integrations/{_seg(provider)}/sync", - json={"athlete_id": athlete_id, "access_token": access_token, **options}, - ) + body: Dict[str, Any] = {"athlete_id": athlete_id, "access_token": access_token, "sync_types": sync_types or ["activities"]} + if date_range is not None: + body["date_range"] = date_range + return self._client.request("POST", f"/v1/integrations/{_seg(provider)}/sync", json=body) def status(self, provider: str, athlete_id: str) -> IntegrationStatusResponse: + """``provider``: ``intervals_icu``, ``strava`` or ``training_peaks``.""" return self._client.request("GET", f"/v1/integrations/{_seg(provider)}/status", params={"athlete_id": athlete_id}) - def disconnect(self, provider: str, athlete_id: str) -> Dict[str, Any]: + def disconnect(self, provider: str, athlete_id: str) -> IntegrationDisconnectResponse: + """End the connection you supplied for the athlete with ``sync``: it is revoked at the + provider and its tokens are removed. Activities already synced stay. A linked athlete's own + connection to the provider in their Saturday account is not changed.""" return self._client.request("POST", f"/v1/integrations/{_seg(provider)}/disconnect", json={"athlete_id": athlete_id}) @@ -656,7 +703,14 @@ def __init__(self, client: Saturday): self._client = client def simulate_subscription(self, athlete_id: str, *, active: bool = True) -> SimulateSubscriptionResponse: - """Give the athlete a simulated Saturday subscription (``active=True``) or take it away.""" + """Give the athlete a simulated Saturday subscription (``active=True``) or take it away. + + A key marks at most 10 athletes a UTC day (marking one already marked today again is free); + past that it raises ``RateLimitError`` with code ``simulated_subscriber_daily_limit_reached`` + and ``resets_at``. Each simulated subscriber gets up to 100 exact answers over 3 distinct + profiles; past either, answers are ranges with ``simulated_limit_reached``. These are the + API's defaults. + """ return self._client.request( "POST", f"/v1/test/athletes/{_seg(athlete_id)}/simulate-subscription", json={"active": active} ) @@ -666,8 +720,8 @@ class _MetaResource: def __init__(self, client: Saturday): self._client = client - def discovery(self) -> Dict[str, Any]: - """The routes and features this key can see.""" + def discovery(self) -> DiscoveryResponse: + """The routes and features this key can see, and how a key is had (``get_a_key``).""" return self._client.request("GET", "/v1/") def errors(self) -> ErrorCatalogResponse: diff --git a/saturday/errors.py b/saturday/errors.py index eed0b86..7de542c 100644 --- a/saturday/errors.py +++ b/saturday/errors.py @@ -1,6 +1,6 @@ """ Typed errors. Every API error carries ``status``, ``code``, ``message``, ``error_type`` and, -when the API sets them, ``param`` and ``request_id``. +when the API sets them, ``param``, ``request_id`` and (for ``athlete_exists``) ``athlete_id``. """ from __future__ import annotations @@ -9,12 +9,15 @@ from datetime import datetime, timedelta, timezone from typing import Any, Dict, Optional -# The 429 codes that reset at UTC midnight. Nothing succeeds before then. +# The 429 codes that reset at UTC midnight. Nothing they refuse succeeds before then. +# simulated_subscriber_daily_limit_reached is the test environment's: the key has marked its day's +# allowance of athletes with testing.simulate_subscription. DAILY_LIMIT_CODES = ( "daily_call_limit_reached", "intelligence_daily_limit_reached", "athlete_free_daily_limit_reached", "distinct_lookup_daily_limit_reached", + "simulated_subscriber_daily_limit_reached", ) # The longest wait the client sleeps through inside one call, in seconds. @@ -33,6 +36,7 @@ def __init__( param: Optional[str] = None, request_id: Optional[str] = None, retry_after: Optional[float] = None, + athlete_id: Optional[str] = None, ): super().__init__(message) self.message = message @@ -41,6 +45,8 @@ def __init__( self.code = code self.param = param self.request_id = request_id + # For athlete_exists (409): the athlete that holds the external_id you sent. + self.athlete_id = athlete_id # Seconds to wait, from the Retry-After header, when the response carried one (429s and 503s). self.retry_after = retry_after @@ -55,6 +61,7 @@ def from_response(cls, status: int, error_body: Dict[str, Any], retry_after: Opt "code": detail.get("code", "unknown"), "param": detail.get("param"), "request_id": detail.get("request_id"), + "athlete_id": detail.get("athlete_id"), } seconds: Optional[float] = None if retry_after is not None: @@ -72,6 +79,8 @@ def from_response(cls, status: int, error_body: Dict[str, Any], retry_after: Opt return PermissionDeniedError(**kwargs) if status == 404: return NotFoundError(**kwargs) + if status == 409: + return ConflictError(**kwargs) if status == 429: return RateLimitError(**kwargs, retry_after=seconds) return cls(**kwargs, retry_after=seconds) @@ -82,7 +91,11 @@ class AuthenticationError(SaturdayError): class PermissionDeniedError(SaturdayError): - """403: the key cannot use this feature or resource (for example ``feature_alpha``).""" + """403: the key cannot use this feature or resource. Read ``code``: ``feature_alpha`` (a feature + not yet open to your key), ``plan_inactive`` (the paid Saturday plan this key comes with has + ended; the key works again, with its athletes, once the plan is active), + ``resource_limit_exceeded`` (the key's athletes are at their limit; write to api@saturday.fit + to raise it).""" class RateLimitError(SaturdayError): @@ -93,12 +106,14 @@ class RateLimitError(SaturdayError): The client retries a wait of 30 seconds or less; a longer one is raised to you. - ``rate_limited``: an unusual request pattern; calculations are blocked for ``retry_after`` seconds. - ``daily_call_limit_reached``, ``intelligence_daily_limit_reached``, - ``athlete_free_daily_limit_reached``, ``distinct_lookup_daily_limit_reached``: a daily - ceiling. ``daily_limit`` is True and ``resets_at`` is the UTC midnight it resets at. Never retried. + ``athlete_free_daily_limit_reached``, ``distinct_lookup_daily_limit_reached``, and on the + test environment ``simulated_subscriber_daily_limit_reached``: a daily ceiling. + ``daily_limit`` is True and ``resets_at`` is the UTC midnight it resets at. Never retried. """ def __init__(self, *args: Any, retry_after: Optional[float] = None, now: Optional[datetime] = None, **kwargs: Any): - super().__init__(*args, retry_after=retry_after, **kwargs) + kwargs["retry_after"] = retry_after + super().__init__(*args, **kwargs) # An API that predates the daily codes marks a daily ceiling by sending no Retry-After. self.daily_limit = self.code in DAILY_LIMIT_CODES or retry_after is None self.resets_at: Optional[datetime] = None @@ -136,3 +151,9 @@ def _suggested_field(message: str) -> Optional[str]: class NotFoundError(SaturdayError): """404: no such resource for this key, or a route this key cannot see.""" + + +class ConflictError(SaturdayError): + """409: the request conflicts with a record you hold. For ``athlete_exists``, another of your + athletes holds the ``external_id`` you sent: nothing was created or changed, and + ``athlete_id`` names that athlete.""" diff --git a/saturday/types.py b/saturday/types.py index 29da2e0..c141ae9 100644 --- a/saturday/types.py +++ b/saturday/types.py @@ -14,10 +14,20 @@ SessionInput = Literal["intensity_level", "thermal_stress_level", "meal_before_min", "is_race"] """A session input a plan from ranges can be missing.""" -PlanBasisSource = Literal["profile_incomplete", "session_incomplete", "profile_and_session_incomplete", "stored_ranges"] -"""What a plan from ranges is missing: the athlete's profile answers, the session's inputs, or -both. ``stored_ranges`` is an activity's stored ranges with nothing missing that can be named now -(the athlete has answered since): calculate the activity again.""" +PlanBasisSource = Literal[ + "profile_incomplete", + "session_incomplete", + "profile_and_session_incomplete", + "stored_ranges", + "trial_allowance", + "simulation_allowance", +] +"""Why a plan is from ranges: the athlete's profile answers are missing, the session's inputs are, +or both. ``stored_ranges`` is an activity's stored ranges with nothing missing that can be named now +(the athlete has answered since): calculate the activity again. ``trial_allowance``: the athlete's +trial has used today's calls, or this profile is past the trial's allowance of profiles; +``message`` says which, in words you can show the athlete. ``simulation_allowance`` (test +environment only): the athlete's simulated subscription has given its allowance.""" class SafetyMetadata(TypedDict): @@ -125,11 +135,29 @@ class ActivityLeg(TypedDict): class TrialMetadata(TypedDict, total=False): + """Trial and sandbox fields on a calculation. The trial's length is ``rate_limits.trial_days`` + on ``partner.get()``.""" + tier_source: str trial_ends_at: int # When the trial ends, Unix seconds. trial_calls_remaining_today: int + # The athlete's trial has used today's calls, so these numbers are ranges; trial_cap_note says so. trial_cap_reached: bool trial_cap_note: str + # Your key has started its new trials for the UTC day (rate_limits.trial_starts_per_day), so + # this athlete's trial starts on a later day and these numbers are ranges. + trial_start_deferred: bool + # The athlete's trial already covers its allowance of distinct profiles + # (rate_limits.trial_profiles_per_athlete), so this new one is answered in ranges. Earlier + # profiles stay exact. + trial_profile_limit_reached: bool + # With trial_start_deferred or trial_profile_limit_reached, why these numbers are ranges, in + # words you can show the athlete. + trial_note: str + # Test environment only: the athlete's simulated subscription has given its allowance of exact + # answers or distinct profiles, so these numbers are ranges. + simulated_limit_reached: bool + simulation_note: str # With simulated_limit_reached, which allowance was reached. class _CalculationRequired(TypedDict): @@ -392,12 +420,16 @@ class ActivityListResponse(TypedDict): request_id: str -class BatchError(TypedDict): +class _BatchErrorRequired(TypedDict): index: int code: str message: str +class BatchError(_BatchErrorRequired, total=False): + athlete_id: str # For athlete_exists: the athlete that holds the item's external_id. + + class _BatchSummaryRequired(TypedDict): total: int succeeded: int @@ -830,7 +862,7 @@ class ProductFitDetail(TypedDict): class _PlanBasisRequired(TypedDict): source: PlanBasisSource - message: str # Names what is missing and where each goes. Show it with the plan. + message: str # Names what is missing and where each goes, or which allowance was reached. Show it with the plan. carb_range_g_per_hr: str sodium_range_mg_per_hr: str fluid_range_ml_per_hr: str @@ -838,7 +870,8 @@ class _PlanBasisRequired(TypedDict): class PlanBasis(_PlanBasisRequired, total=False): """Present when a plan uses the middle of the per-hour ranges for the session because the - athlete's profile or the session is missing inputs. With every input in, it is absent.""" + athlete's profile or the session is missing inputs, or a trial or simulated subscription is past + its allowance (``source``). With every input in and the athlete's access open, it is absent.""" # The athlete's profile answers the plan lacks, by the names precision.missing_fields uses. missing_profile_fields: List[str] @@ -883,6 +916,10 @@ class ProductFitResponse(_ProductAnswerRequired, total=False): categories: List[ProductCategory] cta: SubscriptionCTA request_id: str + # Teaser tier only: your key has started its new trials for the UTC day, so this athlete's + # trial starts on a later day. trial_note says why, in words you can show the athlete. + trial_start_deferred: bool + trial_note: str ProductChoice = Literal["product_a", "product_b"] @@ -921,6 +958,8 @@ class ProductCompareResponse(_ProductAnswerRequired, total=False): categories: List[ProductCategory] cta: SubscriptionCTA request_id: str + trial_start_deferred: bool # Teaser tier only, as on product fit. + trial_note: str class PrepProduct(TypedDict): @@ -1077,6 +1116,43 @@ class OnboardingQuestionsResponse(TypedDict): request_id: str +class _DiscoveryKeyInfoRequired(TypedDict): + how: str + page: str # https://saturday.fit/api + athletes_per_key: int + more_athletes: str # How to ask for more athletes. + contact: str # api@saturday.fit + + +class DiscoveryKeyInfo(_DiscoveryKeyInfoRequired, total=False): + """How a key is had, in plain text values: a key comes with any paid Saturday plan and is made + by the signed-in account at saturday.fit/api; it covers athletes_per_key athletes until + Saturday raises it.""" + + # The account routes that page calls. They take a signed-in Saturday account, not an API key, + # so the SDK does not call them. + account_routes: str + trial: str + limits: str + platforms: str + docs: str + quickstart: str + llms_txt: str + who_is_this: str + + +class DiscoveryResponse(TypedDict): + """``GET /v1/``: the routes and features this key can see, and how a key is had.""" + + name: str + version: str + # Resource names to paths. A feature short of general availability carries its stage in its + # name ("nutrition (alpha)"); a hidden feature is absent. + links: Dict[str, str] + get_a_key: DiscoveryKeyInfo + request_id: str + + class ErrorCatalogEntry(TypedDict): code: str type: str @@ -1107,6 +1183,13 @@ class PartnerRateLimits(TypedDict): requests_per_minute: int requests_per_day: Optional[int] # All calls a day; None when no daily ceiling applies. ip_requests_per_day: Optional[int] # Calculation calls a day; None when none applies. + # New athlete trials this key may start per UTC day; an athlete past it gets ranges with + # trial_start_deferred. None when the key has no such bound. + trial_starts_per_day: Optional[int] + # Distinct profiles one trial athlete's exact numbers cover over the trial; a further one gets + # ranges with trial_profile_limit_reached. None when the key has no such bound. + trial_profiles_per_athlete: Optional[int] + trial_days: int # Days an athlete's trial lasts from its first exact answer. class PartnerAccount(TypedDict): @@ -1114,6 +1197,7 @@ class PartnerAccount(TypedDict): name: str contact_email: str status: Literal["active", "suspended"] + # partner for a platform partner, individual for a key that comes with a Saturday account's paid plan. plan: Literal["partner", "individual"] rate_limits: PartnerRateLimits created_at: int # Unix seconds. @@ -1397,8 +1481,16 @@ class AthleteDataExport(_AthleteDataExportRequired, total=False): # --- Integrations and the test project --- +IntegrationProvider = Literal["intervals_icu", "strava", "training_peaks"] +"""The providers ``integrations.status`` and ``integrations.disconnect`` take.""" + +SyncProvider = Literal["intervals_icu"] +"""The provider ``integrations.sync`` takes. Strava and TrainingPeaks tokens are refused with a +``ValidationError`` (``invalid_provider``).""" + + class _IntegrationStatusDetailRequired(TypedDict): - provider: str + provider: IntegrationProvider connected: bool sync_count: int @@ -1413,17 +1505,32 @@ class IntegrationStatusResponse(TypedDict): request_id: str -class _IntegrationSyncRequired(TypedDict): - provider: str - status: Literal["completed", "partial", "failed", "not_configured"] +class _IntegrationSyncResultRequired(TypedDict): + provider: SyncProvider + # partial when some activities could not be stored, failed when none could or intervals.icu + # refused the token; errors says why. + status: Literal["completed", "partial", "failed"] activities_found: int activities_synced: int - activities_skipped: int + activities_skipped: int # Found but not stored: the activity's type names no sport the API supports. -class IntegrationSyncResponse(_IntegrationSyncRequired, total=False): +class IntegrationSyncResult(_IntegrationSyncResultRequired, total=False): + # Whether the athlete's prescriptions for these activities are exact (full) or ranges (teaser). prescription_tier: Literal["full", "teaser"] errors: List[str] + + +class IntegrationSyncResponse(TypedDict): + result: IntegrationSyncResult + request_id: str + + +class IntegrationDisconnectResponse(TypedDict): + """The connection you supplied is ended.""" + + message: str # For example "Successfully disconnected intervals_icu". + provider: IntegrationProvider request_id: str diff --git a/tests/LIVE.md b/tests/LIVE.md index fdacdde..2372305 100644 --- a/tests/LIVE.md +++ b/tests/LIVE.md @@ -9,8 +9,9 @@ python -m pytest tests/test_live.py ``` - The key must be a test key (`sk_test_`); the suite refuses a live key. -- One run makes about 115 calls, of which about 45 are calculations, prep, product fit and compare, and creates 4 athletes (one of them with a simulated subscription, for the brick and triathlon block), 4 activities, an organization, an API key and a webhook pointed at `https://example.com`. The webhook receives two deliveries, a `webhook.test` and a `prescription.calculated`; example.com answers 405, and the suite reads each event body from its delivery record. It erases the athletes, with their activities, and deletes the key and webhook it created; the organization stays. +- One run makes about 130 calls, of which about 45 are calculations, prep, product fit and compare, and creates 4 athletes (one of them with a simulated subscription, for the brick and triathlon block), 4 activities, an organization, an API key and a webhook pointed at `https://example.com`. The webhook receives two deliveries, a `webhook.test` and a `prescription.calculated`; example.com answers 405, and the suite reads each event body from its delivery record. It erases the athletes, with their activities, and deletes the key and webhook it created; the organization stays. - The catalog products it sizes are Maurten Gel 100 and Tailwind Endurance Fuel. -- `athletes.erase` and `testing.simulate_subscription` need the test environment. +- `athletes.erase` and `testing.simulate_subscription` need the test environment. The run marks 2 athletes with `testing.simulate_subscription`, inside the 10 a key may mark per UTC day. +- It also checks what the API refuses: a second athlete with a taken `external_id` (create, batch item and update), a Strava or TrainingPeaks token on `integrations.sync`, prep with both `products=` and `legs=`, and the stored prescription after an update that changes the session. Set `SATURDAY_LIVE_CAPTURE=tests/fixtures/live.json` to record every response. Keys, secrets, signed links and account details are replaced with placeholders before they are written. `tests/test_live_types.py`, part of the normal test run, checks every recorded response against the TypedDict its method returns: every required key, no undeclared key, every value of its declared type, so a field the API adds, drops or renames fails the suite until the types match. diff --git a/tests/fixtures/contracts.json b/tests/fixtures/contracts.json index 68a8edc..8ec593a 100644 --- a/tests/fixtures/contracts.json +++ b/tests/fixtures/contracts.json @@ -1,6 +1,6 @@ { "_meta": { - "backend_sha": "66538f7d5f608418e34895defb740e442dd8691a", + "backend_sha": "f51d10337444de95cfc94e2155442635976f61f2", "source": "pkg/api Go JSON types, stored-prescription/list/settings HTTP handlers, the coach billing structs in pkg/purchase, pkg/connect and pkg/coachbilling, and the profile-sharing types in pkg/api, pkg/partner and pkg/webhook; synthetic values, no API calls" }, "activity": { @@ -23,12 +23,6 @@ "updated_at": 1700000000 }, "activity_banded": { - "total_carb_g": 0, - "total_sodium_mg": 0, - "total_fluid_ml": 0, - "carb_g_per_hr": 0, - "sodium_mg_per_hr": 0, - "fluid_ml_per_hr": 0, "calculated_at": 1700000000, "profile_complete": false, "carb_range_g_per_hr": "50-70", @@ -60,7 +54,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -73,12 +67,6 @@ "activity_full_banded": { "tier": "full", "prescription": { - "total_carb_g": 0, - "total_sodium_mg": 0, - "total_fluid_ml": 0, - "carb_g_per_hr": 0, - "sodium_mg_per_hr": 0, - "fluid_ml_per_hr": 0, "calculated_at": 1700000000, "profile_complete": false, "carb_range_g_per_hr": "50-70", @@ -90,7 +78,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -128,7 +116,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -182,7 +170,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -293,7 +281,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -313,7 +301,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -788,12 +776,6 @@ "result": { "tier": "full", "prescription": { - "total_carb_g": 0, - "total_sodium_mg": 0, - "total_fluid_ml": 0, - "carb_g_per_hr": 0, - "sodium_mg_per_hr": 0, - "fluid_ml_per_hr": 0, "calculated_at": 1700000000, "profile_complete": false, "carb_range_g_per_hr": "50-70", @@ -805,7 +787,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -937,7 +919,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -975,7 +957,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -1011,7 +993,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -1031,7 +1013,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -1081,7 +1063,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -1101,7 +1083,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true }, "attribution": { @@ -1136,12 +1118,6 @@ }, "stored_banded": { "prescription": { - "total_carb_g": 0, - "total_sodium_mg": 0, - "total_fluid_ml": 0, - "carb_g_per_hr": 0, - "sodium_mg_per_hr": 0, - "fluid_ml_per_hr": 0, "calculated_at": 1700000000, "profile_complete": false, "carb_range_g_per_hr": "50-70", @@ -1153,7 +1129,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true } }, @@ -1172,7 +1148,7 @@ "max_safe_sodium_mg_per_hr": 3000, "confidence_score": 0, "requires_human_review": false, - "warnings": null, + "warnings": [], "not_instructions": true } }, diff --git a/tests/fixtures/live.json b/tests/fixtures/live.json index 4dc5835..a448574 100644 --- a/tests/fixtures/live.json +++ b/tests/fixtures/live.json @@ -1,7 +1,22 @@ { "discovery": { - "type": "Dict", + "type": "DiscoveryResponse", "body": { + "get_a_key": { + "account_routes": "GET and POST /v1/account/api-key with the signed-in account's Firebase ID token (what saturday.fit/api calls)", + "athletes_per_key": 10, + "contact": "api@saturday.fit", + "docs": "https://docs.saturday.fit", + "how": "A key comes with any paid Saturday plan, member or coach. Sign in at saturday.fit/api to make yours.", + "limits": "2 requests a second, 200 calls a day", + "llms_txt": "https://saturday.fit/llms.txt", + "more_athletes": "To cover more than 10 athletes, write to api@saturday.fit about what you're building and we'll raise it.", + "page": "https://saturday.fit/api", + "platforms": "Building Saturday into a platform for many athletes? Write to api@saturday.fit about a partnership.", + "quickstart": "https://docs.saturday.fit/quickstart", + "trial": "Each athlete gets 30 days of exact numbers; after that, exact numbers come with the athlete's Saturday subscription.", + "who_is_this": "Builders whose athletes live in their own system. Coaching athletes who use the Saturday app? The coach portal is your lane, and its API keys come with every paid coach plan: https://coach.saturday.fit" + }, "links": { "activity_types": "/v1/activity-types", "athletes": "/v1/athletes", @@ -14,21 +29,7 @@ "settings_schema": "/v1/settings/schema" }, "name": "Saturday API", - "request_id": "req_0cf909dfb5ab", - "self_serve": { - "docs": "https://docs.saturday.fit", - "key_claim": "GET /v1/signup/claim?session_id=\u2026 (one-time reveal after checkout; also emailed)", - "key_resend": "POST /v1/signup/resend {\"session_id\": \"cs_\u2026\"} \u2192 rotates + re-emails your key if it never arrived", - "limits": "2 req/s, 200 calls/day (higher limits: api@saturday.fit)", - "llms_txt": "https://saturday.fit/llms.txt", - "plan": "individual_monthly", - "price": "$5.39/month", - "quickstart": "https://docs.saturday.fit/quickstart", - "signup_api": "POST /v1/signup {\"email\": \"you@example.com\"} \u2192 hosted checkout URL", - "signup_web": "https://saturday.fit/api", - "trial": "Every athlete's first calculate starts a 30-day full-precision trial: 15 calls on day one, then 5/day.", - "who_is_this": "Builders whose athletes live in THEIR system. Coaching real Saturday-app athletes? The coach portal is your lane, and its API keys come with the Business and Enterprise plans: https://coach.saturday.fit" - }, + "request_id": "req_34b82d631709", "version": "1.0.0" } }, @@ -60,6 +61,14 @@ "retryable": false, "documentation_url": "https://docs.saturday.fit/authentication" }, + { + "code": "invalid_token", + "type": "authentication_error", + "http_status": 401, + "message": "The account routes behind saturday.fit/api got no Saturday sign-in, or one that is invalid, expired or revoked. Sign in again.", + "retryable": false, + "documentation_url": "https://docs.saturday.fit/authentication" + }, { "code": "insufficient_scope", "type": "authorization_error", @@ -173,10 +182,26 @@ "documentation_url": "https://docs.saturday.fit/error-handling" }, { - "code": "sandbox_signup_closed", + "code": "plan_inactive", + "type": "authorization_error", + "http_status": 403, + "message": "The key comes with a paid Saturday plan, and the plan on its account has ended. The key works again, with its athletes as they were, once the plan is active.", + "retryable": false, + "documentation_url": "https://docs.saturday.fit/authentication" + }, + { + "code": "paid_plan_required", + "type": "authorization_error", + "http_status": 403, + "message": "A Saturday API key comes with any paid Saturday plan, and the signed-in account has none now.", + "retryable": false, + "documentation_url": "https://docs.saturday.fit/authentication" + }, + { + "code": "sandbox_key_by_saturday", "type": "authorization_error", "http_status": 403, - "message": "Sandbox keys are issued by Saturday; self-serve signup on the sandbox takes Saturday's own addresses only.", + "message": "Keys on the sandbox go only to Saturday's own addresses; write to api@saturday.fit for one.", "retryable": false, "documentation_url": "https://docs.saturday.fit/authentication" }, @@ -264,7 +289,7 @@ "code": "invalid_provider", "type": "invalid_request", "http_status": 400, - "message": "The integration provider is not one of strava, training_peaks, intervals_icu.", + "message": "The integration provider is not supported on this route: sync takes intervals_icu; status and disconnect take strava, training_peaks and intervals_icu. message says which.", "retryable": false, "documentation_url": "https://docs.saturday.fit/error-handling" }, @@ -292,6 +317,14 @@ "retryable": false, "documentation_url": "https://docs.saturday.fit/guides/organizations" }, + { + "code": "athlete_exists", + "type": "invalid_request", + "http_status": 409, + "message": "An athlete with this external_id already exists, so nothing was created; athlete_id names it.", + "retryable": false, + "documentation_url": "https://docs.saturday.fit/guides/athletes" + }, { "code": "already_revoked", "type": "invalid_request", @@ -317,18 +350,18 @@ "documentation_url": "https://docs.saturday.fit/guides/activities" }, { - "code": "claim_used", + "code": "key_exists", "type": "invalid_request", - "http_status": 410, - "message": "This claim link was used and cannot be used again.", + "http_status": 409, + "message": "The signed-in account has a working key. Send replace: true to make a new one; the current key then stops working.", "retryable": false, - "documentation_url": "https://docs.saturday.fit/error-handling" + "documentation_url": "https://docs.saturday.fit/authentication" }, { - "code": "sandbox_key_by_email", + "code": "key_comes_with_plan", "type": "invalid_request", "http_status": 410, - "message": "On the sandbox a key is sent only by email, to the address it was bought with; the success page does not show it.", + "message": "Keys are not bought. A key comes with any paid Saturday plan; sign in at saturday.fit/api to make yours.", "retryable": false, "documentation_url": "https://docs.saturday.fit/authentication" }, @@ -388,6 +421,14 @@ "retryable": true, "documentation_url": "https://docs.saturday.fit/rate-limiting" }, + { + "code": "simulated_subscriber_daily_limit_reached", + "type": "rate_limit_error", + "http_status": 429, + "message": "On the sandbox, the key has marked its day's allowance of athletes as subscribed with simulate-subscription; athletes already marked keep their simulated subscription. It resets at midnight UTC; Retry-After is the seconds until then.", + "retryable": true, + "documentation_url": "https://docs.saturday.fit/guides/freemium-model" + }, { "code": "resource_not_found", "type": "not_found_error", @@ -516,14 +557,6 @@ "retryable": true, "documentation_url": "https://docs.saturday.fit/error-handling" }, - { - "code": "payment_error", - "type": "api_error", - "http_status": 500, - "message": "The payment provider could not complete the request. Retry.", - "retryable": true, - "documentation_url": "https://docs.saturday.fit/error-handling" - }, { "code": "key_generation_error", "type": "api_error", @@ -540,14 +573,6 @@ "retryable": true, "documentation_url": "https://docs.saturday.fit/authentication" }, - { - "code": "resend_error", - "type": "api_error", - "http_status": 500, - "message": "The key email could not be sent. Retry.", - "retryable": true, - "documentation_url": "https://docs.saturday.fit/authentication" - }, { "code": "sync_error", "type": "api_error", @@ -584,7 +609,7 @@ "code": "provider_erasure_incomplete", "type": "api_error", "http_status": 503, - "message": "The athlete's connected-app data could not be erased yet, so nothing was erased. Retry the delete.", + "message": "A provider connection you supplied for the athlete could not be revoked yet, so nothing was deleted. Retry the delete.", "retryable": true, "documentation_url": "https://docs.saturday.fit/guides/athletes" }, @@ -661,15 +686,15 @@ "documentation_url": "https://docs.saturday.fit/error-handling" } ], - "request_id": "req_61bdbe84b22b", - "total": 78 + "request_id": "req_f0875373aac2", + "total": 81 } }, "health": { "type": "HealthResponse", "body": { "status": "ok", - "timestamp": "2026-11-18T08:59:08Z", + "timestamp": "2026-11-19T17:03:39Z", "version": "1.0.0" } }, @@ -751,7 +776,7 @@ "max_duration_min": 2160 } ], - "request_id": "req_9805bca6c49e", + "request_id": "req_4ab607025fa7", "total": 7 } }, @@ -779,14 +804,14 @@ "max_duration_min": 2160 } ], - "request_id": "req_65ac0a888f10", + "request_id": "req_659d051250e9", "total": 0 } }, "settings_schema": { "type": "SettingsSchemaResponse", "body": { - "request_id": "req_d9e1b9f67d63", + "request_id": "req_3ac162947219", "settings": [ { "field": "sweat_level", @@ -1185,16 +1210,16 @@ ] } ], - "request_id": "req_87c7b6eebb7d", + "request_id": "req_9cdfea5cc1fa", "schema_version": "2026-06-12.1" } }, "athlete": { "type": "Athlete", "body": { - "id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", - "external_id": "sdk-python-19eb20f2-a", + "external_id": "sdk-python-88490c48-a", "sex": "female", "year_of_birth": 1990, "weight_kg": 62, @@ -1208,8 +1233,8 @@ "performance": true, "concerns_answered": true }, - "created_at": 1794992348, - "updated_at": 1794992348, + "created_at": 1795107820, + "updated_at": 1795107820, "profile_complete": true } }, @@ -1218,9 +1243,9 @@ "body": { "athletes": [ { - "id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", - "external_id": "sdk-python-19eb20f2-a", + "external_id": "sdk-python-88490c48-a", "sex": "female", "year_of_birth": 1990, "weight_kg": 62, @@ -1234,8 +1259,8 @@ "performance": true, "concerns_answered": true }, - "created_at": 1794992348, - "updated_at": 1794992348, + "created_at": 1795107820, + "updated_at": 1795107820, "profile_complete": true } ], @@ -1243,14 +1268,14 @@ "total": 1, "has_more": false }, - "request_id": "req_213f9966a9de" + "request_id": "req_5e1224b09c0d" } }, "fueling_profile": { "type": "FuelingProfile", "body": { "object": "fueling_profile", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "sharing": "not_linked", "message": "This athlete has not connected a Saturday account, so there are no Saturday app answers to share." } @@ -1260,12 +1285,12 @@ "body": { "created": [ { - "id": "e099db1c-9c28-434c-ba40-68949f5f0459", + "id": "e37b1955-1a15-41a7-9c64-5953fd7bbacd", "partner_id": "partner_example", - "external_id": "sdk-python-19eb20f2-c", + "external_id": "sdk-python-88490c48-c", "settings": {}, - "created_at": 1794992350, - "updated_at": 1794992350, + "created_at": 1795107820, + "updated_at": 1795107820, "profile_complete": false } ], @@ -1274,12 +1299,18 @@ "index": 1, "code": "missing_identifier", "message": "At least one of name, email, or external_id is required" + }, + { + "index": 2, + "code": "athlete_exists", + "message": "An athlete with external_id \"sdk-python-88490c48-a\" already exists: 6dda898d-6c1c-45d8-87d5-34dcb861fb12. Nothing was created.", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12" } ], - "total": 2, + "total": 3, "succeeded": 1, - "failed": 1, - "request_id": "req_1906f70d75e1" + "failed": 2, + "request_id": "req_7eebba3a04f1" } }, "calculate_exact": { @@ -1310,7 +1341,7 @@ "profile_complete": true }, "tier_source": "trial", - "trial_ends_at": 1797584352, + "trial_ends_at": 1797699820, "trial_calls_remaining_today": 14 } }, @@ -1447,7 +1478,7 @@ } }, "tier_source": "trial", - "trial_ends_at": 1797584359, + "trial_ends_at": 1797699827, "trial_calls_remaining_today": 14 } }, @@ -1681,7 +1712,7 @@ "profile_complete": true }, "tier_source": "trial", - "trial_ends_at": 1797584352, + "trial_ends_at": 1797699820, "trial_calls_remaining_today": 10 } ], @@ -1689,22 +1720,22 @@ { "index": 1, "code": "invalid_value", - "message": "activity_type must be one of: bike, run, swim, row, ski, lift, hike (got \"nope\"). To map another sport name, call POST /v1/infer/activity-type." + "message": "activity_type must be one of: bike, run, swim, row, ski, lift, hike, or brick or triathlon with legs (got \"nope\"). To map another sport name, call POST /v1/infer/activity-type." } ], "total": 2, "succeeded": 1, "failed": 1, - "estimated_ms": 1944, - "elapsed_ms": 1521, - "request_id": "req_defeb928aeac" + "estimated_ms": 1931, + "elapsed_ms": 1577, + "request_id": "req_fa82968c7440" } }, "activity": { "type": "Activity", "body": { - "id": "b74fee38-1bca-4d9d-a72a-802ccdb9a77d", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "29b39138-2486-471f-ab9e-52d836d8e25e", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", "type": "bike", "duration_min": 150, @@ -1712,9 +1743,9 @@ "thermal_stress_level": 6, "is_race_event": false, "meal_before_min": 120, - "external_id": "sdk-python-19eb20f2-w1", - "created_at": 1794992370, - "updated_at": 1794992370 + "external_id": "sdk-python-88490c48-w1", + "created_at": 1795107835, + "updated_at": 1795107835 } }, "activity_list": { @@ -1722,8 +1753,8 @@ "body": { "activities": [ { - "id": "b74fee38-1bca-4d9d-a72a-802ccdb9a77d", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "29b39138-2486-471f-ab9e-52d836d8e25e", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", "type": "bike", "duration_min": 150, @@ -1731,16 +1762,16 @@ "thermal_stress_level": 6, "is_race_event": false, "meal_before_min": 120, - "external_id": "sdk-python-19eb20f2-w1", - "created_at": 1794992370, - "updated_at": 1794992370 + "external_id": "sdk-python-88490c48-w1", + "created_at": 1795107835, + "updated_at": 1795107835 } ], "pagination": { "total": 1, "has_more": false }, - "request_id": "req_dc6a9601ae8b" + "request_id": "req_68deabfda743" } }, "activity_calculate": { @@ -1754,7 +1785,7 @@ "carb_g_per_hr": 71, "sodium_mg_per_hr": 830, "fluid_ml_per_hr": 790, - "calculated_at": 1794992370 + "calculated_at": 1795107836 }, "safety": { "max_safe_fluid_ml_per_hr": 1500, @@ -1774,7 +1805,7 @@ "profile_complete": true }, "tier_source": "trial", - "trial_ends_at": 1797584352, + "trial_ends_at": 1797699820, "trial_calls_remaining_today": 9 } }, @@ -1788,7 +1819,7 @@ "carb_g_per_hr": 71, "sodium_mg_per_hr": 830, "fluid_ml_per_hr": 790, - "calculated_at": 1794992370 + "calculated_at": 1795107836 }, "safety": { "max_safe_fluid_ml_per_hr": 1500, @@ -1841,7 +1872,7 @@ "sodium": 86, "fluid": 1 }, - "note": "The base mix covers the rest: sugar 0g, sodium 300mg from salt, water 2080mL. Products are additions to the base recipe: this gap is normal and often optimal.", + "note": "The base mix covers the rest: sugar 0g, sodium 300mg from salt, water 2080mL.", "safety": { "max_safe_fluid_ml_per_hr": 1500, "max_safe_sodium_mg_per_hr": 3000, @@ -1857,7 +1888,7 @@ "body": { "rating": 4, "notes": "live suite", - "created_at": 1794992373 + "created_at": 1795107839 } }, "activity_import": { @@ -1865,38 +1896,38 @@ "body": { "imported": [ { - "id": "fa326782-7f42-4d74-9118-42799a2d1f5a", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "3616a83d-7abe-46d9-83fd-ee8a1c9e3848", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", "type": "run", "duration_min": 45, "intensity_level": 5, "is_race_event": false, "meal_before_min": 120, - "external_id": "sdk-python-19eb20f2-i1", + "external_id": "sdk-python-88490c48-i1", "prescription": { - "calculated_at": 1794992373, + "calculated_at": 1795107842, "profile_complete": false, "carb_range_g_per_hr": "20-30", "sodium_range_mg_per_hr": "0-500", "fluid_range_ml_per_hr": "200-600" }, - "created_at": 1794992373, - "updated_at": 1794992373 + "created_at": 1795107842, + "updated_at": 1795107842 } ], "total": 1, "succeeded": 1, "failed": 0, - "request_id": "req_86e50fbc094b", + "request_id": "req_954591de562a", "prescriptions": [ { "index": 0, - "activity_id": "fa326782-7f42-4d74-9118-42799a2d1f5a", + "activity_id": "3616a83d-7abe-46d9-83fd-ee8a1c9e3848", "result": { "tier": "full", "prescription": { - "calculated_at": 1794992373, + "calculated_at": 1795107842, "profile_complete": false, "carb_range_g_per_hr": "20-30", "sodium_range_mg_per_hr": "0-500", @@ -1936,8 +1967,8 @@ "message": "For exact numbers, fill in what is missing. This session is missing thermal_stress_level. Set it on the activity with PATCH /v1/athletes/{athlete_id}/activities/{activity_id}, then calculate the activity again." }, "tier_source": "trial", - "trial_ends_at": 1797584352, - "trial_calls_remaining_today": 8 + "trial_ends_at": 1797699820, + "trial_calls_remaining_today": 7 } } ] @@ -2199,8 +2230,8 @@ "simulate_subscription": { "type": "SimulateSubscriptionResponse", "body": { - "athlete_id": "5441d3de-36eb-4a82-9c56-6369e78e8d65", - "request_id": "req_07d708d9c273", + "athlete_id": "ea917cff-eced-495f-9990-ebccea50d58f", + "request_id": "req_676c83ad557c", "simulated_active": true } }, @@ -2217,9 +2248,12 @@ "burst_size": 100, "requests_per_minute": 3000, "requests_per_day": 10000, - "ip_requests_per_day": 5000 + "ip_requests_per_day": 5000, + "trial_starts_per_day": 50, + "trial_profiles_per_athlete": 3, + "trial_days": 30 }, - "created_at": 1794992254 + "created_at": 1795107724 } }, "usage": { @@ -2227,16 +2261,16 @@ "body": { "by_endpoint": { "/v1/activity-types": 4, - "/v1/athletes": 8, - "/v1/athletes/batch": 4, + "/v1/athletes": 10, + "/v1/athletes/batch": 6, "/v1/athletes/{athlete_id}": 4, "/v1/athletes/{athlete_id}/activities": 5, "/v1/athletes/{athlete_id}/activities/import": 3, - "/v1/athletes/{athlete_id}/activities/{activity_id}": 9, - "/v1/athletes/{athlete_id}/activities/{activity_id}/calculate": 7, + "/v1/athletes/{athlete_id}/activities/{activity_id}": 13, + "/v1/athletes/{athlete_id}/activities/{activity_id}/calculate": 9, "/v1/athletes/{athlete_id}/activities/{activity_id}/feedback": 2, "/v1/athletes/{athlete_id}/activities/{activity_id}/prep": 5, - "/v1/athletes/{athlete_id}/activities/{activity_id}/prescription": 3, + "/v1/athletes/{athlete_id}/activities/{activity_id}/prescription": 7, "/v1/athletes/{athlete_id}/consent": 2, "/v1/athletes/{athlete_id}/consent/{consent_id}": 1, "/v1/athletes/{athlete_id}/delete": 5, @@ -2255,7 +2289,7 @@ "/v1/organizations/{id}/members/{memberId}": 1, "/v1/organizations/{id}/offer": 3, "/v1/organizations/{id}/subscriptions": 1, - "/v1/partner": 1, + "/v1/partner": 2, "/v1/partner/api-keys": 2, "/v1/partner/api-keys/{keyId}": 1, "/v1/partner/api-keys/{keyId}/rotate": 1, @@ -2270,20 +2304,20 @@ }, "daily": [ { - "date": "2026-11-18", - "total_calls": 138, + "date": "2026-11-19", + "total_calls": 153, "by_endpoint": { "/v1/activity-types": 4, - "/v1/athletes": 8, - "/v1/athletes/batch": 4, + "/v1/athletes": 10, + "/v1/athletes/batch": 6, "/v1/athletes/{athlete_id}": 4, "/v1/athletes/{athlete_id}/activities": 5, "/v1/athletes/{athlete_id}/activities/import": 3, - "/v1/athletes/{athlete_id}/activities/{activity_id}": 9, - "/v1/athletes/{athlete_id}/activities/{activity_id}/calculate": 7, + "/v1/athletes/{athlete_id}/activities/{activity_id}": 13, + "/v1/athletes/{athlete_id}/activities/{activity_id}/calculate": 9, "/v1/athletes/{athlete_id}/activities/{activity_id}/feedback": 2, "/v1/athletes/{athlete_id}/activities/{activity_id}/prep": 5, - "/v1/athletes/{athlete_id}/activities/{activity_id}/prescription": 3, + "/v1/athletes/{athlete_id}/activities/{activity_id}/prescription": 7, "/v1/athletes/{athlete_id}/consent": 2, "/v1/athletes/{athlete_id}/consent/{consent_id}": 1, "/v1/athletes/{athlete_id}/delete": 5, @@ -2302,7 +2336,7 @@ "/v1/organizations/{id}/members/{memberId}": 1, "/v1/organizations/{id}/offer": 3, "/v1/organizations/{id}/subscriptions": 1, - "/v1/partner": 1, + "/v1/partner": 2, "/v1/partner/api-keys": 2, "/v1/partner/api-keys/{keyId}": 1, "/v1/partner/api-keys/{keyId}/rotate": 1, @@ -2315,18 +2349,18 @@ "/v1/webhooks/{id}/deliveries": 2, "/v1/webhooks/{id}/test": 1 }, - "ip_calls": 50, - "own_calls": 88, + "ip_calls": 56, + "own_calls": 97, "unique_athletes": 8, "estimate_calculates": 2 } ], "period": { - "from": "2026-10-19", - "to": "2026-11-18" + "from": "2026-10-20", + "to": "2026-11-19" }, - "request_id": "req_9fe1b32cf6c4", - "total_calls": 138 + "request_id": "req_64aadd3bfdba", + "total_calls": 153 } }, "usage_daily": { @@ -2334,20 +2368,20 @@ "body": { "daily": [ { - "date": "2026-11-18", - "total_calls": 140, + "date": "2026-11-19", + "total_calls": 154, "by_endpoint": { "/v1/activity-types": 4, - "/v1/athletes": 8, - "/v1/athletes/batch": 4, + "/v1/athletes": 10, + "/v1/athletes/batch": 6, "/v1/athletes/{athlete_id}": 4, "/v1/athletes/{athlete_id}/activities": 5, "/v1/athletes/{athlete_id}/activities/import": 3, - "/v1/athletes/{athlete_id}/activities/{activity_id}": 9, - "/v1/athletes/{athlete_id}/activities/{activity_id}/calculate": 7, + "/v1/athletes/{athlete_id}/activities/{activity_id}": 13, + "/v1/athletes/{athlete_id}/activities/{activity_id}/calculate": 9, "/v1/athletes/{athlete_id}/activities/{activity_id}/feedback": 2, "/v1/athletes/{athlete_id}/activities/{activity_id}/prep": 5, - "/v1/athletes/{athlete_id}/activities/{activity_id}/prescription": 3, + "/v1/athletes/{athlete_id}/activities/{activity_id}/prescription": 7, "/v1/athletes/{athlete_id}/consent": 2, "/v1/athletes/{athlete_id}/consent/{consent_id}": 1, "/v1/athletes/{athlete_id}/delete": 5, @@ -2379,17 +2413,17 @@ "/v1/webhooks/{id}/deliveries": 2, "/v1/webhooks/{id}/test": 1 }, - "ip_calls": 50, - "own_calls": 90, + "ip_calls": 56, + "own_calls": 98, "unique_athletes": 8, "estimate_calculates": 2 } ], "period": { - "from": "2026-11-11", - "to": "2026-11-18" + "from": "2026-11-12", + "to": "2026-11-19" }, - "request_id": "req_1f782040dcde" + "request_id": "req_bfa8b27d0aa6" } }, "api_keys": { @@ -2397,53 +2431,53 @@ "body": { "api_keys": [ { - "id": "97cbff1eb25cd7c3bb94cc876cb5ae31bfe78eab6d149177d0bec8116561decb", - "name": "sdk-node-aefc57c2-key", + "id": "184270db1e1e5f2f19c806ddf7e482c094ca10a5455c8dd8959b316ae432cbda", + "name": "sdk-live", "environment": "test", "scopes": [ "*" ], - "created_at": 1794992322, - "last_used_at": 0, - "revoked": true + "created_at": 1795107724, + "last_used_at": 1795107845, + "revoked": false }, { - "id": "b301fd6443ef23abac75d62b8e489b6c869a706a03ef45364a26ed115c1bd97b", - "name": "sdk-live", + "id": "3e681ff13df1fb62f181fd405a14bc73fd148bf119c5a842a8b04e8d861a232c", + "name": "sdk-node-717d343f-key", "environment": "test", "scopes": [ "*" ], - "created_at": 1794992254, - "last_used_at": 1794992376, - "revoked": false + "created_at": 1795107793, + "last_used_at": 0, + "revoked": true }, { - "id": "d0804fff2a43055901b564e51b3aaccb933bfba4dbafd1739e497d3ed5d38c2b", - "name": "sdk-node-aefc57c2-key", + "id": "4b18be4d729a78e3a2bc1b1940ccacac3f60f9cd832c70f66b51cb5bed679515", + "name": "sdk-node-717d343f-key", "environment": "test", "scopes": [ "*" ], - "created_at": 1794992322, + "created_at": 1795107793, "last_used_at": 0, "revoked": true } ], - "request_id": "req_07e87fa7de65", + "request_id": "req_03fafde98146", "total": 3 } }, "api_key_created": { "type": "CreatedApiKey", "body": { - "created_at": 1794992378, + "created_at": 1795107845, "environment": "test", - "id": "f70958bbc16022581dfb12fbbbfaffea9ecc5a8b91060ac4463f75ac3643f048", + "id": "326e7ab6c55c0c3342292af39ae981e65f96f1be72713f4ee450095753974c33", "key": "sk_test_example", "message": "Store this key securely \u2014 it will not be shown again.", - "name": "sdk-python-19eb20f2-key", - "request_id": "req_01b4407e5dff", + "name": "sdk-python-88490c48-key", + "request_id": "req_f5b33603c9fd", "scopes": [ "*" ] @@ -2453,12 +2487,12 @@ "type": "RotatedApiKey", "body": { "environment": "test", - "id": "8504deb3e53dabcfa18e7b73715a3cba8b152f20490a033ef3adcc8c5e4a4947", + "id": "aaa790cb8fd8453a3e4544fa9358557b025f8b5492d968a169ec6bb5bd20f457", "key": "sk_test_example", "message": "Store this key securely \u2014 it will not be shown again. The old key has been revoked.", - "name": "sdk-python-19eb20f2-key", - "request_id": "req_16659138dfb6", - "rotated_from": "f70958bbc16022581dfb12fbbbfaffea9ecc5a8b91060ac4463f75ac3643f048", + "name": "sdk-python-88490c48-key", + "request_id": "req_fe1e92101fb1", + "rotated_from": "326e7ab6c55c0c3342292af39ae981e65f96f1be72713f4ee450095753974c33", "scopes": [ "*" ] @@ -2468,17 +2502,17 @@ "type": "WebhookCreateResponse", "body": { "message": "Store the secret securely \u2014 it will not be shown again. Use it to verify webhook signatures.", - "request_id": "req_b50efd0d978e", + "request_id": "req_a279554ad355", "webhook": { - "id": "6575c5c3-2bf0-4da6-8418-1b623fce0c53", + "id": "24828579-0e06-481e-8866-7fc7fe9ace17", "partner_id": "partner_example", "url": "https://example.com/saturday-live-suite", "events": [ "prescription.calculated" ], "active": true, - "created_at": 1794992378, - "updated_at": 1794992378, + "created_at": 1795107845, + "updated_at": 1795107845, "fail_count": 0, "secret": "whsec_example" } @@ -2487,19 +2521,19 @@ "webhook_list": { "type": "WebhookListResponse", "body": { - "request_id": "req_3fd69a77de69", + "request_id": "req_b25c072cd35d", "total": 1, "webhooks": [ { - "id": "6575c5c3-2bf0-4da6-8418-1b623fce0c53", + "id": "24828579-0e06-481e-8866-7fc7fe9ace17", "partner_id": "partner_example", "url": "https://example.com/saturday-live-suite", "events": [ "prescription.calculated" ], "active": true, - "created_at": 1794992378, - "updated_at": 1794992378, + "created_at": 1795107845, + "updated_at": 1795107845, "fail_count": 0 } ] @@ -2508,15 +2542,15 @@ "webhook": { "type": "Webhook", "body": { - "id": "6575c5c3-2bf0-4da6-8418-1b623fce0c53", + "id": "24828579-0e06-481e-8866-7fc7fe9ace17", "partner_id": "partner_example", "url": "https://example.com/saturday-live-suite", "events": [ "prescription.calculated" ], "active": true, - "created_at": 1794992378, - "updated_at": 1794992378, + "created_at": 1795107845, + "updated_at": 1795107845, "fail_count": 0 } }, @@ -2524,20 +2558,20 @@ "type": "WebhookTestResponse", "body": { "delivery": { - "id": "eae11df7-b65e-494f-83df-85112e8ae337", - "webhook_id": "6575c5c3-2bf0-4da6-8418-1b623fce0c53", - "event_id": "619e4017-5a4d-428a-a1a0-28cc738afbcd", + "id": "034cdb79-1efe-4686-af04-9f8b562ca521", + "webhook_id": "24828579-0e06-481e-8866-7fc7fe9ace17", + "event_id": "cd391a6a-dcc7-4154-86c1-bc70c7a4f8b9", "event_type": "webhook.test", - "event_data": "eyJpZCI6IjYxOWU0MDE3LTVhNGQtNDI4YS1hMWEwLTI4Y2M3MzhhZmJjZCIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NDk5MjM3OH0=", + "event_data": "eyJpZCI6ImNkMzkxYTZhLWRjYzctNDE1NC04NmMxLWJjNzBjN2E0ZjhiOSIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NTEwNzg0Nn0=", "url": "https://example.com/saturday-live-suite", "status_code": 405, "response_body": "Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

", "attempts": 1, "status": "failed", - "created_at": 1794992379, + "created_at": 1795107846, "partner_id": "partner_example" }, - "request_id": "req_f73069b35927" + "request_id": "req_243d2f098958" } }, "webhook_deliveries": { @@ -2545,48 +2579,48 @@ "body": { "deliveries": [ { - "id": "84824ae0-c104-4a94-b1c0-079c3cf70935", - "webhook_id": "6575c5c3-2bf0-4da6-8418-1b623fce0c53", - "event_id": "60a1cb8e-931b-4b3d-a146-6289baf9d2a5", + "id": "bdb22fa6-1992-4430-861e-c121c7e6a2db", + "webhook_id": "24828579-0e06-481e-8866-7fc7fe9ace17", + "event_id": "bf56de8a-587b-485c-a170-b4fb837b20ec", "event_type": "prescription.calculated", - "event_data": "eyJpZCI6IjYwYTFjYjhlLTkzMWItNGIzZC1hMTQ2LTYyODliYWY5ZDJhNSIsInR5cGUiOiJwcmVzY3JpcHRpb24uY2FsY3VsYXRlZCIsImRhdGEiOnsiYXRobGV0ZV9pZCI6IjgwYjE1Y2NmLTg1NGItNGJkYS1hYTIyLWFhYWI2Nzc3M2RlMyIsImF0dHJpYnV0aW9uIjp7ImxpbmsiOiJodHRwczovL3NhdHVyZGF5LmZpdCIsImxvZ29fdXJsIjoiaHR0cHM6Ly9zYXR1cmRheS5maXQvbG9nby5wbmciLCJyZXF1aXJlZCI6dHJ1ZSwidGV4dCI6IlBvd2VyZWQgYnkgU2F0dXJkYXkifSwiY2FyYl9nX3Blcl9ociI6MzAsImZsdWlkX21sX3Blcl9ociI6NDAwLCJwcmVjaXNpb24iOnsicHJvZmlsZV9jb21wbGV0ZSI6dHJ1ZX0sInNhZmV0eSI6eyJjb25maWRlbmNlX3Njb3JlIjoxLCJtYXhfc2FmZV9mbHVpZF9tbF9wZXJfaHIiOjE1MDAsIm1heF9zYWZlX3NvZGl1bV9tZ19wZXJfaHIiOjMwMDAsIm5vdF9pbnN0cnVjdGlvbnMiOnRydWUsInJlcXVpcmVzX2h1bWFuX3JldmlldyI6ZmFsc2UsIndhcm5pbmdzIjpbXX0sInNvZGl1bV9tZ19wZXJfaHIiOjMwMCwidGllciI6ImZ1bGwiLCJ0aWVyX3NvdXJjZSI6InRyaWFsIiwidG90YWxfY2FyYl9nIjozMCwidG90YWxfZmx1aWRfbWwiOjQwMCwidG90YWxfc29kaXVtX21nIjozMDAsInRyaWFsX2NhbGxzX3JlbWFpbmluZ190b2RheSI6NywidHJpYWxfZW5kc19hdCI6MTc5NzU4NDM1Mn0sImNyZWF0ZWRfYXQiOjE3OTQ5OTIzNzl9", + "event_data": "eyJpZCI6ImJmNTZkZThhLTU4N2ItNDg1Yy1hMTcwLWI0ZmI4MzdiMjBlYyIsInR5cGUiOiJwcmVzY3JpcHRpb24uY2FsY3VsYXRlZCIsImRhdGEiOnsiYXRobGV0ZV9pZCI6IjZkZGE4OThkLTZjMWMtNDVkOC04N2Q1LTM0ZGNiODYxZmIxMiIsImF0dHJpYnV0aW9uIjp7ImxpbmsiOiJodHRwczovL3NhdHVyZGF5LmZpdCIsImxvZ29fdXJsIjoiaHR0cHM6Ly9zYXR1cmRheS5maXQvbG9nby5wbmciLCJyZXF1aXJlZCI6dHJ1ZSwidGV4dCI6IlBvd2VyZWQgYnkgU2F0dXJkYXkifSwiY2FyYl9nX3Blcl9ociI6MzAsImZsdWlkX21sX3Blcl9ociI6NDAwLCJwcmVjaXNpb24iOnsicHJvZmlsZV9jb21wbGV0ZSI6dHJ1ZX0sInNhZmV0eSI6eyJjb25maWRlbmNlX3Njb3JlIjoxLCJtYXhfc2FmZV9mbHVpZF9tbF9wZXJfaHIiOjE1MDAsIm1heF9zYWZlX3NvZGl1bV9tZ19wZXJfaHIiOjMwMDAsIm5vdF9pbnN0cnVjdGlvbnMiOnRydWUsInJlcXVpcmVzX2h1bWFuX3JldmlldyI6ZmFsc2UsIndhcm5pbmdzIjpbXX0sInNvZGl1bV9tZ19wZXJfaHIiOjMwMCwidGllciI6ImZ1bGwiLCJ0aWVyX3NvdXJjZSI6InRyaWFsIiwidG90YWxfY2FyYl9nIjozMCwidG90YWxfZmx1aWRfbWwiOjQwMCwidG90YWxfc29kaXVtX21nIjozMDAsInRyaWFsX2NhbGxzX3JlbWFpbmluZ190b2RheSI6MywidHJpYWxfZW5kc19hdCI6MTc5NzY5OTgyMH0sImNyZWF0ZWRfYXQiOjE3OTUxMDc4NDd9", "url": "https://example.com/saturday-live-suite", "status_code": 405, "response_body": "Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

", "attempts": 1, - "next_retry_at": 1794992439, + "next_retry_at": 1795107907, "status": "failed", - "created_at": 1794992379, + "created_at": 1795107847, "partner_id": "partner_example" }, { - "id": "eae11df7-b65e-494f-83df-85112e8ae337", - "webhook_id": "6575c5c3-2bf0-4da6-8418-1b623fce0c53", - "event_id": "619e4017-5a4d-428a-a1a0-28cc738afbcd", + "id": "034cdb79-1efe-4686-af04-9f8b562ca521", + "webhook_id": "24828579-0e06-481e-8866-7fc7fe9ace17", + "event_id": "cd391a6a-dcc7-4154-86c1-bc70c7a4f8b9", "event_type": "webhook.test", - "event_data": "eyJpZCI6IjYxOWU0MDE3LTVhNGQtNDI4YS1hMWEwLTI4Y2M3MzhhZmJjZCIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NDk5MjM3OH0=", + "event_data": "eyJpZCI6ImNkMzkxYTZhLWRjYzctNDE1NC04NmMxLWJjNzBjN2E0ZjhiOSIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NTEwNzg0Nn0=", "url": "https://example.com/saturday-live-suite", "status_code": 405, "response_body": "Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

", "attempts": 1, "status": "failed", - "created_at": 1794992379, + "created_at": 1795107846, "partner_id": "partner_example" } ], - "request_id": "req_743f31d71fd6", + "request_id": "req_7ac33a5d994e", "total": 2 } }, "organization": { "type": "Organization", "body": { - "id": "7cb4c882-f5c9-4ef8-a7b3-f6b4e85cddd3", + "id": "65231b0f-c9e5-4d28-85d7-5195ccf819a7", "partner_id": "partner_example", - "display_name": "sdk-python-19eb20f2 team", + "display_name": "sdk-python-88490c48 team", "sport": "triathlon", - "created_at": 1794992382, - "updated_at": 1794992382, + "created_at": 1795107848, + "updated_at": 1795107848, "member_count": 0 } }, @@ -2595,22 +2629,22 @@ "body": { "organizations": [ { - "id": "7cb4c882-f5c9-4ef8-a7b3-f6b4e85cddd3", + "id": "65231b0f-c9e5-4d28-85d7-5195ccf819a7", "partner_id": "partner_example", - "display_name": "sdk-python-19eb20f2 team", + "display_name": "sdk-python-88490c48 team", "sport": "triathlon", - "created_at": 1794992382, - "updated_at": 1794992382, + "created_at": 1795107848, + "updated_at": 1795107848, "member_count": 0 }, { - "id": "eb067513-ef59-4ca9-9d82-cc3dc97acfee", + "id": "b732a0db-7e23-4de1-9544-dcb995b15ebd", "partner_id": "partner_example", - "display_name": "sdk-node-aefc57c2 team", + "display_name": "sdk-node-717d343f team", "description": "Live suite", "sport": "triathlon", - "created_at": 1794992325, - "updated_at": 1794992326, + "created_at": 1795107797, + "updated_at": 1795107798, "member_count": 0 } ], @@ -2618,17 +2652,17 @@ "total": 2, "has_more": false }, - "request_id": "req_ec69bafe7b3a" + "request_id": "req_108c112d6874" } }, "organization_member": { "type": "OrganizationMember", "body": { - "id": "3e85e8af-9f3d-4ddf-886e-f915ab98bcbd", - "email": "sdk-python-19eb20f2@example.com", + "id": "399c71fa-697c-4040-a815-b2737f723bc9", + "email": "sdk-python-88490c48@example.com", "role": "member", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", - "joined_at": 1794992382 + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "joined_at": 1795107848 } }, "organization_members": { @@ -2636,32 +2670,32 @@ "body": { "members": [ { - "id": "3e85e8af-9f3d-4ddf-886e-f915ab98bcbd", - "email": "sdk-python-19eb20f2@example.com", + "id": "399c71fa-697c-4040-a815-b2737f723bc9", + "email": "sdk-python-88490c48@example.com", "role": "member", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", - "joined_at": 1794992382 + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "joined_at": 1795107848 } ], - "request_id": "req_de36864fe801", + "request_id": "req_f706280d000a", "total": 1 } }, "organization_offer": { "type": "OrganizationOffer", "body": { - "id": "08daa10f-3728-4277-bae5-9c37e7e4ac0d", - "org_id": "7cb4c882-f5c9-4ef8-a7b3-f6b4e85cddd3", + "id": "d287cf03-8606-4cef-8f05-be7698bed299", + "org_id": "65231b0f-c9e5-4d28-85d7-5195ccf819a7", "discount_percent": 10, "active": true, - "created_at": 1794992382, + "created_at": 1795107849, "stack_cap_percent": 30 } }, "organization_subscriptions": { "type": "OrganizationSubscriptionListResponse", "body": { - "request_id": "req_d59bf139d217", + "request_id": "req_9f064b59e8d4", "subscriptions": [], "total": 0 } @@ -2669,12 +2703,12 @@ "consent": { "type": "ConsentRecord", "body": { - "id": "54d63bbc-b943-4331-bf9c-275205bed953", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "205b38fe-ba7e-4a99-8744-e1ac9db6824f", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", "consent_type": "analytics", "granted": true, - "granted_at": 1794992383, + "granted_at": 1795107849, "ip_address": "192.0.2.1" } }, @@ -2683,29 +2717,29 @@ "body": { "consent": [ { - "id": "54d63bbc-b943-4331-bf9c-275205bed953", - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "id": "205b38fe-ba7e-4a99-8744-e1ac9db6824f", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", "consent_type": "analytics", "granted": true, - "granted_at": 1794992383, + "granted_at": 1795107849, "ip_address": "192.0.2.1" } ], - "request_id": "req_35acb9a9ac48", + "request_id": "req_30964a2d6531", "total": 1 } }, "export": { "type": "AthleteDataExport", "body": { - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "partner_id": "partner_example", - "exported_at": 1794992383, + "exported_at": 1795107849, "profile": { - "created_at": 1794992348, - "external_id": "sdk-python-19eb20f2-a", - "id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "created_at": 1795107820, + "external_id": "sdk-python-88490c48-a", + "id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "name": "Live Suite", "partner_id": "partner_example", "profile_complete": true, @@ -2720,24 +2754,27 @@ "usual_carb_consumption": "range_60_80" }, "sex": "female", - "trial_started_at": 1794992352, - "updated_at": 1794992349, + "trial_profiles": [ + "1251fa8cb67d" + ], + "trial_started_at": 1795107820, + "updated_at": 1795107820, "weight_kg": 62, "year_of_birth": 1990 }, "activities": [ { - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", - "created_at": 1794992373, + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "created_at": 1795107842, "duration_min": 45, - "external_id": "sdk-python-19eb20f2-i1", - "id": "fa326782-7f42-4d74-9118-42799a2d1f5a", + "external_id": "sdk-python-88490c48-i1", + "id": "3616a83d-7abe-46d9-83fd-ee8a1c9e3848", "intensity_level": 5, "is_race_event": false, "meal_before_min": 120, "partner_id": "partner_example", "prescription": { - "calculated_at": 1794992373, + "calculated_at": 1795107842, "carb_g_per_hr": 0, "carb_range_g_per_hr": "20-30", "confidence": 0.25, @@ -2751,19 +2788,19 @@ "total_sodium_mg": 0 }, "type": "run", - "updated_at": 1794992374 + "updated_at": 1795107842 } ], "consent": [ { - "athlete_id": "80b15ccf-854b-4bda-aa22-aaab67773de3", + "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", "consent_type": "analytics", "granted": true, - "granted_at": 1794992383, - "id": "54d63bbc-b943-4331-bf9c-275205bed953", + "granted_at": 1795107849, + "id": "205b38fe-ba7e-4a99-8744-e1ac9db6824f", "ip_address": "192.0.2.1", "partner_id": "partner_example", - "revoked_at": 1794992383 + "revoked_at": 1795107849 } ] } @@ -2771,9 +2808,9 @@ "integration_status": { "type": "IntegrationStatusResponse", "body": { - "request_id": "req_9e6a2e1a8587", + "request_id": "req_6325b0f5e83e", "status": { - "provider": "strava", + "provider": "intervals_icu", "connected": false, "sync_count": 0 } @@ -2889,8 +2926,8 @@ "activity_brick": { "type": "Activity", "body": { - "id": "03ce907e-be0b-4a34-a55b-f17630e244d1", - "athlete_id": "31b0f33e-9ff8-425d-bdcd-31a0d795f6ec", + "id": "e18d4a10-4719-401d-87b0-1a620a9edcc0", + "athlete_id": "fc58aa29-780e-4d1f-a863-cf86d8b8a0e4", "partner_id": "partner_example", "type": "brick", "duration_min": 120, @@ -2910,9 +2947,9 @@ } ], "meal_before_min": 120, - "external_id": "sdk-python-19eb20f2-brick", - "created_at": 1794992398, - "updated_at": 1794992398 + "external_id": "sdk-python-88490c48-brick", + "created_at": 1795107864, + "updated_at": 1795107864 } }, "activity_calculate_brick": { @@ -2926,7 +2963,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1794992398, + "calculated_at": 1795107865, "legs": [ { "duration_min": 90, @@ -2977,7 +3014,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1794992398, + "calculated_at": 1795107865, "legs": [ { "duration_min": 90, @@ -3053,7 +3090,7 @@ "warnings": [ "Leg 2 (run): Carbs exceed prescription by 45g" ], - "note": "The base mix covers the rest: sugar 0g, sodium 437mg from salt, water 1340mL. Products are additions to the base recipe: this gap is normal and often optimal.", + "note": "The base mix covers the rest: sugar 0g, sodium 437mg from salt, water 1340mL.", "legs": [ { "activity_type": "bike", @@ -3096,7 +3133,7 @@ "sodium": 71, "fluid": 3 }, - "note": "The base mix covers the rest: sugar 0g, sodium 247mg from salt, water 1070mL. Products are additions to the base recipe: this gap is normal and often optimal." + "note": "The base mix covers the rest: sugar 0g, sodium 247mg from salt, water 1070mL." }, { "activity_type": "run", @@ -3142,7 +3179,7 @@ "warnings": [ "Carbs exceed prescription by 45g" ], - "note": "The base mix covers the rest: sugar 0g, sodium 190mg from salt, water 270mL. Products are additions to the base recipe: this gap is normal and often optimal." + "note": "The base mix covers the rest: sugar 0g, sodium 190mg from salt, water 270mL." } ], "safety": { @@ -3201,7 +3238,7 @@ "warnings": [ "Leg 2 (run): Carbs exceed prescription by 20g" ], - "note": "The base mix covers the rest: sugar 10g, sodium 210mg from salt, water 1380mL. Products are additions to the base recipe: this gap is normal and often optimal.", + "note": "The base mix covers the rest: sugar 10g, sodium 210mg from salt, water 1380mL.", "legs": [ { "activity_type": "bike", @@ -3236,7 +3273,7 @@ "sodium": 100, "fluid": 0 }, - "note": "The base mix covers the rest: sugar 10g, sodium 0mg from salt, water 1100mL. Products are additions to the base recipe: this gap is normal and often optimal." + "note": "The base mix covers the rest: sugar 10g, sodium 0mg from salt, water 1100mL." }, { "activity_type": "run", @@ -3274,7 +3311,7 @@ "warnings": [ "Carbs exceed prescription by 20g" ], - "note": "The base mix covers the rest: sugar 0g, sodium 210mg from salt, water 280mL. Products are additions to the base recipe: this gap is normal and often optimal." + "note": "The base mix covers the rest: sugar 0g, sodium 210mg from salt, water 280mL." } ], "safety": { @@ -3397,7 +3434,7 @@ "sodium_mg": 230, "fluid_ml": 290 }, - "verdict": "At 1 servings: provides 83% carbs, 8% sodium. The rest comes from base ingredients (sugar + salt + water)." + "verdict": "At 1 serving: provides 83% carbs, 8% sodium. The rest comes from base ingredients (sugar + salt + water)." } } ], @@ -3709,8 +3746,8 @@ "body": { "imported": [ { - "id": "795c9783-20cf-4202-88f2-075aa74e3177", - "athlete_id": "31b0f33e-9ff8-425d-bdcd-31a0d795f6ec", + "id": "1a63b23b-3849-4fca-b9e6-c8e30d46ae1d", + "athlete_id": "fc58aa29-780e-4d1f-a863-cf86d8b8a0e4", "partner_id": "partner_example", "type": "brick", "duration_min": 120, @@ -3730,7 +3767,7 @@ } ], "meal_before_min": 120, - "external_id": "sdk-python-19eb20f2-i-brick", + "external_id": "sdk-python-88490c48-i-brick", "prescription": { "total_carb_g": 140, "total_sodium_mg": 1100, @@ -3738,7 +3775,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1794992405, + "calculated_at": 1795107872, "legs": [ { "duration_min": 90, @@ -3760,18 +3797,18 @@ } ] }, - "created_at": 1794992405, - "updated_at": 1794992405 + "created_at": 1795107872, + "updated_at": 1795107872 } ], "total": 1, "succeeded": 1, "failed": 0, - "request_id": "req_e1206e770578", + "request_id": "req_f0cee635ddd8", "prescriptions": [ { "index": 0, - "activity_id": "795c9783-20cf-4202-88f2-075aa74e3177", + "activity_id": "1a63b23b-3849-4fca-b9e6-c8e30d46ae1d", "result": { "tier": "full", "prescription": { @@ -3781,7 +3818,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1794992405, + "calculated_at": 1795107872, "legs": [ { "duration_min": 90, diff --git a/tests/test_hidden_routes.py b/tests/test_hidden_routes.py index b87035a..f0acab8 100644 --- a/tests/test_hidden_routes.py +++ b/tests/test_hidden_routes.py @@ -1,10 +1,11 @@ -"""The SDK neither calls nor names routes no partner key reaches.""" +"""The SDK neither calls nor names routes no partner key reaches: closed to partners, retired (the +key purchase) or called with a signed-in Saturday account rather than a key (saturday.fit/api).""" from pathlib import Path from saturday import Saturday -HIDDEN_PATHS = ["/v1/products", "/v1/ai/", "/ai/conversations", "/gear"] +HIDDEN_PATHS = ["/v1/products", "/v1/ai/", "/ai/conversations", "/gear", "/v1/signup", "/v1/account/"] def test_calls_no_route_closed_to_partners(): diff --git a/tests/test_live.py b/tests/test_live.py index cabe641..867ebd0 100644 --- a/tests/test_live.py +++ b/tests/test_live.py @@ -13,7 +13,7 @@ import pytest -from saturday import NotFoundError, PermissionDeniedError, Saturday, ValidationError +from saturday import ConflictError, NotFoundError, PermissionDeniedError, Saturday, ValidationError BASE = os.environ.get("SATURDAY_LIVE_BASE_URL") KEY = os.environ.get("SATURDAY_LIVE_API_KEY") @@ -121,9 +121,16 @@ def exact(plan): def test_main_flows(live): client, capture, run = live - capture("discovery", "Dict", client.meta.discovery()) + discovery = capture("discovery", "DiscoveryResponse", client.meta.discovery()) + # A key comes with a paid Saturday plan: the API names the page and no price. + assert discovery["get_a_key"]["page"] == "https://saturday.fit/api" + assert discovery["get_a_key"]["athletes_per_key"] > 0 + assert not re.search(r"\$\d", json.dumps(discovery)) catalog = capture("errors", "ErrorCatalogResponse", client.meta.errors()) - assert "unsupported_field" in [e["code"] for e in catalog["errors"]] + codes = [e["code"] for e in catalog["errors"]] + for code in ("unsupported_field", "athlete_exists", "plan_inactive", "simulated_subscriber_daily_limit_reached", "provider_erasure_incomplete"): + assert code in codes, code + assert "payment_error" not in codes capture("health", "HealthResponse", client.meta.health()) types = capture("activity_types", "ActivityTypesResponse", client.reference.activity_types()) assert [t["id"] for t in types["linked_session_types"]] == ["brick", "triathlon"] @@ -137,12 +144,22 @@ def test_main_flows(live): assert complete["profile_complete"] is True partial = client.athletes.create(external_id=f"{run}-b", weight_kg=70) capture("athlete_list", "AthleteListResponse", client.athletes.list(external_id=f"{run}-a")) + # One athlete per external_id: a retried create, and a PATCH onto a taken id, change nothing and name the holder. + with pytest.raises(ConflictError) as again: + client.athletes.create(external_id=f"{run}-a", **COMPLETE) + assert (again.value.code, again.value.athlete_id) == ("athlete_exists", complete["id"]) + with pytest.raises(ConflictError) as taken: + client.athletes.update(partial["id"], external_id=f"{run}-a") + assert taken.value.athlete_id == complete["id"] + assert [a["id"] for a in client.athletes.list(external_id=f"{run}-a")["athletes"]] == [complete["id"]] assert client.athletes.update(complete["id"], name="Live Suite")["name"] == "Live Suite" settings = client.athletes.update_settings(complete["id"], **{**COMPLETE["settings"], "sweat_level": 6}) assert settings["sweat_level"] == 6 capture("fueling_profile", "FuelingProfile", client.athletes.get_fueling_profile(complete["id"])) - batch = capture("athletes_batch", "BatchAthleteResponse", client.athletes.batch_create([{"external_id": f"{run}-c"}, {"sex": "female"}])) + batch = capture("athletes_batch", "BatchAthleteResponse", client.athletes.batch_create( + [{"external_id": f"{run}-c"}, {"sex": "female"}, {"external_id": f"{run}-a"}])) assert batch["errors"][0]["index"] == 1 + assert (batch["errors"][1]["index"], batch["errors"][1]["code"], batch["errors"][1]["athlete_id"]) == (2, "athlete_exists", complete["id"]) client.athletes.erase(batch["created"][0]["id"]) # Calculation @@ -193,6 +210,15 @@ def test_main_flows(live): ])) assert prep["prescription"]["carb_g"] == stored["prescription"]["total_carb_g"] capture("feedback", "ActivityFeedback", client.activities.submit_feedback(complete["id"], activity["id"], rating=4, notes="live suite")) + # A field sent at its stored value keeps the prescription; a change to the session removes it until the next calculate. + client.activities.update(complete["id"], activity["id"], intensity_level=6, external_id=f"{run}-w1b") + assert client.activities.get_prescription(complete["id"], activity["id"])["prescription"]["total_carb_g"] == stored["prescription"]["total_carb_g"] + assert "prescription" not in client.activities.update(complete["id"], activity["id"], intensity_level=8) + with pytest.raises(NotFoundError) as outdated: + client.activities.get_prescription(complete["id"], activity["id"]) + assert outdated.value.code == "prescription_not_found" + fresh = client.activities.calculate_prescription(complete["id"], activity["id"]) + assert client.activities.get_prescription(complete["id"], activity["id"])["prescription"]["total_carb_g"] == fresh["prescription"]["total_carb_g"] imported = capture("activity_import", "ActivityImportResponse", client.activities.import_activities(complete["id"], [ {"type": "run", "duration_min": 45, "intensity_level": 5, "meal_before_min": 120, "is_race_event": False, "external_id": f"{run}-i1"}, ], calculate=True)) @@ -226,7 +252,8 @@ def test_main_flows(live): assert not client.testing.simulate_subscription(partial["id"], active=False)["simulated_active"] # Partner account - capture("partner", "PartnerAccount", client.partner.get()) + account = capture("partner", "PartnerAccount", client.partner.get()) + assert account["rate_limits"]["trial_days"] > 0 usage = capture("usage", "UsageResponse", client.partner.usage()) assert usage["by_endpoint"] and all(endpoint.startswith("/v1/") for endpoint in usage["by_endpoint"]) capture("usage_daily", "DailyUsageResponse", client.partner.usage_daily()) @@ -281,7 +308,12 @@ def test_main_flows(live): client.athletes.revoke_consent(complete["id"], consent["id"]) exported = capture("export", "AthleteDataExport", client.athletes.export(complete["id"])) assert abs(exported["exported_at"] - time.time()) < 600 - capture("integration_status", "IntegrationStatusResponse", client.integrations.status("strava", complete["id"])) + for provider in ("strava", "training_peaks"): + with pytest.raises(ValidationError) as refused_provider: + client.integrations.sync(provider, athlete_id=complete["id"], access_token="not-a-token") + assert refused_provider.value.code == "invalid_provider" + status = capture("integration_status", "IntegrationStatusResponse", client.integrations.status("intervals_icu", complete["id"])) + assert status["status"]["connected"] is False client.athletes.erase(partial["id"]) with pytest.raises(NotFoundError): client.athletes.get(partial["id"]) @@ -368,6 +400,9 @@ def test_linked_sessions(live): with pytest.raises(ValidationError) as wrong_count: client.activities.prep(aid, stored["id"], legs=[{"products": []}]) assert (wrong_count.value.code, wrong_count.value.param) == ("invalid_value", "legs") + with pytest.raises(ValidationError) as both: + client.activities.prep(aid, stored["id"], products=[{"product_query": "maurten gel 100"}], legs=[{"products": []}, {"products": []}]) + assert (both.value.code, both.value.param) == ("invalid_value", "products") # Fit and compare size the whole session at the top level and each leg's share under legs. brick_fit = capture("product_fit_brick", "ProductFitResponse", client.nutrition.product_fit( @@ -410,6 +445,8 @@ def test_linked_sessions(live): assert minutes.value.param == "duration_min" longer = client.activities.update(aid, stored["id"], legs=[activity_legs[0], {**activity_legs[1], "duration_min": 45}]) assert longer["duration_min"] == 135 + with pytest.raises(NotFoundError): + client.activities.get_prescription(aid, stored["id"]) assert client.activities.calculate_prescription(aid, stored["id"])["prescription"]["total_carb_g"] > brick["total_carb_g"] single = client.activities.update(aid, stored["id"], type="run", duration_min=60, intensity_level=5, thermal_stress_level=5) assert single["type"] == "run" and "legs" not in single diff --git a/tests/test_request.py b/tests/test_request.py index 5e13c06..7d56678 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -1,7 +1,9 @@ +import json + import httpx import pytest -from saturday import NotFoundError, PermissionDeniedError, RateLimitError, Saturday, ValidationError +from saturday import ConflictError, NotFoundError, PermissionDeniedError, RateLimitError, Saturday, ValidationError @pytest.fixture @@ -183,6 +185,7 @@ def _too_many(code, headers=None): @pytest.mark.parametrize("code", [ "daily_call_limit_reached", "intelligence_daily_limit_reached", "athlete_free_daily_limit_reached", "distinct_lookup_daily_limit_reached", + "simulated_subscriber_daily_limit_reached", ]) def test_daily_codes_are_never_retried_and_carry_the_reset(make_client, monkeypatch, code): from datetime import datetime, timezone @@ -261,3 +264,40 @@ def test_other_validation_errors_carry_no_suggestion(make_client): with pytest.raises(ValidationError) as raised: client.nutrition.calculate(activity_type="brick", legs=[]) assert raised.value.suggestion is None + + +def test_taken_external_id_raises_conflict_naming_the_athlete(make_client): + calls = [] + client = make_client(lambda r: calls.append(r) or httpx.Response(409, json={"error": { + "type": "invalid_request", "code": "athlete_exists", "athlete_id": "ath_1", "request_id": "req_1", + "message": 'An athlete with external_id "user-42" already exists: ath_1. Nothing was created.', + }})) + with pytest.raises(ConflictError) as raised: + client.athletes.create(external_id="user-42") + assert (raised.value.status, raised.value.code, raised.value.athlete_id) == (409, "athlete_exists", "ath_1") + assert len(calls) == 1 + + +def test_sync_posts_to_the_intervals_icu_route_with_sync_types(make_client): + seen = [] + body = {"result": {"provider": "intervals_icu", "status": "completed", "activities_found": 1, + "activities_synced": 1, "activities_skipped": 0}, "request_id": "req_1"} + client = make_client(lambda r: seen.append(r) or httpx.Response(200, json=body)) + synced = client.integrations.sync("intervals_icu", athlete_id="ath_1", access_token="tok", + date_range={"start": "2026-11-01", "end": "2026-11-07"}) + assert synced["result"]["activities_synced"] == 1 + assert seen[0].url.path == "/v1/integrations/intervals_icu/sync" + assert json.loads(seen[0].content) == {"athlete_id": "ath_1", "access_token": "tok", "sync_types": ["activities"], + "date_range": {"start": "2026-11-01", "end": "2026-11-07"}} + + +def test_erase_incomplete_is_raised_not_retried(make_client): + calls = [] + client = make_client(lambda r: calls.append(r) or httpx.Response(503, json={"error": { + "type": "api_error", "code": "provider_erasure_incomplete", + "message": "A provider connection you supplied for this athlete could not be revoked yet, so nothing was deleted. Retry the request.", + }})) + with pytest.raises(Exception) as raised: + client.athletes.erase("ath_1") + assert (raised.value.status, raised.value.code) == (503, "provider_erasure_incomplete") + assert len(calls) == 1 From bcecc6fc4cc9541f4c390679703a3f64d85a0db3 Mon Sep 17 00:00:00 2001 From: Alex Harrison Date: Thu, 19 Nov 2026 15:09:28 -0700 Subject: [PATCH 2/2] 0.8.0: the trial's exact answers, and disconnect of a provider never connected TrialMetadata.trial_answers_used_up and rate_limits.trial_answers (the exact answers one athlete's trial gives in all); trial_note and plan_basis trial_allowance cover the new bound. integrations.disconnect documents 404 integration_not_found. Recordings made again against the partner API on the test environment (7224bc165161). Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 +- README.md | 6 +- saturday/client.py | 4 +- saturday/types.py | 18 +- tests/fixtures/live.json | 384 ++++++++++++++++++++------------------- 5 files changed, 219 insertions(+), 199 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f2e4b9..ae71316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Breaking changes: -- `integrations.sync` takes `"intervals_icu"` only: the API refuses Strava and TrainingPeaks tokens with a `ValidationError` of code `invalid_provider`. Send TrainingPeaks workouts with `activities.import_activities` once the athlete agrees to share them. `sync` takes `date_range` (`{"start", "end"}`; it said `from` and `to`, which the API never read) and `sync_types` (default `["activities"]`, sent for you) as keyword arguments; `refresh_token` and other options are gone (the API did not use them). The answer is `IntegrationSyncResponse`, `{"result", "request_id"}`, with what the sync did under `result` (`IntegrationSyncResult`, whose `status` is `completed`, `partial` or `failed`). `integrations.disconnect` returns `IntegrationDisconnectResponse` (`message`, `provider`, `request_id`). `IntegrationProvider` and `SyncProvider` name the providers each route takes. +- `integrations.sync` takes `"intervals_icu"` only: the API refuses Strava and TrainingPeaks tokens with a `ValidationError` of code `invalid_provider`. Send TrainingPeaks workouts with `activities.import_activities` once the athlete agrees to share them. `sync` takes `date_range` (`{"start", "end"}`; it said `from` and `to`, which the API never read) and `sync_types` (default `["activities"]`, sent for you) as keyword arguments; `refresh_token` and other options are gone (the API did not use them). The answer is `IntegrationSyncResponse`, `{"result", "request_id"}`, with what the sync did under `result` (`IntegrationSyncResult`, whose `status` is `completed`, `partial` or `failed`). `integrations.disconnect` returns `IntegrationDisconnectResponse` (`message`, `provider`, `request_id`), and raises `NotFoundError` (`integration_not_found`) for a provider the athlete never connected. `IntegrationProvider` and `SyncProvider` name the providers each route takes. - `external_id` is unique within your account. `athletes.create` or `athletes.update` with an `external_id` another of your athletes holds changes nothing and raises the new `ConflictError` (409, code `athlete_exists`), whose `athlete_id` names that athlete; a `batch_create` item fails with `athlete_exists` and `errors[i]["athlete_id"]`. A retried create is safe. - `meta.discovery()` returns `DiscoveryResponse`: `get_a_key` (`DiscoveryKeyInfo`) says how a key is had (any paid Saturday plan, made at saturday.fit/api, `athletes_per_key`, `api@saturday.fit`). The API no longer sells a key, so nothing in the package names a price or a signup route. - `products`, `gear` and `ai` are removed, with their types, `AIStreamError` and `AIStreamEvent`. Those routes are not open to partner keys. @@ -25,8 +25,8 @@ Breaking changes: Added: - `ConflictError` (409); `SaturdayError.athlete_id` and `BatchError["athlete_id"]`. -- The trial's bounds on calculate and the activity calculate (`TrialMetadata`): `trial_start_deferred` (your key has started its new trials for the UTC day), `trial_profile_limit_reached` (the athlete's trial covers its allowance of distinct profiles) and `trial_note`, words you can show the athlete; on the test environment, `simulated_limit_reached` and `simulation_note`. Product fit and compare answers carry `trial_start_deferred` and `trial_note` on the teaser tier. `PlanBasisSource` gains `trial_allowance` (product fit and compare spend one of the athlete's trial calls, as calculate does, and plan from ranges once today's calls are used) and `simulation_allowance`. -- `PartnerRateLimits` gains `trial_starts_per_day`, `trial_profiles_per_athlete` and `trial_days`, the trial's length. `PartnerAccount["plan"]` `individual` is a key that comes with a Saturday account's paid plan. +- The trial's bounds on calculate and the activity calculate (`TrialMetadata`): `trial_start_deferred` (your key has started its new trials for the UTC day), `trial_profile_limit_reached` (the athlete's trial covers its allowance of distinct profiles), `trial_answers_used_up` (the athlete's trial has given all its exact answers) and `trial_note`, words you can show the athlete; on the test environment, `simulated_limit_reached` and `simulation_note`. Product fit and compare answers carry `trial_start_deferred` and `trial_note` on the teaser tier. `PlanBasisSource` gains `trial_allowance` (product fit and compare spend one of the athlete's trial calls, as calculate does, and plan from ranges once today's calls or the trial's exact answers are used) and `simulation_allowance`. +- `PartnerRateLimits` gains `trial_starts_per_day`, `trial_profiles_per_athlete`, `trial_days` (the trial's length) and `trial_answers` (the exact answers one athlete's trial gives in all). `PartnerAccount["plan"]` `individual` is a key that comes with a Saturday account's paid plan. - `DAILY_LIMIT_CODES` gains `simulated_subscriber_daily_limit_reached`: on the test environment, `testing.simulate_subscription` marks at most 10 athletes per key per UTC day by default, then raises `RateLimitError` with `daily_limit` True and `resets_at`. - `PermissionDeniedError` documents `plan_inactive` (the paid plan a key comes with has ended; the key works again, with its athletes, once the plan is active) and `resource_limit_exceeded` (the key's athletes are at their limit). - Documented: `activities.update` with a change to the session removes the stored prescription, so `get_prescription` raises `NotFoundError` (`prescription_not_found`) until the activity is calculated again; `activities.prep` with both `products=` and `legs=` is refused (`invalid_value` on `products`); `athletes.erase` revokes the connections you supplied, deletes everything stored under the athlete and its link to a Saturday account, leaves the member's own Saturday account as it is, and answers 503 `provider_erasure_incomplete`, having deleted nothing, when a connection could not be revoked yet. The README's new "Get a key" section: a key comes with any paid Saturday plan, from saturday.fit/api, and covers 10 athletes; for more, write to api@saturday.fit. diff --git a/README.md b/README.md index 6d20fdd..8c69200 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ A calculation carries exact per-hour numbers and totals only when the athlete's - `precision["missing_session_inputs"]` names the session inputs your call left out. Send every session input on every call: `intensity_level`, `thermal_stress_level`, `meal_before_min` and `is_race`. One left out returns ranges even for a complete profile; `precision["onboarding"]` comes only when profile answers are missing. - Per-hour figures are whole numbers, as the Saturday app's Fuel card shows them, which is not always the total divided by the session's hours. Totals are for the whole session. - A zero may be omitted from the response, so read numbers with `.get(field, 0)`. -- A new athlete's first calculation, product fit or compare starts a trial of the full tier: 15 calls on the first day, then 5 a day, each fit and compare spending one. `trial_calls_remaining_today` and `trial_ends_at` show where it stands, and `client.partner.get()` gives the trial's length in `rate_limits["trial_days"]`. Past a bound the answer is ranges with a flag and a note you can show the athlete: `trial_cap_reached` (today's calls are used), `trial_start_deferred` (your key has started its new trials for the day) or `trial_profile_limit_reached` (the trial covers a set number of distinct profiles), each with `trial_cap_note` or `trial_note`. +- A new athlete's first calculation, product fit or compare starts a trial of the full tier: 15 calls on the first day, then 5 a day, each fit and compare spending one. `trial_calls_remaining_today` and `trial_ends_at` show where it stands, and `client.partner.get()` gives the trial's length in `rate_limits["trial_days"]` and the exact answers it gives in all in `rate_limits["trial_answers"]`. Past a bound the answer is ranges with a flag and a note you can show the athlete: `trial_cap_reached` (today's calls are used), `trial_start_deferred` (your key has started its new trials for the day), `trial_profile_limit_reached` (the trial covers a set number of distinct profiles) or `trial_answers_used_up` (the trial has given all its exact answers), each with `trial_cap_note` or `trial_note`. ## Prep and product fit @@ -137,7 +137,7 @@ with Saturday(api_key="sk_test_...") as client: A stored activity uses `type` and `is_race_event`; a calculation uses `activity_type` and `is_race`. The API refuses the other spelling with a `ValidationError` whose `code` is `unsupported_field`. -When the athlete's profile or the session is missing inputs, prep, product fit and compare plan from the middle of the athlete's ranges and say so in `plan_basis`: its `source` is `profile_incomplete`, `session_incomplete` or both, `missing_profile_fields` and `missing_session_inputs` list what is missing, and `onboarding` comes only when profile answers are. A trial past today's calls plans from ranges too, with `source` `trial_allowance`. Show `plan_basis["message"]` with the plan. Product answers follow the athlete's Saturday subscription or trial: without one, `tier` is `"teaser"` and the response carries product categories in place of the fit. +When the athlete's profile or the session is missing inputs, prep, product fit and compare plan from the middle of the athlete's ranges and say so in `plan_basis`: its `source` is `profile_incomplete`, `session_incomplete` or both, `missing_profile_fields` and `missing_session_inputs` list what is missing, and `onboarding` comes only when profile answers are. A trial past today's calls or its exact answers plans from ranges too, with `source` `trial_allowance`. Show `plan_basis["message"]` with the plan. Product answers follow the athlete's Saturday subscription or trial: without one, `tier` is `"teaser"` and the response carries product categories in place of the fit. `activities.update` with a change to the session (`type`, `legs`, `duration_min`, effort, heat, `is_race_event` or `meal_before_min`) removes the stored prescription: `get_prescription` raises `NotFoundError` (`prescription_not_found`) until you calculate the activity again. A field sent at its stored value changes nothing. @@ -218,7 +218,7 @@ Every timestamp a partner key receives is an integer of Unix seconds: on athlete `athletes.update_settings` replaces the whole settings object: send every setting you want kept. `athletes.delete` removes the athlete and everything stored under them in your account. `athletes.erase` is for a right-to-erasure request: it first revokes, at the provider, each connection you supplied for the athlete with `integrations.sync`, then deletes the athlete, everything stored under them and their link to a Saturday account. A linked athlete's own Saturday account is not changed. A 503 with code `provider_erasure_incomplete` means nothing was deleted yet: call `erase` again. -`integrations.sync("intervals_icu", ...)` fetches the activities of the intervals.icu user an access token belongs to, a token your intervals.icu app obtained, and stores them under your athlete; it is the only provider sync takes. Send TrainingPeaks workouts with `activities.import_activities` once the athlete agrees to share them. `integrations.disconnect` ends the connection you supplied and keeps the activities already synced. +`integrations.sync("intervals_icu", ...)` fetches the activities of the intervals.icu user an access token belongs to, a token your intervals.icu app obtained, and stores them under your athlete; it is the only provider sync takes. Send TrainingPeaks workouts with `activities.import_activities` once the athlete agrees to share them. `integrations.disconnect` ends the connection you supplied and keeps the activities already synced; for a provider the athlete never connected it raises `NotFoundError` (`integration_not_found`). Nutrition and knowledge sit behind [feature gates](https://docs.saturday.fit/guides/feature-gates) that Saturday opens per partner. Until a gate is open for your key, its routes answer `403` with code `feature_alpha` (`PermissionDeniedError`); ask api@saturday.fit to open one. diff --git a/saturday/client.py b/saturday/client.py index 7aa5e5a..21c95f0 100644 --- a/saturday/client.py +++ b/saturday/client.py @@ -692,7 +692,9 @@ def status(self, provider: str, athlete_id: str) -> IntegrationStatusResponse: def disconnect(self, provider: str, athlete_id: str) -> IntegrationDisconnectResponse: """End the connection you supplied for the athlete with ``sync``: it is revoked at the provider and its tokens are removed. Activities already synced stay. A linked athlete's own - connection to the provider in their Saturday account is not changed.""" + connection to the provider in their Saturday account is not changed. A provider the athlete + never connected raises ``NotFoundError`` (code ``integration_not_found``), and nothing + reaches the provider.""" return self._client.request("POST", f"/v1/integrations/{_seg(provider)}/disconnect", json={"athlete_id": athlete_id}) diff --git a/saturday/types.py b/saturday/types.py index c141ae9..3bbbe26 100644 --- a/saturday/types.py +++ b/saturday/types.py @@ -25,7 +25,8 @@ """Why a plan is from ranges: the athlete's profile answers are missing, the session's inputs are, or both. ``stored_ranges`` is an activity's stored ranges with nothing missing that can be named now (the athlete has answered since): calculate the activity again. ``trial_allowance``: the athlete's -trial has used today's calls, or this profile is past the trial's allowance of profiles; +trial has used today's calls or given all its exact answers, or this profile is past the trial's +allowance of profiles; ``message`` says which, in words you can show the athlete. ``simulation_allowance`` (test environment only): the athlete's simulated subscription has given its allowance.""" @@ -135,8 +136,9 @@ class ActivityLeg(TypedDict): class TrialMetadata(TypedDict, total=False): - """Trial and sandbox fields on a calculation. The trial's length is ``rate_limits.trial_days`` - on ``partner.get()``.""" + """Trial and sandbox fields on a calculation. ``partner.get()`` gives the trial's length in + ``rate_limits.trial_days`` and the exact answers it gives in all in + ``rate_limits.trial_answers``.""" tier_source: str trial_ends_at: int # When the trial ends, Unix seconds. @@ -151,8 +153,11 @@ class TrialMetadata(TypedDict, total=False): # (rate_limits.trial_profiles_per_athlete), so this new one is answered in ranges. Earlier # profiles stay exact. trial_profile_limit_reached: bool - # With trial_start_deferred or trial_profile_limit_reached, why these numbers are ranges, in - # words you can show the athlete. + # The athlete's trial has given all its exact answers (rate_limits.trial_answers), so these + # numbers are ranges until the athlete subscribes. + trial_answers_used_up: bool + # With trial_start_deferred, trial_profile_limit_reached or trial_answers_used_up, why these + # numbers are ranges, in words you can show the athlete. trial_note: str # Test environment only: the athlete's simulated subscription has given its allowance of exact # answers or distinct profiles, so these numbers are ranges. @@ -1190,6 +1195,9 @@ class PartnerRateLimits(TypedDict): # ranges with trial_profile_limit_reached. None when the key has no such bound. trial_profiles_per_athlete: Optional[int] trial_days: int # Days an athlete's trial lasts from its first exact answer. + # Exact answers one athlete's trial gives in all, however the days fall; the next answer gets + # ranges with trial_answers_used_up. None when the key has no such bound. + trial_answers: Optional[int] class PartnerAccount(TypedDict): diff --git a/tests/fixtures/live.json b/tests/fixtures/live.json index a448574..b15143b 100644 --- a/tests/fixtures/live.json +++ b/tests/fixtures/live.json @@ -14,7 +14,7 @@ "page": "https://saturday.fit/api", "platforms": "Building Saturday into a platform for many athletes? Write to api@saturday.fit about a partnership.", "quickstart": "https://docs.saturday.fit/quickstart", - "trial": "Each athlete gets 30 days of exact numbers; after that, exact numbers come with the athlete's Saturday subscription.", + "trial": "Each athlete gets 14 days of exact numbers, up to 42 answers in all; after that, exact numbers come with the athlete's Saturday subscription.", "who_is_this": "Builders whose athletes live in their own system. Coaching athletes who use the Saturday app? The coach portal is your lane, and its API keys come with every paid coach plan: https://coach.saturday.fit" }, "links": { @@ -29,7 +29,7 @@ "settings_schema": "/v1/settings/schema" }, "name": "Saturday API", - "request_id": "req_34b82d631709", + "request_id": "req_8adca9a13578", "version": "1.0.0" } }, @@ -517,6 +517,14 @@ "retryable": false, "documentation_url": "https://docs.saturday.fit/guides/webhooks" }, + { + "code": "integration_not_found", + "type": "resource_not_found", + "http_status": 404, + "message": "The athlete never connected this provider, so there is nothing to disconnect.", + "retryable": false, + "documentation_url": "https://docs.saturday.fit/guides/integrations" + }, { "code": "key_not_found", "type": "resource_not_found", @@ -686,15 +694,15 @@ "documentation_url": "https://docs.saturday.fit/error-handling" } ], - "request_id": "req_f0875373aac2", - "total": 81 + "request_id": "req_ab8ddcc071c5", + "total": 82 } }, "health": { "type": "HealthResponse", "body": { "status": "ok", - "timestamp": "2026-11-19T17:03:39Z", + "timestamp": "2026-11-19T22:04:57Z", "version": "1.0.0" } }, @@ -776,7 +784,7 @@ "max_duration_min": 2160 } ], - "request_id": "req_4ab607025fa7", + "request_id": "req_dde07bcaeddf", "total": 7 } }, @@ -804,14 +812,14 @@ "max_duration_min": 2160 } ], - "request_id": "req_659d051250e9", + "request_id": "req_7e2c96db8325", "total": 0 } }, "settings_schema": { "type": "SettingsSchemaResponse", "body": { - "request_id": "req_3ac162947219", + "request_id": "req_ead9152a342f", "settings": [ { "field": "sweat_level", @@ -1210,16 +1218,16 @@ ] } ], - "request_id": "req_9cdfea5cc1fa", + "request_id": "req_b81cd89af0fc", "schema_version": "2026-06-12.1" } }, "athlete": { "type": "Athlete", "body": { - "id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", - "external_id": "sdk-python-88490c48-a", + "external_id": "sdk-python-54d7e3e2-a", "sex": "female", "year_of_birth": 1990, "weight_kg": 62, @@ -1233,8 +1241,8 @@ "performance": true, "concerns_answered": true }, - "created_at": 1795107820, - "updated_at": 1795107820, + "created_at": 1795125898, + "updated_at": 1795125898, "profile_complete": true } }, @@ -1243,9 +1251,9 @@ "body": { "athletes": [ { - "id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", - "external_id": "sdk-python-88490c48-a", + "external_id": "sdk-python-54d7e3e2-a", "sex": "female", "year_of_birth": 1990, "weight_kg": 62, @@ -1259,8 +1267,8 @@ "performance": true, "concerns_answered": true }, - "created_at": 1795107820, - "updated_at": 1795107820, + "created_at": 1795125898, + "updated_at": 1795125898, "profile_complete": true } ], @@ -1268,14 +1276,14 @@ "total": 1, "has_more": false }, - "request_id": "req_5e1224b09c0d" + "request_id": "req_669a42cbf98d" } }, "fueling_profile": { "type": "FuelingProfile", "body": { "object": "fueling_profile", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "sharing": "not_linked", "message": "This athlete has not connected a Saturday account, so there are no Saturday app answers to share." } @@ -1285,12 +1293,12 @@ "body": { "created": [ { - "id": "e37b1955-1a15-41a7-9c64-5953fd7bbacd", + "id": "8945765e-91d6-4f39-9f8a-ac4fa08189be", "partner_id": "partner_example", - "external_id": "sdk-python-88490c48-c", + "external_id": "sdk-python-54d7e3e2-c", "settings": {}, - "created_at": 1795107820, - "updated_at": 1795107820, + "created_at": 1795125900, + "updated_at": 1795125900, "profile_complete": false } ], @@ -1303,14 +1311,14 @@ { "index": 2, "code": "athlete_exists", - "message": "An athlete with external_id \"sdk-python-88490c48-a\" already exists: 6dda898d-6c1c-45d8-87d5-34dcb861fb12. Nothing was created.", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12" + "message": "An athlete with external_id \"sdk-python-54d7e3e2-a\" already exists: 46e14267-1619-48bf-86af-521f00a65261. Nothing was created.", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261" } ], "total": 3, "succeeded": 1, "failed": 2, - "request_id": "req_7eebba3a04f1" + "request_id": "req_b051d0ae2b2b" } }, "calculate_exact": { @@ -1341,7 +1349,7 @@ "profile_complete": true }, "tier_source": "trial", - "trial_ends_at": 1797699820, + "trial_ends_at": 1796335501, "trial_calls_remaining_today": 14 } }, @@ -1478,7 +1486,7 @@ } }, "tier_source": "trial", - "trial_ends_at": 1797699827, + "trial_ends_at": 1796335508, "trial_calls_remaining_today": 14 } }, @@ -1712,7 +1720,7 @@ "profile_complete": true }, "tier_source": "trial", - "trial_ends_at": 1797699820, + "trial_ends_at": 1796335501, "trial_calls_remaining_today": 10 } ], @@ -1726,16 +1734,16 @@ "total": 2, "succeeded": 1, "failed": 1, - "estimated_ms": 1931, - "elapsed_ms": 1577, - "request_id": "req_fa82968c7440" + "estimated_ms": 1984, + "elapsed_ms": 1412, + "request_id": "req_b863a7439f14" } }, "activity": { "type": "Activity", "body": { - "id": "29b39138-2486-471f-ab9e-52d836d8e25e", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "80a4d99d-cb60-4212-a2f5-436083dc3fb2", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", "type": "bike", "duration_min": 150, @@ -1743,9 +1751,9 @@ "thermal_stress_level": 6, "is_race_event": false, "meal_before_min": 120, - "external_id": "sdk-python-88490c48-w1", - "created_at": 1795107835, - "updated_at": 1795107835 + "external_id": "sdk-python-54d7e3e2-w1", + "created_at": 1795125917, + "updated_at": 1795125917 } }, "activity_list": { @@ -1753,8 +1761,8 @@ "body": { "activities": [ { - "id": "29b39138-2486-471f-ab9e-52d836d8e25e", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "80a4d99d-cb60-4212-a2f5-436083dc3fb2", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", "type": "bike", "duration_min": 150, @@ -1762,16 +1770,16 @@ "thermal_stress_level": 6, "is_race_event": false, "meal_before_min": 120, - "external_id": "sdk-python-88490c48-w1", - "created_at": 1795107835, - "updated_at": 1795107835 + "external_id": "sdk-python-54d7e3e2-w1", + "created_at": 1795125917, + "updated_at": 1795125917 } ], "pagination": { "total": 1, "has_more": false }, - "request_id": "req_68deabfda743" + "request_id": "req_bbe92b5c54a4" } }, "activity_calculate": { @@ -1785,7 +1793,7 @@ "carb_g_per_hr": 71, "sodium_mg_per_hr": 830, "fluid_ml_per_hr": 790, - "calculated_at": 1795107836 + "calculated_at": 1795125918 }, "safety": { "max_safe_fluid_ml_per_hr": 1500, @@ -1805,7 +1813,7 @@ "profile_complete": true }, "tier_source": "trial", - "trial_ends_at": 1797699820, + "trial_ends_at": 1796335501, "trial_calls_remaining_today": 9 } }, @@ -1819,7 +1827,7 @@ "carb_g_per_hr": 71, "sodium_mg_per_hr": 830, "fluid_ml_per_hr": 790, - "calculated_at": 1795107836 + "calculated_at": 1795125918 }, "safety": { "max_safe_fluid_ml_per_hr": 1500, @@ -1888,7 +1896,7 @@ "body": { "rating": 4, "notes": "live suite", - "created_at": 1795107839 + "created_at": 1795125922 } }, "activity_import": { @@ -1896,38 +1904,38 @@ "body": { "imported": [ { - "id": "3616a83d-7abe-46d9-83fd-ee8a1c9e3848", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "27f348d7-6080-43f3-8aff-fa21bf3932b8", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", "type": "run", "duration_min": 45, "intensity_level": 5, "is_race_event": false, "meal_before_min": 120, - "external_id": "sdk-python-88490c48-i1", + "external_id": "sdk-python-54d7e3e2-i1", "prescription": { - "calculated_at": 1795107842, + "calculated_at": 1795125926, "profile_complete": false, "carb_range_g_per_hr": "20-30", "sodium_range_mg_per_hr": "0-500", "fluid_range_ml_per_hr": "200-600" }, - "created_at": 1795107842, - "updated_at": 1795107842 + "created_at": 1795125926, + "updated_at": 1795125926 } ], "total": 1, "succeeded": 1, "failed": 0, - "request_id": "req_954591de562a", + "request_id": "req_479d80b19938", "prescriptions": [ { "index": 0, - "activity_id": "3616a83d-7abe-46d9-83fd-ee8a1c9e3848", + "activity_id": "27f348d7-6080-43f3-8aff-fa21bf3932b8", "result": { "tier": "full", "prescription": { - "calculated_at": 1795107842, + "calculated_at": 1795125926, "profile_complete": false, "carb_range_g_per_hr": "20-30", "sodium_range_mg_per_hr": "0-500", @@ -1967,7 +1975,7 @@ "message": "For exact numbers, fill in what is missing. This session is missing thermal_stress_level. Set it on the activity with PATCH /v1/athletes/{athlete_id}/activities/{activity_id}, then calculate the activity again." }, "tier_source": "trial", - "trial_ends_at": 1797699820, + "trial_ends_at": 1796335501, "trial_calls_remaining_today": 7 } } @@ -2230,8 +2238,8 @@ "simulate_subscription": { "type": "SimulateSubscriptionResponse", "body": { - "athlete_id": "ea917cff-eced-495f-9990-ebccea50d58f", - "request_id": "req_676c83ad557c", + "athlete_id": "4e971df8-2f54-46bd-b336-3210ded61d28", + "request_id": "req_fb17ef1637bd", "simulated_active": true } }, @@ -2239,21 +2247,22 @@ "type": "PartnerAccount", "body": { "id": "partner_example", - "name": "SDK live suite", + "name": "SDK live suite (Claude, throwaway)", "contact_email": "partner@example.com", "status": "active", "plan": "partner", "rate_limits": { - "requests_per_second": 50, - "burst_size": 100, - "requests_per_minute": 3000, - "requests_per_day": 10000, - "ip_requests_per_day": 5000, + "requests_per_second": 10, + "burst_size": 20, + "requests_per_minute": 600, + "requests_per_day": 2000, + "ip_requests_per_day": 325, "trial_starts_per_day": 50, "trial_profiles_per_athlete": 3, - "trial_days": 30 + "trial_days": 14, + "trial_answers": 42 }, - "created_at": 1795107724 + "created_at": 1795125699 } }, "usage": { @@ -2359,7 +2368,7 @@ "from": "2026-10-20", "to": "2026-11-19" }, - "request_id": "req_64aadd3bfdba", + "request_id": "req_eb5dd3b12b2d", "total_calls": 153 } }, @@ -2423,7 +2432,7 @@ "from": "2026-11-12", "to": "2026-11-19" }, - "request_id": "req_bfa8b27d0aa6" + "request_id": "req_92f2e0de297e" } }, "api_keys": { @@ -2431,53 +2440,53 @@ "body": { "api_keys": [ { - "id": "184270db1e1e5f2f19c806ddf7e482c094ca10a5455c8dd8959b316ae432cbda", - "name": "sdk-live", + "id": "595f6017fde0113b467fcebd24d924c4c07c40bf1cf5602d6a2f0aaabb3b231b", + "name": "sdk-node-6987f285-key", "environment": "test", "scopes": [ "*" ], - "created_at": 1795107724, - "last_used_at": 1795107845, - "revoked": false + "created_at": 1795125875, + "last_used_at": 0, + "revoked": true }, { - "id": "3e681ff13df1fb62f181fd405a14bc73fd148bf119c5a842a8b04e8d861a232c", - "name": "sdk-node-717d343f-key", + "id": "a1b073768c30bb052a9361d0aa5e95271676a0dade28d764a004a4b4ed0e20fe", + "name": "partner_sdklive_1119b-test-key", "environment": "test", "scopes": [ "*" ], - "created_at": 1795107793, - "last_used_at": 0, - "revoked": true + "created_at": 1795125700, + "last_used_at": 1795125931, + "revoked": false }, { - "id": "4b18be4d729a78e3a2bc1b1940ccacac3f60f9cd832c70f66b51cb5bed679515", - "name": "sdk-node-717d343f-key", + "id": "d63d68a41fbd8009b6578b244b19b614e2849a6c7246d8dd47ac49c2dbfe1305", + "name": "sdk-node-6987f285-key", "environment": "test", "scopes": [ "*" ], - "created_at": 1795107793, + "created_at": 1795125874, "last_used_at": 0, "revoked": true } ], - "request_id": "req_03fafde98146", + "request_id": "req_71f1a6382dfc", "total": 3 } }, "api_key_created": { "type": "CreatedApiKey", "body": { - "created_at": 1795107845, + "created_at": 1795125931, "environment": "test", - "id": "326e7ab6c55c0c3342292af39ae981e65f96f1be72713f4ee450095753974c33", + "id": "c5c6b5885daa50ea0078adade82f55237de4f00ec8eee6d0f479b4e7b2099926", "key": "sk_test_example", "message": "Store this key securely \u2014 it will not be shown again.", - "name": "sdk-python-88490c48-key", - "request_id": "req_f5b33603c9fd", + "name": "sdk-python-54d7e3e2-key", + "request_id": "req_4a8083ad6f22", "scopes": [ "*" ] @@ -2487,12 +2496,12 @@ "type": "RotatedApiKey", "body": { "environment": "test", - "id": "aaa790cb8fd8453a3e4544fa9358557b025f8b5492d968a169ec6bb5bd20f457", + "id": "4b2f2d15cc7f99b05e296de6a1d78906c3f32e05852ff121f418a1d3139e1855", "key": "sk_test_example", "message": "Store this key securely \u2014 it will not be shown again. The old key has been revoked.", - "name": "sdk-python-88490c48-key", - "request_id": "req_fe1e92101fb1", - "rotated_from": "326e7ab6c55c0c3342292af39ae981e65f96f1be72713f4ee450095753974c33", + "name": "sdk-python-54d7e3e2-key", + "request_id": "req_64dd0ffb7594", + "rotated_from": "c5c6b5885daa50ea0078adade82f55237de4f00ec8eee6d0f479b4e7b2099926", "scopes": [ "*" ] @@ -2502,17 +2511,17 @@ "type": "WebhookCreateResponse", "body": { "message": "Store the secret securely \u2014 it will not be shown again. Use it to verify webhook signatures.", - "request_id": "req_a279554ad355", + "request_id": "req_bcf256808a4b", "webhook": { - "id": "24828579-0e06-481e-8866-7fc7fe9ace17", + "id": "13ecd1e6-47d7-4726-b330-ce3236b06708", "partner_id": "partner_example", "url": "https://example.com/saturday-live-suite", "events": [ "prescription.calculated" ], "active": true, - "created_at": 1795107845, - "updated_at": 1795107845, + "created_at": 1795125932, + "updated_at": 1795125932, "fail_count": 0, "secret": "whsec_example" } @@ -2521,19 +2530,19 @@ "webhook_list": { "type": "WebhookListResponse", "body": { - "request_id": "req_b25c072cd35d", + "request_id": "req_1116d394b3f7", "total": 1, "webhooks": [ { - "id": "24828579-0e06-481e-8866-7fc7fe9ace17", + "id": "13ecd1e6-47d7-4726-b330-ce3236b06708", "partner_id": "partner_example", "url": "https://example.com/saturday-live-suite", "events": [ "prescription.calculated" ], "active": true, - "created_at": 1795107845, - "updated_at": 1795107845, + "created_at": 1795125932, + "updated_at": 1795125932, "fail_count": 0 } ] @@ -2542,15 +2551,15 @@ "webhook": { "type": "Webhook", "body": { - "id": "24828579-0e06-481e-8866-7fc7fe9ace17", + "id": "13ecd1e6-47d7-4726-b330-ce3236b06708", "partner_id": "partner_example", "url": "https://example.com/saturday-live-suite", "events": [ "prescription.calculated" ], "active": true, - "created_at": 1795107845, - "updated_at": 1795107845, + "created_at": 1795125932, + "updated_at": 1795125932, "fail_count": 0 } }, @@ -2558,20 +2567,20 @@ "type": "WebhookTestResponse", "body": { "delivery": { - "id": "034cdb79-1efe-4686-af04-9f8b562ca521", - "webhook_id": "24828579-0e06-481e-8866-7fc7fe9ace17", - "event_id": "cd391a6a-dcc7-4154-86c1-bc70c7a4f8b9", + "id": "fafaf971-1a30-49c1-90c0-13a9ddd716f5", + "webhook_id": "13ecd1e6-47d7-4726-b330-ce3236b06708", + "event_id": "43429789-5735-48cd-812e-e62fe0b3c53c", "event_type": "webhook.test", - "event_data": "eyJpZCI6ImNkMzkxYTZhLWRjYzctNDE1NC04NmMxLWJjNzBjN2E0ZjhiOSIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NTEwNzg0Nn0=", + "event_data": "eyJpZCI6IjQzNDI5Nzg5LTU3MzUtNDhjZC04MTJlLWU2MmZlMGIzYzUzYyIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NTEyNTkzM30=", "url": "https://example.com/saturday-live-suite", "status_code": 405, "response_body": "Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

", "attempts": 1, "status": "failed", - "created_at": 1795107846, + "created_at": 1795125933, "partner_id": "partner_example" }, - "request_id": "req_243d2f098958" + "request_id": "req_fd642b3dd5fc" } }, "webhook_deliveries": { @@ -2579,48 +2588,48 @@ "body": { "deliveries": [ { - "id": "bdb22fa6-1992-4430-861e-c121c7e6a2db", - "webhook_id": "24828579-0e06-481e-8866-7fc7fe9ace17", - "event_id": "bf56de8a-587b-485c-a170-b4fb837b20ec", + "id": "d623613c-9b99-4ebf-aef4-69ac4cd75ec9", + "webhook_id": "13ecd1e6-47d7-4726-b330-ce3236b06708", + "event_id": "36aa4187-911b-41f0-b64f-12326ecde5f0", "event_type": "prescription.calculated", - "event_data": "eyJpZCI6ImJmNTZkZThhLTU4N2ItNDg1Yy1hMTcwLWI0ZmI4MzdiMjBlYyIsInR5cGUiOiJwcmVzY3JpcHRpb24uY2FsY3VsYXRlZCIsImRhdGEiOnsiYXRobGV0ZV9pZCI6IjZkZGE4OThkLTZjMWMtNDVkOC04N2Q1LTM0ZGNiODYxZmIxMiIsImF0dHJpYnV0aW9uIjp7ImxpbmsiOiJodHRwczovL3NhdHVyZGF5LmZpdCIsImxvZ29fdXJsIjoiaHR0cHM6Ly9zYXR1cmRheS5maXQvbG9nby5wbmciLCJyZXF1aXJlZCI6dHJ1ZSwidGV4dCI6IlBvd2VyZWQgYnkgU2F0dXJkYXkifSwiY2FyYl9nX3Blcl9ociI6MzAsImZsdWlkX21sX3Blcl9ociI6NDAwLCJwcmVjaXNpb24iOnsicHJvZmlsZV9jb21wbGV0ZSI6dHJ1ZX0sInNhZmV0eSI6eyJjb25maWRlbmNlX3Njb3JlIjoxLCJtYXhfc2FmZV9mbHVpZF9tbF9wZXJfaHIiOjE1MDAsIm1heF9zYWZlX3NvZGl1bV9tZ19wZXJfaHIiOjMwMDAsIm5vdF9pbnN0cnVjdGlvbnMiOnRydWUsInJlcXVpcmVzX2h1bWFuX3JldmlldyI6ZmFsc2UsIndhcm5pbmdzIjpbXX0sInNvZGl1bV9tZ19wZXJfaHIiOjMwMCwidGllciI6ImZ1bGwiLCJ0aWVyX3NvdXJjZSI6InRyaWFsIiwidG90YWxfY2FyYl9nIjozMCwidG90YWxfZmx1aWRfbWwiOjQwMCwidG90YWxfc29kaXVtX21nIjozMDAsInRyaWFsX2NhbGxzX3JlbWFpbmluZ190b2RheSI6MywidHJpYWxfZW5kc19hdCI6MTc5NzY5OTgyMH0sImNyZWF0ZWRfYXQiOjE3OTUxMDc4NDd9", + "event_data": "eyJpZCI6IjM2YWE0MTg3LTkxMWItNDFmMC1iNjRmLTEyMzI2ZWNkZTVmMCIsInR5cGUiOiJwcmVzY3JpcHRpb24uY2FsY3VsYXRlZCIsImRhdGEiOnsiYXRobGV0ZV9pZCI6IjQ2ZTE0MjY3LTE2MTktNDhiZi04NmFmLTUyMWYwMGE2NTI2MSIsImF0dHJpYnV0aW9uIjp7ImxpbmsiOiJodHRwczovL3NhdHVyZGF5LmZpdCIsImxvZ29fdXJsIjoiaHR0cHM6Ly9zYXR1cmRheS5maXQvbG9nby5wbmciLCJyZXF1aXJlZCI6dHJ1ZSwidGV4dCI6IlBvd2VyZWQgYnkgU2F0dXJkYXkifSwiY2FyYl9nX3Blcl9ociI6MzAsImZsdWlkX21sX3Blcl9ociI6NDAwLCJwcmVjaXNpb24iOnsicHJvZmlsZV9jb21wbGV0ZSI6dHJ1ZX0sInNhZmV0eSI6eyJjb25maWRlbmNlX3Njb3JlIjoxLCJtYXhfc2FmZV9mbHVpZF9tbF9wZXJfaHIiOjE1MDAsIm1heF9zYWZlX3NvZGl1bV9tZ19wZXJfaHIiOjMwMDAsIm5vdF9pbnN0cnVjdGlvbnMiOnRydWUsInJlcXVpcmVzX2h1bWFuX3JldmlldyI6ZmFsc2UsIndhcm5pbmdzIjpbXX0sInNvZGl1bV9tZ19wZXJfaHIiOjMwMCwidGllciI6ImZ1bGwiLCJ0aWVyX3NvdXJjZSI6InRyaWFsIiwidG90YWxfY2FyYl9nIjozMCwidG90YWxfZmx1aWRfbWwiOjQwMCwidG90YWxfc29kaXVtX21nIjozMDAsInRyaWFsX2NhbGxzX3JlbWFpbmluZ190b2RheSI6MywidHJpYWxfZW5kc19hdCI6MTc5NjMzNTUwMX0sImNyZWF0ZWRfYXQiOjE3OTUxMjU5MzN9", "url": "https://example.com/saturday-live-suite", "status_code": 405, "response_body": "Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

", "attempts": 1, - "next_retry_at": 1795107907, + "next_retry_at": 1795125993, "status": "failed", - "created_at": 1795107847, + "created_at": 1795125933, "partner_id": "partner_example" }, { - "id": "034cdb79-1efe-4686-af04-9f8b562ca521", - "webhook_id": "24828579-0e06-481e-8866-7fc7fe9ace17", - "event_id": "cd391a6a-dcc7-4154-86c1-bc70c7a4f8b9", + "id": "fafaf971-1a30-49c1-90c0-13a9ddd716f5", + "webhook_id": "13ecd1e6-47d7-4726-b330-ce3236b06708", + "event_id": "43429789-5735-48cd-812e-e62fe0b3c53c", "event_type": "webhook.test", - "event_data": "eyJpZCI6ImNkMzkxYTZhLWRjYzctNDE1NC04NmMxLWJjNzBjN2E0ZjhiOSIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NTEwNzg0Nn0=", + "event_data": "eyJpZCI6IjQzNDI5Nzg5LTU3MzUtNDhjZC04MTJlLWU2MmZlMGIzYzUzYyIsInR5cGUiOiJ3ZWJob29rLnRlc3QiLCJkYXRhIjp7Im1lc3NhZ2UiOiJUaGlzIGlzIGEgdGVzdCB3ZWJob29rIGRlbGl2ZXJ5IGZyb20gU2F0dXJkYXkifSwiY3JlYXRlZF9hdCI6MTc5NTEyNTkzM30=", "url": "https://example.com/saturday-live-suite", "status_code": 405, "response_body": "Example Domain

Example Domain

This domain is for use in documentation examples without needing permission. Avoid use in operations.

Learn more

", "attempts": 1, "status": "failed", - "created_at": 1795107846, + "created_at": 1795125933, "partner_id": "partner_example" } ], - "request_id": "req_7ac33a5d994e", + "request_id": "req_b3ad536ab1c2", "total": 2 } }, "organization": { "type": "Organization", "body": { - "id": "65231b0f-c9e5-4d28-85d7-5195ccf819a7", + "id": "daef6c16-8c10-4eb7-99f1-9ca146ea6ebc", "partner_id": "partner_example", - "display_name": "sdk-python-88490c48 team", + "display_name": "sdk-python-54d7e3e2 team", "sport": "triathlon", - "created_at": 1795107848, - "updated_at": 1795107848, + "created_at": 1795125936, + "updated_at": 1795125936, "member_count": 0 } }, @@ -2629,22 +2638,22 @@ "body": { "organizations": [ { - "id": "65231b0f-c9e5-4d28-85d7-5195ccf819a7", + "id": "daef6c16-8c10-4eb7-99f1-9ca146ea6ebc", "partner_id": "partner_example", - "display_name": "sdk-python-88490c48 team", + "display_name": "sdk-python-54d7e3e2 team", "sport": "triathlon", - "created_at": 1795107848, - "updated_at": 1795107848, + "created_at": 1795125936, + "updated_at": 1795125936, "member_count": 0 }, { - "id": "b732a0db-7e23-4de1-9544-dcb995b15ebd", + "id": "105fdd3b-fcd4-46bf-b894-32bbb287b0cc", "partner_id": "partner_example", - "display_name": "sdk-node-717d343f team", + "display_name": "sdk-node-6987f285 team", "description": "Live suite", "sport": "triathlon", - "created_at": 1795107797, - "updated_at": 1795107798, + "created_at": 1795125879, + "updated_at": 1795125880, "member_count": 0 } ], @@ -2652,17 +2661,17 @@ "total": 2, "has_more": false }, - "request_id": "req_108c112d6874" + "request_id": "req_8b15d5ff7aad" } }, "organization_member": { "type": "OrganizationMember", "body": { - "id": "399c71fa-697c-4040-a815-b2737f723bc9", - "email": "sdk-python-88490c48@example.com", + "id": "c58d067f-a8a4-4384-b562-c5f74df00c3f", + "email": "sdk-python-54d7e3e2@example.com", "role": "member", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", - "joined_at": 1795107848 + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", + "joined_at": 1795125937 } }, "organization_members": { @@ -2670,32 +2679,32 @@ "body": { "members": [ { - "id": "399c71fa-697c-4040-a815-b2737f723bc9", - "email": "sdk-python-88490c48@example.com", + "id": "c58d067f-a8a4-4384-b562-c5f74df00c3f", + "email": "sdk-python-54d7e3e2@example.com", "role": "member", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", - "joined_at": 1795107848 + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", + "joined_at": 1795125937 } ], - "request_id": "req_f706280d000a", + "request_id": "req_600e2e08f86d", "total": 1 } }, "organization_offer": { "type": "OrganizationOffer", "body": { - "id": "d287cf03-8606-4cef-8f05-be7698bed299", - "org_id": "65231b0f-c9e5-4d28-85d7-5195ccf819a7", + "id": "689512b5-6547-4249-81de-b801f56b6ba5", + "org_id": "daef6c16-8c10-4eb7-99f1-9ca146ea6ebc", "discount_percent": 10, "active": true, - "created_at": 1795107849, + "created_at": 1795125937, "stack_cap_percent": 30 } }, "organization_subscriptions": { "type": "OrganizationSubscriptionListResponse", "body": { - "request_id": "req_9f064b59e8d4", + "request_id": "req_b798686b54bb", "subscriptions": [], "total": 0 } @@ -2703,12 +2712,12 @@ "consent": { "type": "ConsentRecord", "body": { - "id": "205b38fe-ba7e-4a99-8744-e1ac9db6824f", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "94e4b032-ad9c-428c-b0c8-ba394a0082bf", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", "consent_type": "analytics", "granted": true, - "granted_at": 1795107849, + "granted_at": 1795125938, "ip_address": "192.0.2.1" } }, @@ -2717,29 +2726,29 @@ "body": { "consent": [ { - "id": "205b38fe-ba7e-4a99-8744-e1ac9db6824f", - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "id": "94e4b032-ad9c-428c-b0c8-ba394a0082bf", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", "consent_type": "analytics", "granted": true, - "granted_at": 1795107849, + "granted_at": 1795125938, "ip_address": "192.0.2.1" } ], - "request_id": "req_30964a2d6531", + "request_id": "req_83086af717d2", "total": 1 } }, "export": { "type": "AthleteDataExport", "body": { - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "partner_id": "partner_example", - "exported_at": 1795107849, + "exported_at": 1795125939, "profile": { - "created_at": 1795107820, - "external_id": "sdk-python-88490c48-a", - "id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "created_at": 1795125898, + "external_id": "sdk-python-54d7e3e2-a", + "id": "46e14267-1619-48bf-86af-521f00a65261", "name": "Live Suite", "partner_id": "partner_example", "profile_complete": true, @@ -2754,27 +2763,28 @@ "usual_carb_consumption": "range_60_80" }, "sex": "female", + "trial_answers": 12, "trial_profiles": [ "1251fa8cb67d" ], - "trial_started_at": 1795107820, - "updated_at": 1795107820, + "trial_started_at": 1795125901, + "updated_at": 1795125900, "weight_kg": 62, "year_of_birth": 1990 }, "activities": [ { - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", - "created_at": 1795107842, + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", + "created_at": 1795125926, "duration_min": 45, - "external_id": "sdk-python-88490c48-i1", - "id": "3616a83d-7abe-46d9-83fd-ee8a1c9e3848", + "external_id": "sdk-python-54d7e3e2-i1", + "id": "27f348d7-6080-43f3-8aff-fa21bf3932b8", "intensity_level": 5, "is_race_event": false, "meal_before_min": 120, "partner_id": "partner_example", "prescription": { - "calculated_at": 1795107842, + "calculated_at": 1795125926, "carb_g_per_hr": 0, "carb_range_g_per_hr": "20-30", "confidence": 0.25, @@ -2788,19 +2798,19 @@ "total_sodium_mg": 0 }, "type": "run", - "updated_at": 1795107842 + "updated_at": 1795125926 } ], "consent": [ { - "athlete_id": "6dda898d-6c1c-45d8-87d5-34dcb861fb12", + "athlete_id": "46e14267-1619-48bf-86af-521f00a65261", "consent_type": "analytics", "granted": true, - "granted_at": 1795107849, - "id": "205b38fe-ba7e-4a99-8744-e1ac9db6824f", + "granted_at": 1795125938, + "id": "94e4b032-ad9c-428c-b0c8-ba394a0082bf", "ip_address": "192.0.2.1", "partner_id": "partner_example", - "revoked_at": 1795107849 + "revoked_at": 1795125938 } ] } @@ -2808,7 +2818,7 @@ "integration_status": { "type": "IntegrationStatusResponse", "body": { - "request_id": "req_6325b0f5e83e", + "request_id": "req_188ac58bbdd9", "status": { "provider": "intervals_icu", "connected": false, @@ -2926,8 +2936,8 @@ "activity_brick": { "type": "Activity", "body": { - "id": "e18d4a10-4719-401d-87b0-1a620a9edcc0", - "athlete_id": "fc58aa29-780e-4d1f-a863-cf86d8b8a0e4", + "id": "d146b372-904d-424d-812a-c4488e2e19f6", + "athlete_id": "fa0c0324-26c7-4b58-bd66-5ebfc8b0f895", "partner_id": "partner_example", "type": "brick", "duration_min": 120, @@ -2947,9 +2957,9 @@ } ], "meal_before_min": 120, - "external_id": "sdk-python-88490c48-brick", - "created_at": 1795107864, - "updated_at": 1795107864 + "external_id": "sdk-python-54d7e3e2-brick", + "created_at": 1795125959, + "updated_at": 1795125959 } }, "activity_calculate_brick": { @@ -2963,7 +2973,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1795107865, + "calculated_at": 1795125959, "legs": [ { "duration_min": 90, @@ -3014,7 +3024,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1795107865, + "calculated_at": 1795125959, "legs": [ { "duration_min": 90, @@ -3746,8 +3756,8 @@ "body": { "imported": [ { - "id": "1a63b23b-3849-4fca-b9e6-c8e30d46ae1d", - "athlete_id": "fc58aa29-780e-4d1f-a863-cf86d8b8a0e4", + "id": "12218eb9-5de9-410b-89f7-54907d7dcbd6", + "athlete_id": "fa0c0324-26c7-4b58-bd66-5ebfc8b0f895", "partner_id": "partner_example", "type": "brick", "duration_min": 120, @@ -3767,7 +3777,7 @@ } ], "meal_before_min": 120, - "external_id": "sdk-python-88490c48-i-brick", + "external_id": "sdk-python-54d7e3e2-i-brick", "prescription": { "total_carb_g": 140, "total_sodium_mg": 1100, @@ -3775,7 +3785,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1795107872, + "calculated_at": 1795125974, "legs": [ { "duration_min": 90, @@ -3797,18 +3807,18 @@ } ] }, - "created_at": 1795107872, - "updated_at": 1795107872 + "created_at": 1795125973, + "updated_at": 1795125973 } ], "total": 1, "succeeded": 1, "failed": 0, - "request_id": "req_f0cee635ddd8", + "request_id": "req_d21e856fc533", "prescriptions": [ { "index": 0, - "activity_id": "1a63b23b-3849-4fca-b9e6-c8e30d46ae1d", + "activity_id": "12218eb9-5de9-410b-89f7-54907d7dcbd6", "result": { "tier": "full", "prescription": { @@ -3818,7 +3828,7 @@ "carb_g_per_hr": 70, "sodium_mg_per_hr": 550, "fluid_ml_per_hr": 700, - "calculated_at": 1795107872, + "calculated_at": 1795125974, "legs": [ { "duration_min": 90,