openapi: 3.2.0 info: title: Terra Admin API version: 2026.11.19 license: name: Apache-2.0 url: https://github.com/tryterra/openapi/blob/master/LICENSE description: |- Configure and inspect your Terra account, for people and agents, with an admin token minted through an RFC 8628 device flow approved on the dashboard. - The `{dev_id}` path segment is the only way to choose an environment. - Errors are RFC 7807 `application/problem+json` with a stable `code`. - Mutations accept an `Idempotency-Key` header and return `X-RateLimit-*` headers. - Product reads and replay actions also need a current entitlement (403 `entitlement_required`); billing, configuration and recovery keep their usual permissions. - A disabled environment returns 403 `environment_disabled`, and 503 `authorization_unavailable` means current authorization could not be checked. servers: - url: https://access.tryterra.co/api/v3/admin security: - adminToken: [] tags: - name: authentication summary: Authentication description: Get an admin token through the device flow or the OAuth authorization-code grant, and give it up again. x-displayName: Authentication - name: account summary: Account description: Your company record, its environments (dev-ids) and the products your account can use. x-displayName: Account - name: team summary: Team description: Invite, list and remove the people on your team. x-displayName: Team - name: billing summary: Billing description: Your subscription, invoices, payment method and usage. x-displayName: Billing - name: tokens-and-keys summary: Tokens and keys description: Admin tokens, data access tokens and each environment's API key. x-displayName: Tokens and keys - name: destinations summary: Destinations description: Where Terra sends your data, such as a webhook, a database or a storage bucket, and how healthy delivery is. x-displayName: Destinations - name: events summary: Events description: The webhook events sent to you, with their delivery status, and the event types they can carry. x-displayName: Events - name: unified-api summary: Unified API description: Which data the Unified API collects and how it is processed, and how the connection widget is set up. x-displayName: Unified API - name: sources summary: Sources description: The wearables and apps your Unified API users can connect, with their credentials and sign-in settings. x-displayName: Sources - name: users summary: Users description: Your Unified API users' connections and stored data, and synthetic test users whose data you can start and stop. x-displayName: Users - name: health-scores summary: Health Scores description: Health Scores computed from Unified API data. Turn scores on, configure them, and read their history and analytics. x-displayName: Health Scores - name: models summary: Models description: Models that run over your users' stored Unified API data. The catalogue of available models, and an environment's run history. x-displayName: Models - name: planned-workouts summary: Planned Workouts description: Planned Workouts sends workouts to your users' connected Unified API devices. The pace-unit metadata stored on those workouts. x-displayName: Planned Workouts - name: vantage summary: Vantage description: Configure Vantage for an environment (products, markets, webhook, API version), and inspect or simulate its orders, results and webhook events. x-displayName: Vantage - name: lab-reports summary: Lab Reports description: Configure Lab Reports for an environment. x-displayName: Lab Reports - name: doctor summary: Environment doctor description: Check an environment for problems that stop data reaching you. x-displayName: Environment doctor - name: documentation-search summary: Documentation search description: Ask a question in plain language and get an answer from Terra's published documentation. x-displayName: Documentation search paths: /auth/authorize: get: operationId: authorizeOAuth tags: - authentication summary: Begin an authorization-code grant with S256 PKCE description: |- Starts an OAuth authorization-code grant with S256 PKCE for a client identified by its client ID metadata document. - Validates the client and the exact registered redirect before any redirect; untrusted clients receive a local error page. - Consent is completed through the authenticated dashboard bridge. security: [] parameters: - name: client_id in: query required: true schema: type: string description: HTTPS client ID metadata document URL. - name: redirect_uri in: query required: true schema: type: string description: Registered redirect URI. - name: response_type in: query required: true schema: type: string enum: - code description: Authorization code response. - name: code_challenge in: query required: true schema: type: string description: Base64url SHA-256 of the verifier. - name: code_challenge_method in: query required: true schema: type: string enum: - S256 description: Required PKCE method. - name: resource in: query required: true style: form explode: true schema: type: array minItems: 1 items: type: string description: https://access.tryterra.co/api/v3/admin/mcp - name: scope in: query schema: type: string description: Space-separated admin scopes. An empty scope selects the MCP preset. - name: state in: query schema: type: string description: Opaque state echoed unchanged. - name: requested_dev_ids in: query schema: type: string description: Optional space-separated environment IDs. responses: '302': description: Dashboard consent redirect, or a client error redirect with state and iss. headers: Location: description: Redirect destination. schema: type: string '400': description: Client or redirect is untrusted; no redirect is issued. content: text/html: schema: type: string '503': description: Authorization-code flow is disabled (temporarily_unavailable JSON), or the client's metadata could not be fetched (an HTML page with Retry-After; no redirect is issued because the redirect URI is unverified). headers: Retry-After: schema: type: string description: Seconds to wait before retrying. content: application/json: schema: $ref: '#/components/schemas/OAuthError' text/html: schema: type: string /auth/device: post: operationId: startDeviceAuth tags: - authentication responses: '200': description: Device pairing started. content: application/json: schema: $ref: '#/components/schemas/DeviceStartResponse' example: device_code: kJ9…43-chars…Qw user_code: TERRA-K7MP-4WX2 verification_uri: https://dashboard.tryterra.co/cli/verify verification_uri_complete: https://dashboard.tryterra.co/cli/verify?code=TERRA-K7MP-4WX2 expires_in: 900 interval: 5 '400': description: invalid_request | invalid_scope (RFC 6749 §5.2 envelope). content: application/json: schema: $ref: '#/components/schemas/OAuthError' example: error: invalid_request error_description: client_id is required summary: Begin device-pairing auth (RFC 8628) security: [] requestBody: required: true content: application/x-www-form-urlencoded: schema: $ref: '#/components/schemas/DeviceStartFormRequest' description: |- Starts device pairing with a standard RFC 8628 §3.1 device authorization request. - Speaks only the OAuth wire format: a form-encoded body and a JSON `200` response with `Cache-Control: no-store`. - Errors use the RFC 6749 §5.2 error envelope. /auth/token: post: operationId: pollToken tags: - authentication responses: '200': description: Token minted (RFC 6749 §5.1). content: application/json: schema: $ref: '#/components/schemas/OAuthTokenResponse' example: access_token: terra_at_kJ9…shown-once…Qw token_type: Bearer expires_in: 2592000 scope: account:read providers:read events:read token_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a '400': description: authorization_pending | slow_down | access_denied | expired_token | invalid_request | unsupported_grant_type | invalid_grant | invalid_client (RFC 8628 §3.5 / RFC 6749 §5.2 envelope). content: application/json: schema: $ref: '#/components/schemas/OAuthError' example: error: authorization_pending error_description: authorization pending '401': description: Header client authentication failed (RFC 6749 §5.2). headers: WWW-Authenticate: schema: type: string content: application/json: schema: $ref: '#/components/schemas/OAuthError' '503': description: temporarily_unavailable with Retry-After when the authorization-code flow is disabled, client metadata or keys cannot be fetched, or assertion replay protection is unavailable. headers: Retry-After: schema: type: string content: application/json: schema: $ref: '#/components/schemas/OAuthError' summary: Exchange an authorization code or poll a device grant security: [] requestBody: required: true content: application/x-www-form-urlencoded: schema: anyOf: - $ref: '#/components/schemas/TokenPollFormRequest' - $ref: '#/components/schemas/AuthorizationCodeFormRequest' - $ref: '#/components/schemas/AuthorizationCodeAssertionFormRequest' description: |- Exchanges an authorization code for a token, or polls a device grant, speaking only the OAuth wire format. - `authorization_code` takes `code`, an S256 `code_verifier`, the canonical MCP resource and an optional exact `redirect_uri`. - The client authenticates by its declared method: `none` with a CIMD `client_id`, or `private_key_jwt` for CIMD clients that declare it, in which case `client_id` may be omitted. - The device grant is the RFC 8628 §3.4 request with `grant_type` `urn:ietf:params:oauth:grant-type:device_code`. - Form-encoded body; RFC 6749 §5.1 token response, §5.2/§3.5 error envelope, `Cache-Control: no-store`. - No refresh tokens are issued; rotate with `POST /tokens/self/rotate`. /auth/scopes: get: operationId: getScopeRegistry tags: - authentication summary: List the scopes a token can be granted description: |- Returns the scope registry this deployment grants from, with the same vocabulary, planes, risk lists and presets `securitySchemes.adminToken` carries, so a client or approval page can show and request scopes without pinning a copy of this document. - Needs no token. security: [] responses: '200': description: The scope registry. content: application/json: schema: $ref: '#/components/schemas/ScopeRegistry' example: scopes: account:read: See your account details and environment IDs. keys:write: Replace your API key. Anything using the old key will stop working. data:read: 'Data plane: read stored end-user health data (activity, sleep, body, …).' planes: account:read: admin keys:write: admin data:read: data dangerous: keys:write: access sensitive: [] account_level: - account:read presets: - name: Read only summary: Auditing, onboarding a teammate, or a demo. scopes: - account:read '429': $ref: '#/components/responses/RateLimited' /docs/ask: post: operationId: askDocs tags: - documentation-search summary: Ask a question about Terra and get an answer from the documentation description: |- Answers a question about Terra from the published documentation and cites the pages the answer drew on. - Needs no scope: the search reads no account data, so any valid token may ask. - An answer with an empty `sources` array was not grounded in the documentation; that is a 200, not an error. security: - adminToken: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/DocsAskRequest' responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DocsAskResponse' example: answer: Call generateWidgetSession and open the URL it returns [1]. confidence: high sources: - label: '1' title: Generate a widget session description: Create a session and redirect the user to the widget. url: https://docs.tryterra.co/widget type: documentation breadcrumbs: - Docs - Authentication '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /me: get: operationId: getMe tags: - tokens-and-keys responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/MeResponse' example: token_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a kind: admin customer_id: cus_9f3k2m scopes: - account:read - providers:read dev_ids: - prod-app-x81LmQ name: terra-cli on alex-mbp created_via: dashboard expires_at: '2026-08-02T09:15:00Z' grant_anchor_at: '2026-07-03T09:15:00Z' last_used_at: '2026-07-03T09:15:00Z' user: user_id: usr_8f2a1c email: alex@acme.example verified: true name: Alex Doe phone_number: '+15551234567' created_at: '2025-01-10T09:00:00Z' last_login: '2026-07-01T09:00:00Z' company_id: cus_9f3k2m role: admin '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' summary: Introspect the calling token security: - adminToken: [] description: |- Returns what the calling token holds, and the user who minted it when the token can see them. - Any valid token may call it; no scope is needed. - `user` requires `account:read`, since the minting user's email, phone and role are the same PII that `GET /team/members/{user_id}` gates. Without that scope, `user` is `null`. patch: operationId: patchMe tags: - tokens-and-keys responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - type: object properties: user: $ref: '#/components/schemas/DashboardUser' required: - user - $ref: '#/components/schemas/DryRunResult' example: user: user_id: usr_8f2a1c email: alex@acme.example verified: true name: Alex Doe (she/her) phone_number: '+15551234567' created_at: '2025-01-10T09:00:00Z' last_login: '2026-07-01T09:00:00Z' company_id: cus_9f3k2m role: admin '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Update the calling principal's own dashboard user profile description: |- Updates the profile of the dashboard user the calling token belongs to. - Strictly self-scoped, but needs `account:write` because a state change requires a write scope; `account:write` is in the default mint set, so only explicitly read-narrowed tokens lose self-edit. - `404 not_found` when the token has no resolvable own dashboard user (see `DashboardUser`). security: - adminToken: - account:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PatchMeRequest' /tokens/self: delete: operationId: revokeSelf tags: - tokens-and-keys responses: '200': description: DryRunResult when ?dry_run=true. The preview describes the token the call would revoke, which is the calling token itself. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: revoke preview: token_id: 1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f kind: admin name: terra-cli on alex-mbp scopes: - account:read dev_ids: null created_by: alex@acme.test created_via: device created_at: '2026-06-24T10:00:00Z' expires_at: '2026-07-24T10:00:00Z' last_used_at: '2026-06-24T11:02:00Z' revoked_at: null '204': description: Revoked. '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' summary: Revoke the calling token description: |- Revokes the token making the call. - Needs no scope: a token is always allowed to give up its own authority. - Revocation is checked per request, so this is effectively the token's last call; anything after it is a 401. - To revoke a different token, use `DELETE /tokens/{token_id}`, which needs `tokens:admin`. security: - adminToken: [] parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /tokens/self/rotate: post: operationId: rotateSelf tags: - tokens-and-keys responses: '200': description: DryRunResult when ?dry_run=true. The preview carries the clamped expiry the successor would get (a rotation near the grant anchor yields a short token); it omits token_id and token, which do not exist until the swap runs. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: rotate preview: kind: admin name: ci runner scopes: - account:read created_at: '2026-06-24T10:00:00Z' expires_at: '2026-07-24T10:00:00Z' last_used_at: null revoked_at: null rotated_from: 1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f will_return_token: true '201': description: Rotated. content: application/json: schema: $ref: '#/components/schemas/TokenResponse' example: token: terra_at_Nw2…shown-once…Rk token_id: 1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f kind: admin customer_id: cus_9f3k2m scopes: - account:read - providers:read dev_ids: null expires_at: '2026-08-02T09:15:00Z' name: terra-cli on alex-mbp '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' summary: Replace the token you're signed in with description: |- Mints a replacement for the calling token and returns the new bearer once. - The response is the only copy of the bearer: a caller that loses it has to pair again. - Available only inside the token's grant window; outside it the request conflicts instead of minting anything. - Read `expires_at`, `scopes` and `dev_ids` off the response rather than assuming they match the old token. security: - adminToken: [] parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /tokens: get: operationId: listTokens tags: - tokens-and-keys responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/TokenSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - token_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a kind: admin name: terra-cli on alex-mbp scopes: - account:read dev_ids: null created_by: alex@acme.com created_via: device_flow created_at: '2026-07-03T09:15:00Z' expires_at: '2026-08-02T09:15:00Z' last_used_at: '2026-07-03T09:15:00Z' revoked_at: null - token_id: 2b3c4d5e-6f70-4a81-92b3-c4d5e6f70a81 kind: data name: sdk-auth-only scopes: - auth:write dev_ids: - prod-app-x81LmQ created_by: token:8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a created_via: admin_api created_at: '2026-07-03T09:15:00Z' expires_at: '2028-07-03T09:15:00Z' last_used_at: null revoked_at: null has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' summary: List the account's tokens description: |- Lists metadata for the account's admin and data tokens. - No bearer is ever returned: an admin token's is shown only when it is minted or rotated, and a data token's is re-shown by `GET /environments/{dev_id}/tokens/{token_id}/secret`, which needs `keys:read`. - Short-lived dashboard session tokens never appear. - A revoked token stays listed with `revoked_at` set, so filter on it rather than assuming every row is live. security: - adminToken: - tokens:admin /tokens/{token_id}: delete: operationId: revokeToken tags: - tokens-and-keys responses: '200': description: DryRunResult when ?dry_run=true. The preview is the token that would be revoked. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: revoke preview: token_id: 1c2d3e4f-5a6b-4c7d-8e9f-0a1b2c3d4e5f kind: admin name: ci runner scopes: - account:read created_at: '2026-06-24T10:00:00Z' expires_at: '2026-07-24T10:00:00Z' last_used_at: null revoked_at: null '204': description: Revoked. '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Revoke an access token description: |- Revokes one of the account's tokens by id, effective immediately. - Validation happens per request, so the revoked token's next call fails. - 404 when no token with that id belongs to this account, whether it never existed or is someone else's. - Revoking the calling token works here too; `DELETE /tokens/self` does it without `tokens:admin`. security: - adminToken: - tokens:admin parameters: - name: token_id in: path required: true schema: type: string format: uuid description: The token to act on, by the id its creation returned. The token value itself is never accepted here. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /company: get: operationId: getCompany tags: - account responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/AccountSummary' example: customer_id: cus_9f3k2m dev_id_count: 2 company: company_id: cus_9f3k2m name: Acme Fitness billing_email: billing@acme.example website_url: https://acme.example learn_about_us: search onboarded: true user_flow_done: true billing: linked: true '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' summary: Account summary description: |- Returns the account's customer id, how many dev-ids it has, and its company profile. - `company` is null when the account has no company record yet, and the profile never carries the billing columns. - `billing` reports only whether a billing account is linked, never its identifiers, and is null exactly when `company` is null. - `dev_id_count` is only a count; the dev-ids themselves are on `GET /environments`. security: - adminToken: - account:read patch: operationId: patchCompany tags: - account responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - type: object properties: company: $ref: '#/components/schemas/CompanyProfile' required: - company - $ref: '#/components/schemas/DryRunResult' example: company: company_id: cus_9f3k2m name: Acme Fitness (Inc.) billing_email: billing@acme.example onboarded: true '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Update company profile description: |- Updates the company profile, leaving omitted fields unchanged. - Send at least one field. - Unknown fields, `created_at` and the billing columns (`stripe_customer_id`, `stripe_subscription_id`, `stripe_metering_type`) are rejected with 400 rather than quietly ignored, so a profile read cannot be sent straight back as a write. security: - adminToken: - account:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PatchCompanyRequest' /environments: get: operationId: listEnvironments tags: - account responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/DevSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - dev_id: prod-app-x81LmQ name: Production label: prod active: true billable: true is_production: true profile: dev_id: prod-app-x81LmQ company_id: cus_9f3k2m name: Production billable: true widget_config: null widget_name: null app_logo: null - dev_id: staging-app-b52TnP name: Staging active: true billable: false is_production: false profile: null has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' summary: List the account's dev-ids description: |- Lists every dev-id on the account, cursor-paginated, each with its profile row inlined. - `profile` is null for a dev-id that has none. - No credential material appears here, masked or otherwise; that is on `GET /environments/{dev_id}`. security: - adminToken: - account:read /entitlements: get: operationId: listEntitlements tags: - account responses: '200': description: OK headers: Terra-Entitlements-View: description: Present as effective when the selected rollout reads live staff grants and local capability sources; absent on the legacy raw view. schema: type: string enum: - effective content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/Entitlement' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - capability: vantage source: stripe_entitlement - capability: streaming source: stripe_entitlement - capability: pass_connections source: manual has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List feature entitlements description: |- Lists the capabilities this account holds, one row each, with `source` recording how each was granted (reconciled from the subscription, or set by hand). - Account-level and read-only. - Only granted capabilities appear, so a locked feature is an absence rather than a row saying false. security: - adminToken: - entitlements:read /billing/invoice-details: post: operationId: updateInvoiceDetails summary: Set invoice billing details description: |- Sets the legal entity name and EU, UK or Swiss VAT number on the authenticated canonical billing customer, creating that customer for a first purchase. - Both freeze onto an invoice at finalization, so set them before subscribing. - A VAT number replaces any other of the same type. tags: - billing security: - adminToken: - billing:write parameters: - $ref: '#/components/parameters/DryRun' responses: '200': description: Completed, or a preview when dry_run is true. content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BillingState' - $ref: '#/components/schemas/DryRunResult' example: state: ok '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/InvoiceDetailsRequest' /billing/invoices/pay: post: operationId: payInvoice summary: Pay an invoice description: |- Pays only the authenticated customer's open invoice, using Stripe payment-method precedence. - An already paid invoice returns success. - When the payment needs authentication, the response returns a hosted URL. tags: - billing security: - adminToken: - billing:write parameters: - $ref: '#/components/parameters/DryRun' responses: '200': description: Completed, or a preview when dry_run is true. content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BillingState' - $ref: '#/components/schemas/DryRunResult' example: state: ok '202': description: Payment requires confirmation on the returned payment_url. content: application/json: schema: $ref: '#/components/schemas/BillingState' example: state: requires_action payment_url: https://invoice.stripe.com/i/example '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PayInvoiceRequest' /billing/subscriptions: get: operationId: listSubscriptions tags: - billing responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/SubscriptionSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - id: sub_1PXk9f2c status: active cancel_at_period_end: false collection_method: charge_automatically cancel_at: null pause_collection: null items: - name: Growth currency: usd billing_scheme: per_unit unit_amount: 49900 quantity: 1 recurring: interval: month interval_count: 1 usage_type: licensed current_period_start: '2026-11-01T00:00:00Z' current_period_end: '2026-12-01T00:00:00Z' scopes: - api - growth has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List subscriptions description: |- Lists the account's subscriptions, cursor-paginated. - `status` alone does not say whether a plan is ending: a subscription scheduled to stop is still active until the period closes, which `cancel_at_period_end` reports. - `collection_method` says whether the card on file is charged automatically or an invoice is sent. - `scopes` holds billing plan labels for `active`, `trialing`, `past_due` and `unpaid` subscriptions; other states return an empty array. - These labels never authorize products: use `GET /entitlements`. security: - adminToken: - billing:read post: operationId: subscribe tags: - billing responses: '200': description: OK (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BillingState' - $ref: '#/components/schemas/DryRunResult' example: state: ok '202': description: Payment confirmation is required before the plan changes. The response carries a payment_url and/or client_secret. Use the hosted page or embedded Stripe confirmation to complete payment, after which the subscription activates. content: application/json: schema: $ref: '#/components/schemas/BillingState' example: state: requires_action payment_url: https://invoice.stripe.com/i/example '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Add or change a plan description: |- Adds a plan or changes the current one; the admin API owns the scope-to-price mapping, eligibility checks and Stripe writes. - Accepts an admin token with explicitly approved `billing:write`, or a dashboard session with `billing:write`. Device-flow approval requires an account admin; no dashboard session is required when using the approved token. - A committed `202` means payment is pending, with a hosted `payment_url` and/or an embedded Stripe invoice confirmation `client_secret`. Never log the client secret or cache it as account data. - Product access and provisioning follow the existing Stripe webhook settlement. Annual event plans also require a deferred monthly metered overage subscription after payment. - Send an `Idempotency-Key` so a successful response can be replayed on retry. - With `?dry_run=true` the same planning runs and nothing is subscribed. The preview carries the action (`would` is `create` or `update`), the price items it would add or remove, the proration date and behaviour, whether an annual plan defers its metered overage, and an invoice estimate of what the change would bill now. The estimate is current Stripe state rather than a reservation and cannot say whether the card will need a challenge; the commit recalculates it. security: - adminToken: - billing:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SubscribeRequest' /billing/invoices: get: operationId: listInvoices tags: - billing responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/InvoiceSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - id: in_1PXk9f2c status: paid amount_due: 49900 currency: usd created_at: '2026-07-03T09:15:00Z' hosted_invoice_url: https://invoice.stripe.com/i/acct_x/in_1PXk9f2c has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List invoices description: |- Lists the account's invoices, cursor-paginated, each with an amount, a currency, a status and, when they exist, links to the hosted invoice and its PDF. - Every field of a row is optional, so treat a missing link as normal rather than as an error. security: - adminToken: - billing:read /billing/invoices/previews: get: operationId: listInvoicePreviews tags: - billing responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/InvoiceSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: [] has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Preview each billable subscription description: |- Returns a complete upcoming invoice summary for each current billable subscription, each row naming its subscription. - Includes past-due and unpaid subscriptions; excludes voided collection pauses. - Neither charges nor creates an invoice. security: - adminToken: - billing:read /billing/payment-method: get: operationId: getPaymentMethod tags: - billing responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/PaymentMethodSummary' example: has_card: true brand: visa exp_month: 11 exp_year: 2027 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Default payment method (masked) description: |- Returns the account's default payment method with card details masked. - Picks the subscription default, then the customer default, then the first attached method. - The safe card fields returned are brand, `last4` and expiry. - Branch on `has_card`: when it is `false` the account has no card on file and the other fields are absent. security: - adminToken: - billing:read /billing/usage: get: operationId: getUsage tags: - billing summary: Current metered usage by subscription item description: |- Returns current metered usage per subscription item; rows preserve their own currencies and independent periods, and no account-wide total is computed. - Includes `active`, `trialing`, `past_due` and `unpaid` subscriptions, collection-paused items included. - Native subscription periods stay separate from the enclosing minute-aligned measurement windows Stripe requires; UTC daily edge buckets can extend beyond the period. - `minute_envelope` amounts are estimates for that measurement window, never exact billed-period quantities or invoice charges. - Pricing decimals are exact strings in currency minor units; unavailable pricing is `null`. - Meter data is eventually consistent. security: - adminToken: - billing:read responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/CurrentUsageResponse' example: rows: [] meters: {} '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /billing/subscriptions/cancel-incomplete: post: operationId: cancelIncomplete tags: - billing requestBody: required: false content: application/json: schema: type: object properties: only_operation_keys: type: boolean default: false description: Select only incomplete subscriptions belonging to the supplied operation keys. Used by payment-failure callbacks so an older challenge cannot cancel a newer purchase. operation_keys: type: array maxItems: 100 items: type: string minLength: 1 maxLength: 255 description: Candidate subscription Idempotency-Key values to acknowledge only after their owned subscription is canceled or incomplete_expired. responses: '200': description: OK (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BillingState' - $ref: '#/components/schemas/DryRunResult' example: state: ok '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Cancel unfinished subscriptions description: |- Cancels the canonical customer's `incomplete` subscriptions, read across every page; terminal `incomplete_expired` subscriptions are excluded. - Accepts an admin token with explicitly approved `billing:write`, or a dashboard session with `billing:write`. Device-flow approval requires an account admin; no dashboard session is required when using the approved token. - Cancellation is sequential and can partially complete if a later Stripe request fails. - The commit rechecks ownership and status before each cancellation, since Stripe can move one out of `incomplete` between the preview and the commit. - With `?dry_run=true` the preview lists the subscriptions the call would cancel, read with the same selection, and cancels nothing; `would` is `cancel`, or `noop` when none are incomplete. security: - adminToken: - billing:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /environments/{dev_id}: get: operationId: getEnvironment tags: - account responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DevDetail' example: dev_id: prod-app-x81LmQ name: Production active: true billable: true is_production: true profile: dev_id: prod-app-x81LmQ company_id: cus_9f3k2m name: Production billable: true widget_config: null widget_name: null app_logo: null api_key_masked: '****k2Qw' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Dev-id detail (masked secrets) description: |- Returns a dev-id's detail, with both credentials masked to their last few characters. - The unmasked material is on `GET /environments/{dev_id}/api-key`, which needs `keys:read`. - `profile` is null for a dev-id with no profile row yet, which the POST on the environments collection creates. security: - adminToken: - account:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/unified-api/widget/config: get: operationId: getWidgetConfig tags: - unified-api responses: '200': description: OK content: application/json: schema: type: object properties: widget: $ref: '#/components/schemas/WidgetConfig' required: - widget example: widget: widget_config: theme: dark widget_name: Acme Connect app_logo: https://cdn.tryterra.co/acme/logo.png '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Get the dev-id's widget config description: |- Returns the branding and configuration for the dev-id's connect widget. - The configuration is the inlined `widget_config` document; `widget_config_url` is retired and no longer returned. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' put: operationId: setWidgetConfig tags: - unified-api responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - type: object properties: widget: $ref: '#/components/schemas/WidgetConfig' required: - widget - $ref: '#/components/schemas/DryRunResult' example: widget: widget_config: theme: dark widget_name: Acme Connect app_logo: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Replace the dev-id's widget config (full replace) description: |- Replaces the dev-id's whole widget config document rather than merging into it. - Any field left out of the body is cleared, so read the current config with `GET /environments/{dev_id}/unified-api/widget/config` first and send it back with the edit applied. - `widget_config_url` is retired and rejected with 400. security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/WidgetConfig' /environments/{dev_id}/api-key: get: operationId: getEnvironmentApiKey tags: - tokens-and-keys responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DevKeys' example: dev_id: prod-app-x81LmQ api_key: 6f8c…full-secret…2a1b '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Full credential material (audited) description: |- Returns the environment's API key in plaintext and audits the read. - Every other read in this API masks the key, which is why this needs `keys:read`, not `account:read`. - An environment whose key was revoked has none: 404 `api_key_not_found`. `POST /environments/{dev_id}/api-key/rotate` mints a new one. - Webhook signing secrets are per webhook: `GET /environments/{dev_id}/unified-api/destinations/{destination_id}/secrets` and, for Vantage, `GET /environments/{dev_id}/vantage/webhook/secrets`. - For new work prefer per-environment data tokens, minted and revoked independently instead of shared. security: - adminToken: - keys:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/unified-api/destination-types: get: operationId: listDestinationTypes tags: - destinations summary: List destination types description: Lists every type a destination can be created as, with the configuration fields it takes, which of them it needs to deliver and which are secrets. The list is identical for every environment. security: - adminToken: - destinations:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The destination types. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/DestinationType' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - type: webhook display_name: Webhook icon_url: https://api.tryterra.co/static/assets/img/destination_icons/webhook.webp config_fields: - name: url type: string required: true secret: false enum: null - name: delivery type: string required: false secret: false enum: - push - ping has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/unified-api/source-types: get: operationId: listSourceTypes tags: - sources responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/SourceType' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - provider: apple_health display_name: Apple Health icon: https://api.tryterra.co/v2/static/icons/apple.webp auth_type: sdk setup: sdk data_types: - activity - athlete - body - daily - health_observation - menstruation - nutrition - sleep deprecated: false byo_supported: false custom_scopes_supported: false customer_credentials_required: false custom_credentials_allowed: true - provider: garmin display_name: Garmin icon: https://api.tryterra.co/v2/static/icons/garmin.webp auth_type: oauth1 setup: api_keys_managed data_types: - activity - athlete - body - daily - planned_workout - sleep deprecated: false byo_supported: false custom_scopes_supported: false customer_credentials_required: false custom_credentials_allowed: true has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List source types description: |- Lists every unified-api provider this environment can enable, described by its provider configuration and sorted by slug. - Each row names the provider by the slug sources use, so a source joins its source type on `provider`. - Whether and how the environment has enabled a provider is on `GET /environments/{dev_id}/unified-api/sources`. - A provider being retired is listed only for environments with access to it. - The list is complete in one response. security: - adminToken: - providers:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/unified-api/sources: get: operationId: listSources tags: - sources responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/Source' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - provider: garmin active: true auth_redirect_url: https://api.acme.com/terra/callback auth_variant: byo - provider: apple_health active: false auth_redirect_url: null auth_variant: standard has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: List sources description: |- Lists the unified-api providers enabled in this environment, with each one's slug, whether it is `active`, its auth redirect URL, and whether users connect through Terra's OAuth app or your own by default. - A paused provider is listed with `active: false`. Deprecated providers are listed; internal providers are not. - Every listed provider can be addressed under `/environments/{dev_id}/unified-api/sources/{provider}`. - Credentials and custom scopes are on their own sub-resources; capabilities and deprecation are on the source type. security: - adminToken: - providers:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/unified-api/sources/batch-enable: post: operationId: batchEnableSources tags: - sources responses: '200': description: Enabled (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BatchEnabledSources' - $ref: '#/components/schemas/DryRunResult' example: data: - provider: garmin active: true auth_redirect_url: https://api.acme.com/terra/callback auth_variant: standard - provider: oura active: true auth_redirect_url: https://api.tryterra.co/v2/auth/oura auth_variant: standard '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' summary: Enable several providers description: |- Enables several providers in one transaction, so either every provider is enabled or none is, and returns each provider's source in request order. - Each is enabled as `PUT /environments/{dev_id}/unified-api/sources/{provider}` does it: no credentials, no scopes, an already-enabled one is left as it is and a paused one is resumed, so a repeat call is safe. - Every provider is checked before anything is written. - When every provider is already active, the preview's `would` is `noop` and nothing is written. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchEnableSourcesRequest' example: providers: - garmin - oura /environments/{dev_id}/unified-api/sources/batch-disable: post: operationId: batchDisableSources tags: - sources responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: disable preview: data: - provider: garmin - provider: oura '204': description: Disabled. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Disable several providers description: |- Disables several providers in one transaction, so either every provider is disabled or none is. - Each is disabled as `DELETE /environments/{dev_id}/unified-api/sources/{provider}` does it: nothing is collected from it while it is off, and enabling it again does not backfill the gap. - Every provider is checked before anything is written. - `POST /environments/{dev_id}/unified-api/sources/batch-enable` is the inverse. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchDisableSourcesRequest' example: providers: - garmin - oura /environments/{dev_id}/unified-api/sources/{provider}: put: operationId: enableSource tags: - sources responses: '200': description: Enabled (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/Source' - $ref: '#/components/schemas/DryRunResult' example: provider: garmin active: true auth_redirect_url: https://api.acme.com/terra/callback auth_variant: standard '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' summary: Enable a provider (idempotent) description: |- Enables a provider in this environment and returns its source. - No credentials or scopes are configured, so until custom credentials are set end users authorize against Terra's own OAuth app, which `terra_owned` reports on the credentials read. - A paused provider is resumed, and one that was disabled comes back with its credentials. - A repeat call is not an error: its preview's `would` is `noop`, and it writes nothing. - A deprecated provider needs its private preview on this environment, or the call is a 422, in a preview too. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' patch: operationId: updateSource tags: - sources responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/Source' - $ref: '#/components/schemas/DryRunResult' example: provider: garmin active: false auth_redirect_url: https://api.acme.com/terra/callback auth_variant: byo '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' summary: Update a provider description: |- Pauses or resumes an enabled provider, or changes how its users connect by default. - Pausing refuses new connections but keeps the provider listed with its credentials, scopes and existing connections. `DELETE` on this path removes it instead. - `auth_variant: byo` needs `byo_supported` on the source type, or is a 422. - Send at least one field. - A deprecated provider can always be paused, but resuming it or changing its auth variant needs its private preview on this environment, or the call is a 422. - When nothing would change, the preview's `would` is `noop` and nothing is written. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: 'The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. A provider that is not enabled is a 404: enable it first with the PUT on this path.' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PatchSourceRequest' examples: pause: summary: Pause a provider value: active: false byo: summary: Connect users through your own OAuth app value: auth_variant: byo delete: operationId: disableSource tags: - sources responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: disable preview: provider: garmin '204': description: Disabled. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Disable a provider description: |- Disables a provider, taking it out of this environment's enabled set. - Nothing is collected from it while it is off, and enabling it again does not backfill the gap. - `PUT` on this path is the inverse. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /environments/{dev_id}/unified-api/sources/{provider}/credentials: get: operationId: getSourceCredentials tags: - sources responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ProviderCredentials' example: provider: garmin has_credentials: true terra_owned: false credential: provider_client_id: acme-garmin-oauth provider_client_secret_masked: '****9876' redirect_url: https://auth.acme.com/auth/garmin/oauth2 sandbox: false oauth_version: '2' has_verification_secret: false secret_ref: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Provider OAuth credentials (masked) description: |- Returns this environment's own OAuth app for the provider, if it has one: the client id with the secret masked to its last digits, the redirect URL, the sandbox flag, the OAuth version and whether a webhook verification secret is stored. - `credential` is null when none is set or when the provider runs on Terra's own app, which `terra_owned` reports. - The OAuth version is null for providers that do not sign in with OAuth. - A paused provider keeps its credentials and reports them here. - Secrets are write-only and are never readable here. security: - adminToken: - providers:read parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. put: operationId: setSourceCredentials tags: - sources summary: Set custom sign-in settings for a wearable or app description: |- Replaces this environment's own OAuth credentials for the provider, so auth runs against your app. Idempotent. - An omitted `redirect_url`, verification secret or `sandbox` goes back to its default; `PATCH` on this path keeps unsent fields. - A `redirect_url` must be on a Terra domain or on a custom domain set up for this provider in this or another of your environments within the token's audience, or the call is a 400; a 503 means the custom domain could not be checked. - With `secret_ref`, Terra test-reads the store before saving: a setup it cannot read is a 400 saying which step failed, an unreachable store is a 503, and a source or deployment without the option is a 422. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ProviderCredentialWrite' responses: '200': description: Stored (or DryRunResult when ?dry_run=true; the client secret is masked in both). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/ProviderCredentials' - $ref: '#/components/schemas/DryRunResult' example: provider: garmin has_credentials: true terra_owned: false credential: provider_client_id: acme-garmin-oauth provider_client_secret_masked: '****4321' redirect_url: https://api.tryterra.co/v2/auth/garmin sandbox: false oauth_version: '1' has_verification_secret: false secret_ref: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' patch: operationId: updateSourceCredentials tags: - sources summary: Update custom sign-in settings for a wearable or app description: |- Changes the sent fields of this environment's own OAuth credentials for the provider and keeps every other stored value. - Send at least one field. An empty `client_secret` or `verification_secret` is a 400; omit it to keep the stored value. - The merged credential passes every check `PUT` on this path runs, including, for Garmin, a check against Garmin with the stored secret; the redirect host check runs when `redirect_url` is sent. - A credential read from a secret store keeps reading it there when neither `secret_ref` nor `client_secret` is sent. - When the merged credential equals the stored one, nothing is written. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. A provider without your own credentials is a 404; set them with the PUT on this path first. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ProviderCredentialPatch' examples: rotate: summary: Rotate the client secret value: client_secret: new-client-secret redirect: summary: Move the redirect to a custom domain value: redirect_url: https://auth.acme.com/auth/strava responses: '200': description: Updated (or DryRunResult when ?dry_run=true; the client secret is masked in both). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/ProviderCredentials' - $ref: '#/components/schemas/DryRunResult' example: provider: strava has_credentials: true terra_owned: false credential: provider_client_id: acme-strava-oauth provider_client_secret_masked: '****4321' redirect_url: https://auth.acme.com/auth/strava sandbox: false oauth_version: '2' has_verification_secret: true secret_ref: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/unified-api/sources/{provider}/domain: get: operationId: getSourceDomain tags: - sources responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/SourceDomain' example: provider: whoop hostname: whoop.acme.com state: ACTIVE reason: null detail: null dns_record: type: A name: whoop.acme.com value: 34.120.0.1 resolved_ip: 34.120.0.1 resolved_ips: - 34.120.0.1 serving: true expires_at: '2027-01-01T00:00:00Z' shared: false redirect_served: true '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: A provider's custom domain description: |- Returns the subdomain this environment set up for the provider's OAuth redirect (and, for Garmin and Strava, its webhooks): the A record to publish, the certificate's state, and whether the edge already serves it. - The domain is live when `state` is `ACTIVE` and `serving` is true. `FAILED`, or a reason such as `CAA`, names what to fix. - With none of its own, a domain another of your environments within the token's audience set up, which this one's stored redirect is on, is returned with `shared: true`. No domain is a 404. - Each call looks the hostname up in DNS and makes a TLS request to it, so poll every 5 seconds or slower. - 503 `service_unavailable`: custom domains are not available on this deployment; 503 `dependency_failed`: the certificate service did not answer. security: - adminToken: - providers:read parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. whoop. Case does not matter. An unrecognised provider is a 400, and one that does not use a custom domain (anything but whoop, dexcom, dexcom_eu, strava and garmin) is a 422. The provider does not need to be enabled. put: operationId: setSourceDomain tags: - sources responses: '200': description: Already set, replacing the current hostname, or reusing another of your environments' domain (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/SourceDomain' - $ref: '#/components/schemas/DryRunResult' example: provider: whoop hostname: whoop.acme.com state: ACTIVE reason: null detail: null dns_record: type: A name: whoop.acme.com value: 34.120.0.1 resolved_ip: 34.120.0.1 resolved_ips: - 34.120.0.1 serving: true expires_at: '2027-01-01T00:00:00Z' shared: false redirect_served: true '201': description: A certificate is being provisioned for the hostname. content: application/json: schema: $ref: '#/components/schemas/SourceDomain' example: provider: whoop hostname: whoop.acme.com state: PROVISIONING reason: null detail: null dns_record: type: A name: whoop.acme.com value: 34.120.0.1 resolved_ip: null resolved_ips: [] serving: false expires_at: null shared: false redirect_served: false '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Set a provider's custom domain description: |- Claims a subdomain you own for the provider, starts its certificate, and returns the A record to publish at your DNS provider; Terra cannot publish it for you. - Poll `GET` on this path until live, then point `redirect_url` at it through the credentials `PUT` or `PATCH`. - Sending the hostname already set is not an error and changes nothing; one another of your environments within the token's audience set up for this provider is reused, with `shared: true`. - A different hostname replaces the current one only once nothing uses the old one: another of your environments redirecting to it, or Garmin webhooks pointing at it, is a 409 and nothing changes. The check covers every environment of the account, naming one only within the token's audience. - A hostname you use for a different provider, or one another account uses, is a 409. - A new certificate returns 201, anything else 200, with the domain as `GET` returns it minus the DNS and TLS probes. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. whoop. Case does not matter. An unrecognised provider is a 400, and one that does not use a custom domain (anything but whoop, dexcom, dexcom_eu, strava and garmin) is a 422. The provider does not need to be enabled. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetSourceDomainRequest' examples: claim: summary: Claim a subdomain for WHOOP value: hostname: whoop.acme.com delete: operationId: deleteSourceDomain tags: - sources responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: delete preview: provider: whoop hostname: whoop.acme.com '204': description: Released, or this environment had no domain of its own. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Release a provider's custom domain description: |- Releases the certificate for this environment's custom domain for the provider, after which OAuth redirects and webhooks on the hostname stop working. - It is a 409 while another of your environments still redirects to the hostname, naming it only when the token's audience includes it, or, for Garmin, while Garmin webhooks still point at it; a 503 means Garmin could not be read to check. - A domain another of your environments set up is never released from here, so an environment with none of its own gets a 204 and nothing changes. - The preview runs the same checks. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. whoop. Case does not matter. An unrecognised provider is a 400, and one that does not use a custom domain (anything but whoop, dexcom, dexcom_eu, strava and garmin) is a 422. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /environments/{dev_id}/unified-api/sources/{provider}/scopes: get: operationId: getSourceScopes tags: - sources responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ProviderScopes' example: provider: fitbit customised: true scopes: - scope: activity name: Activity description: Steps and workouts required: true enabled: true - scope: heartrate name: Heart rate description: Continuous heart rate required: false enabled: true - scope: location name: Location description: GPS routes required: false enabled: false '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Provider OAuth scopes description: |- Lists every scope the provider can request, sorted by scope. - A required scope is always requested. - `enabled` says whether a new connection's OAuth request asks for the scope today: the environment's own choice when `customised` is true, and otherwise the scopes its selected data types need. security: - adminToken: - providers:read parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. The provider must be enabled; otherwise this is a 404. put: operationId: setSourceScopes tags: - sources responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/ProviderScopes' - $ref: '#/components/schemas/DryRunResult' example: provider: fitbit customised: true scopes: - scope: activity name: Activity description: Steps and workouts required: true enabled: true - scope: heartrate name: Heart rate description: Continuous heart rate required: false enabled: true - scope: location name: Location description: GPS routes required: false enabled: true '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Set custom OAuth scopes description: |- Sets the scopes this environment requests from the provider to its required scopes plus the optional ones in the body, replacing any earlier choice. - Every scope the provider does not accept is named in the 400, and then nothing is stored. - To go back to the scopes the selected data types need, use `DELETE` on this path. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. The provider must be enabled. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ScopesRequest' delete: operationId: resetSourceScopes tags: - sources responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: delete preview: provider: fitbit customised: false scopes: - scope: activity name: Activity description: Steps and workouts required: true enabled: true - scope: heartrate name: Heart rate description: Continuous heart rate required: false enabled: false - scope: location name: Location description: GPS routes required: false enabled: false '204': description: Reset, or there was nothing to reset. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Reset custom OAuth scopes description: |- Removes this environment's own scope choice for the provider, so new connections request the scopes its selected data types need. - Existing connections keep the scopes they consented to. - Resetting a provider with no custom scopes succeeds and changes nothing; its preview says `noop`. - A `?dry_run=true` preview shows the scopes `GET` on this path will then report. security: - adminToken: - providers:write parameters: - $ref: '#/components/parameters/DevId' - name: provider in: path required: true schema: type: string description: The provider this applies to, as a slug, e.g. garmin or apple_health. Case does not matter. An unrecognised provider is a 400. The provider must be enabled. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /environments/{dev_id}/unified-api/destinations: get: operationId: listDestinations tags: - destinations responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/DestinationSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - id: '1937255512398764032' type: webhook url: https://api.acme.com/terra/webhook active: true disabled_reason: null disabled_at: null event_types: - activity - sleep - daily has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: List destinations description: |- Lists the environment's destinations, cursor-paginated, with inactive ones included as `active: false`. - Rows carry no credential material: each `url` has any credentials it embeds removed. - A webhook's signing secret is returned only in the create response. - The configuration is read back, masked, by `GET /environments/{dev_id}/unified-api/destinations/{destination_id}`. security: - adminToken: - destinations:read parameters: - $ref: '#/components/parameters/DevId' post: operationId: createDestination tags: - destinations responses: '200': description: DryRunResult when ?dry_run=true. The preview omits id and signing_secret, which do not exist until the destination does; will_return_signing_secret says one would be issued. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: create preview: type: webhook url: https://example.com/terra active: true event_types: - activity configured: true missing: [] config: url: https://example.com/terra delivery: push will_return_signing_secret: true '201': description: Created. content: application/json: schema: $ref: '#/components/schemas/CreatedDestination' example: id: '1937255512398764032' type: webhook url: https://api.acme.com/terra/webhook active: true disabled_reason: null disabled_at: null event_types: - activity - sleep configured: true missing: [] config: url: https://api.acme.com/terra/webhook delivery: push signing_secret: a4f8…shown-once…c917 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Create a destination description: |- Creates a destination and returns it with its secrets masked. - Terra translates `config` into what delivery reads, so send only the fields `GET /environments/{dev_id}/unified-api/destination-types` lists for the type. - For a webhook, the 201 body is the only place its `signing_secret` appears, so store it now. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateDestinationRequest' examples: webhook: summary: A webhook value: type: webhook event_types: - activity - sleep config: url: https://api.acme.com/terra/webhook sql: summary: A Postgres database value: type: sql config: scheme: postgres host: db.acme.com port: 5432 database: terra username: terra password: correct-horse-battery-staple draft: summary: An S3 draft to finish later value: type: s3 active: false /environments/{dev_id}/unified-api/destinations/health: get: operationId: getDestinationsHealth tags: - destinations summary: Get destination health description: |- Works out each destination's health on request from its last 24 hours of delivery outcomes, judged on the last hour. - A delivery is one event to one destination, counted once however many attempts it took, as `GET /environments/{dev_id}/events` shows. - Failing, with `info.failing_since` set to when it began, means every delivery finished in the last hour failed, deliveries have waited on automatic retries for an hour with none delivered, or retries ran out and none has been delivered since. - A resend counts whatever its event's age but keeps its creation time, so how long it has retried is unknown; one still failing makes the destination degraded. - A delivery Terra could not send because it could not load the payload does not count. A disabled destination's error carries its `disabled_reason`, e.g. `auto_disabled_failed_delivery` for one Terra turned off after failing. - When delivery state cannot be read, every destination is `unknown` with error `check_unavailable`: health is never assumed. security: - adminToken: - destinations:read parameters: - $ref: '#/components/parameters/DevId' - name: destination_id in: query required: false description: Only these destinations, as string-encoded ids. Comma-separate them or repeat the parameter. Omit for every destination in the environment. style: form explode: false schema: type: array items: type: string responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/DestinationHealth' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - destination_id: '1937255512398764032' status: failing info: failing_since: '2026-11-04T09:40:12Z' last_delivered_at: '2026-11-04T09:31:05Z' last_failure_at: '2026-11-04T10:14:52Z' last_failure_status_code: 401 pending: 48 oldest_pending_at: '2026-11-04T09:32:40Z' counts: last_hour: delivered: 0 failed: 21 retried: 0 last_24h: delivered: 28911 failed: 21 retried: 140 error: code: unauthorized message: The endpoint answered 401 Unauthorized. - destination_id: '1937255512398764033' status: disabled info: failing_since: null last_delivered_at: null last_failure_at: '2026-11-03T09:40:00Z' last_failure_status_code: null pending: 0 oldest_pending_at: null counts: last_hour: delivered: 0 failed: 0 retried: 0 last_24h: delivered: 0 failed: 4 retried: 0 error: code: auto_disabled_failed_delivery message: Terra turned this destination off after deliveries to it failed for 24 hours. Fix the destination, then turn it back on. has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/unified-api/destinations/batch-create: post: operationId: batchCreateDestinations tags: - destinations responses: '200': description: DryRunResult when ?dry_run=true. Each item's preview omits id and signing_secret, which do not exist until the destination does; its will_return_signing_secret says one would be issued. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: create preview: data: - type: webhook url: https://example.com/terra active: true event_types: [] configured: true missing: [] config: url: https://example.com/terra delivery: push will_return_signing_secret: true '201': description: Created. content: application/json: schema: $ref: '#/components/schemas/BatchCreatedDestinations' example: data: - id: '1937255512398764032' type: webhook url: https://api.acme.com/terra/webhook active: true disabled_reason: null disabled_at: null event_types: [] configured: true missing: [] config: url: https://api.acme.com/terra/webhook delivery: push signing_secret: a4f8…shown-once…c917 - id: '1937255512398764033' type: s3 url: '' active: false disabled_reason: owner disabled_at: '2026-11-04T10:15:00Z' event_types: [] configured: false missing: - config.bucket - config.region - config.access_key_id - config.secret_access_key config: bucket: null region: null role_arn: null access_key_id: null secret_access_key_masked: null signing_secret: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Create several destinations description: |- Creates several destinations in one transaction and returns them in request order. - Every invalid item is reported in one 400 whose errors are prefixed with its position, e.g. `items[2].config.url`. - The deprecated `url` and `metadata` fields are not accepted. - For a webhook, its item in the response is the only place its `signing_secret` appears, so store it now. The MCP refuses an oversized batch so that no signing secret is ever lost to a truncated result. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchCreateDestinationsRequest' example: items: - event_types: - activity - sleep config: url: https://api.acme.com/terra/webhook - type: s3 active: false /environments/{dev_id}/unified-api/destinations/{destination_id}: get: operationId: retrieveDestination tags: - destinations responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/Destination' example: id: '1937255512398764032' type: s3 url: acme-terra active: false disabled_reason: owner disabled_at: '2026-11-03T16:02:11Z' event_types: [] configured: false missing: - config.secret_access_key config: bucket: acme-terra region: eu-west-1 role_arn: null access_key_id: AKIAIOSFODNN7EXAMPLE secret_access_key_masked: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Retrieve a destination description: |- Returns one destination, with its configuration under the field names create and update take. - Each secret comes back as `_masked`, the last four characters behind asterisks, or null when unset; a key file as `has_service_account_key` with its `service_account_email`. - `GET /environments/{dev_id}/unified-api/destinations/{destination_id}/secrets` reveals the secrets, under `keys:read`. - `configured` and `missing` say whether the destination has everything it needs to deliver. security: - adminToken: - destinations:read parameters: - $ref: '#/components/parameters/DevId' - name: destination_id in: path required: true schema: type: string description: The destination to read, by the id its creation returned. patch: operationId: patchDestination tags: - destinations responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/Destination' - $ref: '#/components/schemas/DryRunResult' example: id: '1937255512398764032' type: sql url: db2.acme.com active: true disabled_reason: null disabled_at: null event_types: - activity configured: true missing: [] config: scheme: postgres host: db2.acme.com port: 5432 database: terra username: terra password_masked: '****aple' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Update a destination description: |- Updates a destination and returns it with its secrets masked. - Editing an active destination needs a complete configuration, as activating one does. - A webhook keeps its signing secret. - Any successful update resets the destination's delivery-failure tracking. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - name: destination_id in: path required: true schema: type: string description: The destination to act on, by the id its creation returned. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PatchDestinationRequest' examples: host: summary: Move a database, which needs its password again value: config: host: db2.acme.com password: correct-horse-battery-staple events: summary: Change the delivered events, keeping the stored configuration value: event_types: - activity - sleep activate: summary: Finish and activate a draft value: active: true config: bucket: acme-terra region: eu-west-1 access_key_id: AKIAIOSFODNN7EXAMPLE secret_access_key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY delete: operationId: deleteDestination tags: - destinations responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: delete preview: id: '1937255512398764032' type: webhook url: https://api.acme.com/terra/webhook '204': description: Deleted. '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Delete a destination description: |- Permanently deletes a destination together with its signing secret. - Recreating the same URL produces a new destination with a new secret that receivers have to be told about. - Its delivery-failure tracking is reset. - Pass `?dry_run=true` first to preview what would go. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - name: destination_id in: path required: true schema: type: string description: The destination to act on, by the id its creation returned. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /environments/{dev_id}/unified-api/destinations/{destination_id}/secrets: get: operationId: revealDestinationSecrets tags: - destinations summary: Reveal a destination's credentials description: |- Returns in plaintext the secret configuration fields that `GET /environments/{dev_id}/unified-api/destinations/{destination_id}` masks: a database password, an access key secret, a key file, an API key, a SAS token, or the secret a webhook's deliveries are signed with. - Gated by `keys:read`, the same sensitive plaintext disclosure class as `GET /environments/{dev_id}/api-key`, and audited. - A destination whose stored configuration is unreadable is a 409. security: - adminToken: - keys:read parameters: - $ref: '#/components/parameters/DevId' - name: destination_id in: path required: true schema: type: string description: The destination to read, by the id its creation returned. A destination outside this environment is a 404. responses: '200': description: The destination's secrets. content: application/json: schema: $ref: '#/components/schemas/DestinationSecrets' example: id: '1937255512398764032' type: sql secrets: password: correct-horse-battery-staple '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/unified-api/destinations/{destination_id}/signing-secret/rotate: post: operationId: rotateDestinationSigningSecret tags: - destinations summary: Rotate a webhook's signing secret description: |- Generates a new signing secret for one webhook destination, replacing its own or the environment's it was signed with, and returns it once. - Every delivery after the call is signed with it, so update the receiver straight away. Other destinations keep theirs. - A destination whose stored configuration is unreadable is a 409. - A `?dry_run=true` preview generates and writes nothing. security: - adminToken: - destinations:write - keys:write parameters: - $ref: '#/components/parameters/DevId' - name: destination_id in: path required: true schema: type: string description: The webhook destination to act on, by the id its creation returned. A destination that is not a webhook is a 400. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Rotated (or DryRunResult when ?dry_run=true; the new secret is never previewed). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/RotatedSigningSecret' - $ref: '#/components/schemas/DryRunResult' example: id: '1937255512398764032' signing_secret: a4f8…shown-once…c917 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/unified-api/destinations/supabase/oauth: post: operationId: startSupabaseOauth tags: - destinations responses: '200': description: DryRunResult when ?dry_run=true. The authorization URL carries a session token, so previewing one would mean creating the session the preview promised not to create. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: start preview: redirect_uri: https://api.tryterra.co/api/v2/oauth/callback/dashboard/supabase scope: all return_to: cli expires_in: 600 will_return_authorization_url: true '201': description: Started. content: application/json: schema: $ref: '#/components/schemas/SupabaseStartResponse' example: authorization_url: https://api.supabase.com/v1/oauth/authorize?client_id=…&state=… oauth_session_id: 7f3a…64-hex…c2d1 expires_in: 900 interval: 5 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Start Supabase OAuth description: |- Opens a Supabase pairing session and changes nothing yet: someone has to visit the `authorization_url` and approve access, after which `GET /environments/{dev_id}/unified-api/destinations/supabase/oauth/{oauth_session_id}` reports `ready`. - The session expires after `expires_in` seconds, and `interval` is how often to poll in the meantime. - The body is optional. - With `return_to: dashboard` the browser comes back with `supabase_setup=success&oauth_session_id=`, or `supabase_setup=error&reason=` if the authorization failed. - Both `return_to` values share one redirect_uri, Terra's callback registered with Supabase; `return_to` only picks where it sends the browser. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/SupabaseStartRequest' /environments/{dev_id}/unified-api/destinations/supabase/oauth/{oauth_session_id}: get: operationId: pollSupabaseOauth tags: - destinations responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/SupabaseState' example: state: ready '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Poll Supabase OAuth state description: |- Returns whether a session started with `POST /environments/{dev_id}/unified-api/destinations/supabase/oauth` is `pending`, `ready` or `failed`. - Poll at the start response's `interval` and give up at its `expires_in`. The session reads `pending` until the authorization completes. - A failed authorization is a 200 carrying `state: failed`, not an error status. - A 404 means only that the handle is unknown or expired. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - name: oauth_session_id in: path required: true schema: type: string description: The session handle the start step returned. It expires, so a stale handle is a 404 rather than an error naming the session. /environments/{dev_id}/unified-api/destinations/supabase/oauth/{oauth_session_id}/projects: get: operationId: listSupabaseProjects tags: - destinations responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/SupabaseProject' has_more: type: boolean next_cursor: type: - string - 'null' meta: type: object properties: organizations: type: array description: Every organization the authorization can see, including any without projects. create_project.organization_id must be one of these. items: $ref: '#/components/schemas/SupabaseOrganization' required: - organizations required: - data - has_more - next_cursor - meta example: data: - id: abcdefghijklmnop name: acme-prod organization_id: wxyzorgabcdefgh region: us-east-1 status: ACTIVE_HEALTHY has_more: false next_cursor: null meta: organizations: - id: wxyzorgabcdefgh name: Acme '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '503': description: Supabase's management API returned an error (code dependency_failed, with Supabase's message as the remediation), or Supabase provisioning is not available on this deployment. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: service unavailable detail: the Supabase management API returned an error instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/destinations/supabase/oauth/7f3a…c2d1/projects code: dependency_failed remediation: Retry shortly. summary: List Supabase projects description: |- Lists the Supabase projects visible to an OAuth session, each with the organization it belongs to. - The session must have reached `ready`, or this is a 409: poll `GET /environments/{dev_id}/unified-api/destinations/supabase/oauth/{oauth_session_id}` first. - `meta.organizations` lists every organization the authorization can see, so a project can be created in one that has none yet. - Pass a row's `id` to `POST /environments/{dev_id}/unified-api/destinations/supabase/provision` as `project_ref`, or an organization's `id` as `create_project.organization_id`. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - name: oauth_session_id in: path required: true schema: type: string description: The session handle the start step returned. It expires, so a stale handle is a 404 rather than an error naming the session. /environments/{dev_id}/unified-api/destinations/supabase/provision: post: operationId: provisionSupabase tags: - destinations responses: '200': description: DryRunResult when ?dry_run=true. The OAuth session, its readiness, the project reference and its status, or the new project's organization, and any destination to replace are all validated, so the preview refuses what the call would refuse; nothing is created or deleted. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: provision preview: create_project: name: terra-prod organization_id: wxyzorgabcdefgh region: us-east-1 organization: Acme will_create_project: true will_return_database_password: true will_create_destination: true replace_destination_id: '1937255512398760001' '201': description: Provisioned. content: application/json: schema: $ref: '#/components/schemas/SupabaseProvisioned' example: provisioned: true project_ref: abcdefghijklmnop project_created: true destination_id: '1937255512398764033' database_password: q8Zr…32-chars…Kx1v replaced_destination_id: '1937255512398760001' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': description: The project_ref names a project that is paused, or that failed or was removed, so it cannot be provisioned into until it is restored or repaired in Supabase (code unsupported_operation, with the project's status in the remediation). Retrying unchanged returns the same error. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: unprocessable entity detail: the Supabase project is paused instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/destinations/supabase/provision code: unsupported_operation remediation: Its status is INACTIVE. Restore the project from the Supabase dashboard, wait until its status is ACTIVE_HEALTHY, then provision again. '429': $ref: '#/components/responses/RateLimited' '503': description: Supabase's management API returned an error (code dependency_failed, with Supabase's message as the remediation), or Supabase provisioning is not available on this deployment. When a project was created but could not be connected, the remediation names its reference to retry with as project_ref. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: service unavailable detail: the Supabase management API returned an error instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/destinations/supabase/provision code: dependency_failed remediation: The project limit for this organization has been reached. summary: Provision the Supabase destination description: |- Connects a Supabase project as a data destination, first creating the project when `create_project` is sent, and returns the new `destination_id`. - Long-running: provisioning a project can take minutes, so allow a generous timeout rather than reading a slow response as a hang. - The destination it creates delivers every event type and is managed through the ordinary destinations endpoints from then on. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SupabaseProvisionRequest' /environments/{dev_id}/unified-api/data-types: get: operationId: listSelectableDataTypes tags: - unified-api responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/SelectableDataType' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - data_type: activity - data_type: body - data_type: daily - data_type: sleep has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: List selectable data types description: |- Lists every data type `PUT /environments/{dev_id}/unified-api/scopes` accepts for this environment, in data-type order and complete in one response. - `ATHLETE` is omitted because it is always selected. - A type gated behind an entitlement the account does not hold is omitted rather than flagged, so the list is exactly what a PUT can select without a 403. - Which types are currently selected is on `GET /environments/{dev_id}/unified-api/scopes`. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/unified-api/scopes: get: operationId: listUnifiedApiScopes tags: - unified-api responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/SelectedDataField' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - data_type: activity fields: - steps - distance_metres - calories samples_enabled: false has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Per-data-type field selection description: |- Lists one row per data type the environment collects, with the fields selected within that type and its samples flag. - This is the inner axis only: which data types are selected at all is set by `PUT /environments/{dev_id}/unified-api/scopes`. - A data type that is not selected does not appear. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' patch: operationId: patchUnifiedApiScopes tags: - unified-api responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/SelectedDataField' - $ref: '#/components/schemas/DryRunResult' example: data_type: activity fields: - steps - distance_metres samples_enabled: false '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Replace a data-type field selection description: |- Replaces the field selection for the single data type named in the body. - Anything left out of `fields` is deselected. - `samples_enabled` comes back in the response but cannot be set here. - Data types are selected in the first place by `PUT /environments/{dev_id}/unified-api/scopes`; a data type that is not selected returns 404 in both preview and live mode. security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SelectedDataFieldsRequest' put: operationId: putUnifiedApiScopes tags: - unified-api responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/SelectedDataTypes' - $ref: '#/components/schemas/DryRunResult' example: scopes: - ATHLETE - ACTIVITY - BODY - SLEEP samples_enabled: true '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' summary: Replace which data types are selected security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' description: |- Replaces wholesale which data types this environment collects; `PATCH /environments/{dev_id}/unified-api/scopes` sets the fields within one type. - Send the complete set: anything omitted is deselected, and nothing is read back first, so a concurrent edit is never silently reinstated. - `ATHLETE` is always selected and need not be sent; `SAMPLES` is the per-row samples flag, not a data type. - `HEALTH_OBSERVATION` is 403 `access_denied` unless the account holds the `health_observation` entitlement. - `CLINICAL_RECORD` is 403 `access_denied` unless the account holds the `clinical_record` entitlement. - Needs `dataconfig:write`, not `account:write`, so every role that configures data can edit them. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ReplaceDataTypesRequest' /environments/{dev_id}/unified-api/scores: get: operationId: listScores tags: - health-scores responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/ScoreConfig' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - type: sleep active: true has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Score configuration description: |- Lists the environment's configured scores, each with its type and active flag. - Weights are not in the rows; `GET /environments/{dev_id}/unified-api/scores/{score}` returns them. - These are settings, not results: computed scores are on `GET /environments/{dev_id}/unified-api/scores/history`. security: - adminToken: - scores:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/unified-api/scores/{score}: get: operationId: getScore tags: - health-scores summary: A score's full config (type, active, weights) description: |- Returns one score's configuration: its type, whether it is active, and its weights. - This is the only place the weights appear; rows from `GET /environments/{dev_id}/unified-api/scores` omit them. - Computed values are on `GET /environments/{dev_id}/unified-api/scores/history` and `GET /environments/{dev_id}/unified-api/scores/analytics`. security: - adminToken: - scores:read parameters: - $ref: '#/components/parameters/DevId' - name: score in: path required: true schema: type: string description: |- The score to act on, named however you have it: the score name, an alias, the enum name, or the numeric enum value. An unrecognised score is a 400. responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ScoreResult' example: score: sleep active: true weights: duration: 40 efficiency: 30 timing: 30 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' patch: operationId: patchScore tags: - health-scores responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/ScoreResult' - $ref: '#/components/schemas/DryRunResult' example: score: sleep active: true weights: duration: 50 efficiency: 25 timing: 25 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: Update a score's config (active and/or weights) description: |- Updates an existing score's `active` flag, its weights, or both, and returns the score's full config after the write. - Send at least one of `active` and `weights`. - The response is where to confirm what actually took effect. - The score must already exist; there is no operation for defining a new score. security: - adminToken: - scores:write parameters: - $ref: '#/components/parameters/DevId' - name: score in: path required: true schema: type: string description: |- The score to act on, named however you have it: the score name, an alias, the enum name, or the numeric enum value. An unrecognised score is a 400. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PatchScoreRequest' /environments/{dev_id}/unified-api/scores/history: get: operationId: listScoresHistory tags: - health-scores summary: Score history description: |- Lists a page of the environment's computed scores, newest first, with keyset cursor pagination. - Each row carries the Terra `user_id` its `provider_user_id` maps to, or null when unmapped. security: - adminToken: - scores:read parameters: - $ref: '#/components/parameters/DevId' - name: score in: query schema: type: string description: 'One score, named however you have it: the score name, an alias, the enum name, or the numeric enum value. An unrecognised score is a 400.' - name: user_id in: query schema: type: string format: uuid description: Terra user id, resolved to that user's provider_user_id(s) before the history is read, since the stored rows carry only the provider's id. A user with no connection is an empty page, so a paging caller can tell "no rows" from a broken request. Intersects with provider_user_id when both are sent. - name: provider_user_id in: query schema: type: string description: The provider's own id for a user, matched exactly as stored. No resolution, so this is the filter to reach for when the Terra user id is not to hand. - name: since in: query schema: type: string format: date-time description: Oldest insert_timestamp to return, inclusive, as RFC3339. Windows on when the score was computed, not on the period it covers. Defaults to 7 days before until. - name: until in: query schema: type: string format: date-time description: Newest insert_timestamp to return, inclusive, as RFC3339. Defaults to now. - name: limit in: query schema: type: integer default: 50 minimum: 1 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window the first page resolved, so since and until are ignored while it is set. responses: '200': description: A page of score records (keyset cursor). content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/ScoreHistoryRecord' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - provider_user_id: a1b2c3d4 user_id: 8f14e45f-ceea-467d-9f6a-3b1c2d4e5f6a provider: garmin score: sleep value: 82 dimensions: - 80 - 75 - 90 - -1 - -1 - -1 - -1 - -1 start_time: '2026-07-15T22:00:00Z' end_time: '2026-07-16T07:00:00Z' inserted_at: '2026-07-16T08:14:02.113Z' has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/unified-api/scores/analytics: get: operationId: getScoresAnalytics tags: - health-scores summary: Score analytics description: 'Returns aggregate score stats for the environment over the `since`/`until` window: distinct users covered and total score updates.' security: - adminToken: - scores:read parameters: - $ref: '#/components/parameters/DevId' - name: since in: query schema: type: string format: date-time description: Oldest insert_timestamp to count, inclusive, as RFC3339. Windows on when a score was computed, not on the period it covers. Defaults to 7 days before until. - name: until in: query schema: type: string format: date-time description: Newest insert_timestamp to count, inclusive, as RFC3339. Defaults to now. responses: '200': description: Aggregate score stats over the window. content: application/json: schema: $ref: '#/components/schemas/ScoreAnalytics' example: covered_users: 128 updates: 5140 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/doctor: get: operationId: getDoctor tags: - doctor summary: Check the environment description: |- Runs the environment's checks on request and returns one lint per problem, errors first. - There is no overall status: decide which levels (`error`, `warn`, `info`) fail you. - Each area's checks run only when the token holds the scope that area's reads need (`tokens:read`, `tokens:admin`, `billing:read`, `team:read`, `providers:read`, `connections:read`, `events:read`, `dataconfig:read`, `vantage:read`, `vantageconfig:read`, `lab_reports:read`, `models:read`, `workouts:read`, `account:read`); product checks run only when the environment has the product, and are skipped otherwise. - Checks that cannot run, for want of a scope or a readable dependency, come back as one `check_unavailable` lint per cause listing them in `metadata.checks`, never as a pass. - `cache_key` stays the same for the same problem across runs; `remediation.docs_url` links to the check in the environment doctor docs. security: - adminToken: - destinations:read parameters: - $ref: '#/components/parameters/DevId' - name: name in: query required: false description: Run only these checks, by lint name. Comma-separate them or repeat the parameter; a check matching any of them runs. An unknown name is a 400. Combines with category to choose which lints come back. style: form explode: false schema: type: array items: type: string - name: category in: query required: false description: Run only the checks in these categories. Comma-separate them or repeat the parameter. A check in any of them runs. Combines with name to choose which lints come back. style: form explode: false schema: type: array items: type: string enum: - security - performance - health responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/DoctorReport' example: lints: - name: billing_unlinked title: Billing is not set up level: error facing: external categories: - health description: Terra does not deliver data for a billable environment whose account has no billing set up. detail: The account has no billing set up, so Terra holds every delivery for this billable environment. remediation: text: Subscribe to a plan to set up billing. action: subscribe docs_url: https://docs.tryterra.co/reference/admin-api/environment-doctor#billing_unlinked metadata: type: environment id: null name: null reason: null scope: null since: null observed: {} checks: null cache_key: billing_unlinked observed_at: '2026-11-05T12:00:00Z' - name: check_unavailable title: Check could not run level: info facing: external categories: - health - security description: A check that cannot run is reported here instead of passing. detail: 'These checks could not run because the token lacks the tokens:admin scope: token_cap_near, token_leaked, token_never_expires, token_overbroad, token_unused.' remediation: text: Use a token that holds tokens:admin. action: null docs_url: https://docs.tryterra.co/reference/admin-api/environment-doctor#check_unavailable metadata: type: check id: null name: null reason: missing_scope scope: tokens:admin since: null observed: {} checks: - token_cap_near - token_leaked - token_never_expires - token_overbroad - token_unused cache_key: check_unavailable:missing_scope:tokens:admin observed_at: '2026-11-05T12:00:00Z' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/events: get: operationId: listWebhookEvents tags: - events responses: '200': description: A page of webhook events (keyset cursor). content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/Event' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - event_id: c9d0e1f2-3a4b-4c5d-8e9f-a0b1c2d3e4f5 type: unified_api.activity.updated payload_type: activity provider: garmin connection_id: '1937251889234671616' user_id: 3f8e2b1c-4d5a-4e6f-9a0b-1c2d3e4f5a6b reference_id: user-42 status: pending destination_count: 2 attempt_count: 3 created_at: '2026-07-02T18:04:11Z' completed_at: null has_more: true next_cursor: eyJzZW50X2F0IjoiMjAyNi0wNy0wMlQxODowNDoxMS41MzJaIiwiZXZlbnRfaWQiOiJjOWQwIn0 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List webhook events description: |- Lists webhook events in the environment, newest first, each with where its delivery stands across every destination it was sent to. - Each destination's delivery and its attempts are on `GET /environments/{dev_id}/events/{event_id}`; the body that was sent is on `GET /environments/{dev_id}/events/{event_id}/payload`. - Events are kept for 30 days, and the list reads a bounded window of `created_at`. - No matching events returns an empty page; an unknown `user_id` or `reference_id` is a 404. security: - adminToken: - events:read parameters: - $ref: '#/components/parameters/DevId' - name: destination in: query description: String-encoded destination ID, matched exactly against the delivery-time record. Lists the events sent to that destination; each event's status and counts still cover every destination. A value that is not an id is a 400. schema: type: string example: '1937255512398764032' - name: destination_url in: query description: Exact, case-sensitive destination URL recorded at delivery time. Combines with destination when both are supplied. Lists the events sent to that URL; each event's status and counts still cover every destination. schema: type: string example: https://api.acme.com/terra/webhook - name: limit in: query schema: type: integer minimum: 1 default: 50 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window the first page resolved, so since and until are ignored while it is set, but supplied values must still be valid RFC3339. - name: since in: query schema: type: string format: date-time description: Oldest created_at to return, inclusive, as RFC3339. Defaults to 7 days before until, or 14 days before it when event_id is given. - name: until in: query schema: type: string format: date-time description: Newest created_at to return, inclusive, as RFC3339. Defaults to now. - name: status in: query schema: type: string enum: - pending - delivered - failed - canceled description: Only events with this status. The removed outcome parameter is a 400. - name: provider in: query schema: type: array items: type: string style: form explode: false description: Provider slugs, matched case-insensitively, e.g. garmin. Repeat the parameter to widen the filter; an event matching any of them is returned. - name: type in: query schema: type: array items: type: string style: form explode: false description: Event types, e.g. unified_api.sleep.updated, or a prefix of whole segments ending in .*, e.g. unified_api.* or unified_api.auth.*. Repeat the parameter to widen the filter; an event matching any of them is returned. A type that matches no event type listed here is a 400, as is the removed data_type parameter. - name: destination_type in: query schema: type: array items: type: string style: form explode: false description: Destination kinds the payload was delivered to, matched case-insensitively, e.g. webhook, s3 or kafka. Repeat the parameter to widen the filter; an event matching any of them is returned. - name: summary_id in: query schema: type: string description: A summary id carried by the event's payload, matched exactly. An event is returned when any of its records carries it, including an event no request has been sent for yet. An event canceled before its payload was read never matches. - name: user_id in: query schema: type: string format: uuid description: Terra user id, a UUID, resolved to that user's connection before the history is read. An unknown user returns 404; a user with no deliveries in this environment returns an empty page. Combines with reference_id rather than overriding it. - name: reference_id in: query schema: type: string description: Your own id for a user, matched exactly and resolved to every connection under it. No match is a 404, not an empty page. Given with user_id it narrows further, so a user that is not under the reference matches no events. - name: event_id in: query schema: type: string description: Exact event id. An id is identity-keyed rather than time-keyed, so it widens the default window from 7 days to the 14 days a payload is retained for. - name: order_by in: query schema: type: string enum: - created_at default: created_at description: Field to sort by. Events that tie fall back to event_id in the same direction, so every page is a stable slice. A cursor keeps the order its first page was read in, so order_by is ignored while cursor is set, though it must still be valid. - $ref: '#/components/parameters/Order' /environments/{dev_id}/event-types: get: operationId: listEventTypes tags: - events summary: List event types description: |- Lists every event type the events list records, as `..`, with the product it belongs to, when it occurs and the type its webhook payload carries today. - These are the values the `type` filter on `GET /environments/{dev_id}/events` takes. - The list is identical for every environment. security: - adminToken: - events:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The event types. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/EventType' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - type: unified_api.sleep.updated product: unified_api description: Sleep data was received or revised. payload_types: - sleep has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/events/resend: post: operationId: resendWebhookEvent tags: - events responses: '200': description: DryRunResult when ?dry_run=true. The payload, destination and user lookups have run and nothing is queued; a live resend mints its own resend_id. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: resend preview: event_id: 7d2f1c3a-9b4e-4f60-8a1d-2c3b4e5f6a7b type: unified_api.activity.updated payload_type: activity user_id: 3f8e2b1c-4d5a-4e6f-9a0b-1c2d3e4f5a6b destination_id: '1937255512398764032' dispatched: false '202': description: Queued for redelivery. Dispatch is asynchronous, so a 202 means the event was accepted rather than delivered; re-read the event to see the outcome. content: application/json: schema: $ref: '#/components/schemas/ResendResult' example: event_id: c9d0e1f2-3a4b-4c5d-8e9f-a0b1c2d3e4f5 type: unified_api.activity.updated payload_type: activity destination_id: '1937255512398764032' resend_id: rs_0b8f4f6e-2c1d-4a3b-9e8f-7a6b5c4d3e2f dispatched: true '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Resend an event to one destination description: |- Queues an event's stored payload for redelivery to one destination and answers `202` once it is accepted. - `dispatched: true` means the event was accepted for redelivery, not that it arrived; re-read it with `GET /environments/{dev_id}/events/{event_id}` to see the outcome. - The destination receives the payload again under the same `event_id`, so a receiver that is not idempotent sees the same event twice. - A resend is allowed while the delivery is still pending: it runs alongside the automatic retries, which carry on. security: - adminToken: - events:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ResendEventRequest' /environments/{dev_id}/events/generate: post: operationId: generateWebhookEvent tags: - events responses: '200': description: The built payload when dispatch is false, as a GenerateEventResult with dispatched false; or DryRunResult when ?dry_run=true, whose preview is the GenerateEventResult a real call would return. Either way nothing is stored or delivered, and the event_id is not a real event. content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/GenerateEventResult' - $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: dispatch preview: event_id: 7d2f1c3a-9b4e-4f60-8a1d-2c3b4e5f6a7b type: unified_api.sleep.updated payload_type: sleep provider: null destination_id: null dispatched: false payload: type: sleep data: [] '202': description: Queued for delivery. Dispatch is asynchronous, so the event is stored and accepted rather than delivered; it appears in the delivery history under event_id once sent. content: application/json: schema: $ref: '#/components/schemas/GenerateEventResult' example: event_id: 7d2f1c3a-9b4e-4f60-8a1d-2c3b4e5f6a7b user_id: 3f8e2b1c-4d5a-4e6f-9a0b-1c2d3e4f5a6b reference_id: qa-runner-17 type: unified_api.daily.updated payload_type: daily provider: garmin destination_id: null dispatched: true payload: type: daily user: user_id: 3f8e2b1c-4d5a-4e6f-9a0b-1c2d3e4f5a6b provider: GARMIN data: [] '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Generate a synthetic test event description: |- Builds a realistic event of the requested type for a made-up user, normalises it exactly as live provider data is, stores and queues it, and returns the payload the destination will receive. - Register the receiver as a destination first; there is no ad-hoc URL. - Having no eligible destination, or naming an inactive or non-accepting one, is a 422 on real and dry-run calls alike; `?dry_run=true` previews a dispatching call, failing as it would. - The event is marked synthetic end to end and never touches a real connection. - Requires the environment to be entitled to the Unified API. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/GenerateEventRequest' example: type: daily provider: garmin destination_id: '4821' /environments/{dev_id}/users: get: operationId: listUsers tags: - users responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/UserSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: acme-user-4821 provider: garmin active: true scopes: - activity - sleep created_at: '2026-05-14T08:22:31Z' last_updated_at: '2026-07-03T09:15:00Z' most_recent_data_at: '2026-07-03T05:58:02Z' - user_id: 3e2d1c0b-9a8f-4e7d-6c5b-4a3928170605 provider: oura active: false scopes: [] created_at: '2026-04-02T10:05:00Z' last_updated_at: null most_recent_data_at: null has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' summary: List end-user connections description: |- Lists the environment's end-user connections, newest first by creation time, each with the scopes the user granted the provider. - With `q` it is a search instead, for a search box: it has no cursor, and `has_more` means more connections match and `q` should be refined. security: - adminToken: - connections:read parameters: - $ref: '#/components/parameters/DevId' - name: q in: query schema: type: string minLength: 3 maxLength: 128 description: Text to search for, trimmed, 3 to 128 characters. Matches reference_id by case-insensitive prefix. When it is a full hyphenated UUID it also matches user_id exactly; a partial UUID is treated as a reference prefix only. Combines with provider and active; combining it with cursor, user_id, reference_id or a creation-time bound is a 400. The user_id match comes first, then reference_id matches in reference order; limit defaults to 10 and is clamped to 20, and next_cursor is always null. - name: provider in: query schema: type: string description: One provider slug, e.g. garmin. Validated against the providers this API knows, so an unrecognised one is a 400 rather than a silently empty page. - name: active in: query schema: type: boolean description: Whether the connection is still authorized. Omit for both. - name: user_id in: query schema: type: string format: uuid description: Terra user id, matched exactly. One connection at most, so this is a lookup rather than a filter. - name: reference_id in: query schema: type: string description: Your own id for a user, matched exactly. One user can hold several connections, so this can return more than one row. - name: created_since in: query description: Lower bound (inclusive, RFC3339) on connection creation time. This surface windows on creation time rather than on the data's own timestamps. `since` is accepted as a synonym, and every occurrence of either spelling must carry the same value — a disagreeing value is a 400, whether it arrives under `since` or as a repeat of this parameter. schema: type: string format: date-time - name: since in: query description: Synonym for created_since, accepted so the shorter name a caller reaches for first is not rejected. Every occurrence of either spelling must carry the same value — a disagreeing value is a 400, whether it arrives under `created_since` or as a repeat of this parameter. schema: type: string format: date-time - name: created_until in: query description: Upper bound (inclusive, RFC3339) on connection creation time. `until` is accepted as a synonym, and every occurrence of either spelling must carry the same value — a disagreeing value is a 400, whether it arrives under `until` or as a repeat of this parameter. schema: type: string format: date-time - name: until in: query description: Synonym for created_until, accepted so the shorter name a caller reaches for first is not rejected. Every occurrence of either spelling must carry the same value — a disagreeing value is a 400, whether it arrives under `created_until` or as a repeat of this parameter. schema: type: string format: date-time - name: limit in: query schema: type: integer default: 50 minimum: 1 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. With q, defaults to 10 and is clamped to 20. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window the first page resolved, so the creation-time bounds are ignored while it is set. Not accepted with q. /environments/{dev_id}/users/stats: get: operationId: getUserStats tags: - users summary: Connection and delivery statistics description: |- Returns connection and delivery analytics over [`since`, `until`). - `full` adds current provider balances and every UTC daily bucket, including inactive days; activity counts are zero-filled and connection balances carry forward. - `delivery_attempts` counts recorded outbound attempts, including retries and failures. - `net_connections` is the all-time `CREATE` minus `DELETE` balance at the end of the interval, not a sum or distinct-user count. - Current provider balances are independent of the window; `observed_at` is their read time, not an ingestion watermark or atomic snapshot. security: - adminToken: - connections:read parameters: - $ref: '#/components/parameters/DevId' - name: since in: query schema: type: string format: date-time description: Inclusive start of the event window. Defaults to 3 months before until. At most millisecond precision, and must be within 1900-2299. example: '2026-06-01T00:00:00Z' - name: until in: query schema: type: string format: date-time description: Exclusive end of the event window. Defaults to now. Must be after since. At most millisecond precision, and must be within 1900-2299. example: '2026-06-03T00:00:00Z' - name: view in: query description: Response detail level. Basic returns flat scalar summary fields. Full keeps the same summary fields and adds time series and resource-specific detail sections. Defaults to basic. Full is limited to 1500 intersecting daily buckets, including partial boundary buckets. Basic skips daily and provider aggregation and has no bucket limit. schema: type: string enum: - basic - full default: basic example: full responses: '200': description: Scalar summary metrics in both views; full adds documented detail sections. content: application/json: schema: $ref: '#/components/schemas/UserStatsResponse' examples: basic: summary: Default flat summary value: since: '2026-06-01T00:00:00Z' until: '2026-06-03T00:00:00Z' view: basic net_connections: 10 net_connection_change: 2 connections_created: 3 connections_deleted: 1 delivery_attempts: 240 bytes: 1048576 full: summary: Full analytics, including graph data value: since: '2026-06-01T00:00:00Z' until: '2026-06-03T00:00:00Z' view: full net_connections: 10 net_connection_change: 2 connections_created: 3 connections_deleted: 1 delivery_attempts: 240 bytes: 1048576 granularity: day current: observed_at: '2026-06-10T12:00:00Z' net_connections: 9 providers: - provider: garmin net_connections: 9 series: - bucket_start: '2026-06-01T00:00:00Z' net_connections: 10 net_connection_change: 2 connections_created: 2 connections_deleted: 0 delivery_attempts: 200 bytes: 1000000 - bucket_start: '2026-06-02T00:00:00Z' net_connections: 10 net_connection_change: 0 connections_created: 1 connections_deleted: 1 delivery_attempts: 40 bytes: 48576 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/users/{user_id}/data: get: operationId: getUserData tags: - users summary: Read a user's stored data description: |- Returns the user's stored data of one type over a window, in Terra's JSON format: the body a data read returns. - It reads what Terra already holds and never fetches from the provider, so it works for synthetic users and for users with no destination. security: - adminToken: - payloads:read parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/PayloadSamples' - name: user_id in: path required: true schema: type: string format: uuid description: The user to read, by the id the users list returns. - name: data_type in: query required: true schema: type: string enum: - activity - body - daily - menstruation - nutrition - sleep description: The type of data to read. - name: since in: query required: false schema: type: string format: date-time description: Start of the window. Defaults to 7 days before until; the window can be at most 31 days. - name: until in: query required: false schema: type: string format: date-time description: End of the window. Defaults to now. responses: '200': description: The user's stored data. content: application/json: schema: type: object example: user: user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a provider: SYNTHETIC data: - metadata: start_time: '2026-07-01T23:12:00Z' end_time: '2026-07-02T06:48:00Z' sleep_durations_data: asleep: duration_asleep_state_seconds: 24120 type: sleep '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/synthetic-users: get: operationId: listSyntheticUsers tags: - users summary: List synthetic users description: |- Lists the environment's synthetic users, newest first by creation time, each with its latest generation run. - A user that has never run is listed with `latest_run` null. security: - adminToken: - connections:read parameters: - $ref: '#/components/parameters/DevId' - name: status in: query required: false schema: type: string enum: - generating - stopped description: Narrow the list to users that are generating data or stopped. - name: limit in: query schema: type: integer default: 50 minimum: 1 description: Users per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. responses: '200': description: The environment's synthetic users. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/SyntheticUser' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: null description: a poor sleeper with high stress persona: data_types: sleep: normal daily: normal activity: sparse biases: sleep_quality: low stress: high provider: null status: generating sample: false created_at: '2026-07-02T09:00:00Z' latest_run: run_id: 3c9e1f2a-7b4d-4e8f-a1c2-5d6e7f8a9b0c status: active duration_hours: 24 cadence_seconds: 300 payloads_sent: 14 started_at: '2026-07-02T09:00:00Z' expires_at: '2026-07-03T09:00:00Z' next_run_at: '2026-07-02T10:15:00Z' last_run_at: '2026-07-02T10:10:00Z' has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' post: operationId: createSyntheticUser tags: - users summary: Create a synthetic user description: |- Creates a synthetic user and starts its first generation run. - The user receives one payload of each data type it generates straight away, then one every cadence until the run ends. - A `description` is translated into a persona when the user is created, so a `?dry_run=true` preview shows the request rather than the translated persona; pass `persona` to fix it in advance. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateSyntheticUserRequest' responses: '200': description: DryRunResult when ?dry_run=true. The preview is the validated request; no user is created and the description is not translated. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: create preview: description: a poor sleeper with high stress persona: null provider: null duration_hours: 24 reference_id: null backfill_days: 0 '201': description: The created synthetic user, generating. content: application/json: schema: $ref: '#/components/schemas/SyntheticUser' example: user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: null description: a poor sleeper with high stress persona: data_types: sleep: normal daily: normal activity: sparse biases: sleep_quality: low stress: high provider: null status: generating sample: false created_at: '2026-07-02T09:00:00Z' latest_run: run_id: 3c9e1f2a-7b4d-4e8f-a1c2-5d6e7f8a9b0c status: active duration_hours: 24 cadence_seconds: 300 payloads_sent: 0 started_at: '2026-07-02T09:00:00Z' expires_at: '2026-07-03T09:00:00Z' next_run_at: '2026-07-02T09:05:00Z' last_run_at: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/synthetic-users/samples: post: operationId: ensureSampleUsers tags: - users summary: Ensure sample users description: |- Creates the environment's five fixed sample users if they do not exist yet and fills any missing days of their history, up to now. - The history is generated in the request and stored before the response, so Health Context and model runs can read it immediately. - Every environment's sample users share the same history, seeded by date, so the same day is the same data everywhere. - Repeat calls create nothing and write only days that are missing. - Sample users cannot be started, stopped or uploaded to. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/EnsureSampleUsersRequest' responses: '200': description: The environment's sample users with their history window; or DryRunResult when ?dry_run=true, whose preview lists the personas that would be ensured and the days of history. content: application/json: schema: type: object anyOf: - type: object properties: users: type: array items: $ref: '#/components/schemas/SampleUser' required: - users - $ref: '#/components/schemas/DryRunResult' example: users: - user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: terra-sample-runner name: Marathon runner description: Runs most days with a low resting heart rate and strong recovery. days_written: 45 history_from: '2026-09-12T00:00:00Z' history_to: '2026-10-27T00:00:00Z' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/synthetic-users/{user_id}: get: operationId: getSyntheticUser tags: - users summary: Get a synthetic user description: Returns one synthetic user with its persona and latest generation run. security: - adminToken: - connections:read parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/SyntheticUserId' responses: '200': description: The synthetic user. content: application/json: schema: $ref: '#/components/schemas/SyntheticUser' example: user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: null description: a poor sleeper with high stress persona: data_types: sleep: normal daily: normal activity: sparse biases: sleep_quality: low stress: high provider: null status: generating sample: false created_at: '2026-07-02T09:00:00Z' latest_run: run_id: 3c9e1f2a-7b4d-4e8f-a1c2-5d6e7f8a9b0c status: active duration_hours: 24 cadence_seconds: 300 payloads_sent: 14 started_at: '2026-07-02T09:00:00Z' expires_at: '2026-07-03T09:00:00Z' next_run_at: '2026-07-02T10:15:00Z' last_run_at: '2026-07-02T10:10:00Z' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/synthetic-users/{user_id}/start: post: operationId: startSyntheticUser tags: - users summary: Start a synthetic user description: |- Starts a new generation run for a stopped synthetic user. - A user that is already generating is a 409. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/SyntheticUserId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/StartSyntheticUserRequest' responses: '200': description: The synthetic user, generating; or DryRunResult when ?dry_run=true, whose preview is the persona and duration the run would use. content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/SyntheticUser' - $ref: '#/components/schemas/DryRunResult' example: user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: null description: a poor sleeper with high stress persona: data_types: sleep: normal daily: normal activity: sparse biases: sleep_quality: low stress: high provider: null status: generating sample: false created_at: '2026-07-02T09:00:00Z' latest_run: run_id: 3c9e1f2a-7b4d-4e8f-a1c2-5d6e7f8a9b0c status: active duration_hours: 24 cadence_seconds: 300 payloads_sent: 14 started_at: '2026-07-02T09:00:00Z' expires_at: '2026-07-03T09:00:00Z' next_run_at: '2026-07-02T10:15:00Z' last_run_at: '2026-07-02T10:10:00Z' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/synthetic-users/{user_id}/stop: post: operationId: stopSyntheticUser tags: - users summary: Stop a synthetic user description: |- Ends the synthetic user's current run. - The user and its data stay; start it again any time with `POST /environments/{dev_id}/synthetic-users/{user_id}/start`. - Stopping a user that is not generating changes nothing. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/SyntheticUserId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: The synthetic user, stopped; or DryRunResult when ?dry_run=true, whose preview is the user as it is now (would is noop when it is already stopped). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/SyntheticUser' - $ref: '#/components/schemas/DryRunResult' example: user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a reference_id: null description: a poor sleeper with high stress persona: data_types: sleep: normal daily: normal activity: sparse biases: sleep_quality: low stress: high provider: null status: stopped sample: false created_at: '2026-07-02T09:00:00Z' latest_run: run_id: 3c9e1f2a-7b4d-4e8f-a1c2-5d6e7f8a9b0c status: cancelled duration_hours: 24 cadence_seconds: 300 payloads_sent: 14 started_at: '2026-07-02T09:00:00Z' expires_at: '2026-07-03T09:00:00Z' next_run_at: null last_run_at: '2026-07-02T10:10:00Z' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/events/stats: get: operationId: getEventStats tags: - events summary: Delivery event statistics description: |- Returns analytics on recorded outbound delivery attempts over [`since`, `until`); synchronous API reads are not included. - A status of 200-299 is successful; every other status is failed. - `delivery_attempts` includes retries; `successful_attempts` and `failed_attempts` partition that count. - Latency samples must be finite and positive, in milliseconds; percentiles use TDigest over the whole window. security: - adminToken: - events:read parameters: - $ref: '#/components/parameters/DevId' - name: destination in: query description: String-encoded destination ID, matched exactly against the delivery-time record. Rows that predate destination ID recording do not match. Use destination_url to include older rows. Applies to every metric and to the comparison window. schema: type: string example: '1937255512398764032' - name: destination_url in: query description: Exact, case-sensitive destination URL recorded at delivery time. Combines with destination when both are supplied. Also matches older rows without a recorded destination ID. Applies to every metric and to the comparison window. schema: type: string example: https://api.acme.com/terra/webhook - name: since in: query description: Inclusive start in RFC3339 with at most millisecond precision. Must be within 1900-2299. schema: type: string format: date-time example: '2026-06-01T00:00:00Z' - name: until in: query description: Exclusive end in RFC3339 with at most millisecond precision. Must be after since. Must be within 1900-2299. schema: type: string format: date-time example: '2026-06-01T00:01:00Z' - name: granularity in: query description: Only affects view=full. UTC bucket size. Defaults to minute for windows up to 6 hours, hour for windows up to 7 days, and day otherwise. The full-view window must fit at most 1500 buckets, including partial boundary buckets. schema: type: string enum: - minute - hour - day example: minute - name: compare in: query description: Requires view=full. Adds a flat summary for the previous equal-duration period. Omit to avoid the additional aggregate query. schema: type: string enum: - previous_period example: previous_period - name: view in: query description: Response detail level. Basic returns flat scalar summary fields. Full keeps the same summary fields and adds time series and resource-specific detail sections. Defaults to basic. Basic is flat counts, rates and latency percentiles, without bucket or breakdown aggregation, and has no bucket limit. Full adds every UTC time bucket, a response-time histogram and breakdowns by event data type, provider, destination type and HTTP status, and allows at most 1500 intersecting buckets. schema: type: string enum: - basic - full default: basic example: full responses: '200': description: Scalar summary metrics in both views; full adds documented detail sections. content: application/json: schema: $ref: '#/components/schemas/EventStatsResponse' examples: basic: summary: Default flat summary value: since: '2026-06-01T00:00:00Z' until: '2026-06-01T00:01:00Z' view: basic bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 response_time_samples: 1 p50_response_time_ms: 125 p95_response_time_ms: 125 p99_response_time_ms: 125 full: summary: Full analytics, including graph data value: since: '2026-06-01T00:00:00Z' until: '2026-06-01T00:01:00Z' view: full bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 response_time_samples: 1 p50_response_time_ms: 125 p95_response_time_ms: 125 p99_response_time_ms: 125 granularity: minute series: - bucket_start: '2026-06-01T00:00:00Z' bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 breakdowns: type: - type: unified_api.daily.updated payload_type: daily bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 provider: - provider: garmin bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 destination_type: - destination_type: webhook bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 http_status: - http_status: 200 bytes: 512 delivery_attempts: 1 successful_attempts: 1 failed_attempts: 0 retry_attempts: 0 success_rate: 1 response_time_histogram: - lower_bound_ms: 0 upper_bound_ms: 100 count: 0 - lower_bound_ms: 100 upper_bound_ms: 200 count: 1 - lower_bound_ms: 200 upper_bound_ms: 300 count: 0 - lower_bound_ms: 300 upper_bound_ms: 400 count: 0 - lower_bound_ms: 400 upper_bound_ms: 500 count: 0 - lower_bound_ms: 500 upper_bound_ms: 600 count: 0 - lower_bound_ms: 600 upper_bound_ms: 700 count: 0 - lower_bound_ms: 700 upper_bound_ms: 800 count: 0 - lower_bound_ms: 800 upper_bound_ms: 900 count: 0 - lower_bound_ms: 900 upper_bound_ms: 1000 count: 0 - lower_bound_ms: 1000 upper_bound_ms: 2000 count: 0 - lower_bound_ms: 2000 upper_bound_ms: 5000 count: 0 - lower_bound_ms: 5000 upper_bound_ms: null count: 0 comparison: since: '2026-05-31T23:59:00Z' until: '2026-06-01T00:00:00Z' bytes: 1024 delivery_attempts: 2 successful_attempts: 1 failed_attempts: 1 retry_attempts: 1 success_rate: 0.5 response_time_samples: 2 p50_response_time_ms: 100 p95_response_time_ms: 250 p99_response_time_ms: 250 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/events/{event_id}: get: operationId: getWebhookEvent tags: - events summary: Retrieve a webhook event description: |- Returns one webhook event with one delivery per destination it was sent to, and each request sent to that destination, newest first. - Events are kept for 30 days. security: - adminToken: - events:read parameters: - $ref: '#/components/parameters/DevId' - name: event_id in: path required: true schema: type: string description: The event to read, by the id the events list returns. responses: '200': description: The event with its deliveries. content: application/json: schema: $ref: '#/components/schemas/EventDetail' example: event_id: c9d0e1f2-3a4b-4c5d-8e9f-a0b1c2d3e4f5 type: unified_api.activity.updated payload_type: activity provider: garmin connection_id: '1937251889234671616' user_id: 3f8e2b1c-4d5a-4e6f-9a0b-1c2d3e4f5a6b reference_id: user-42 status: pending destination_count: 2 attempt_count: 3 created_at: '2026-07-02T18:04:11Z' completed_at: null deliveries: - destination_id: '1937255512398764032' destination_type: webhook destination_url: https://api.acme.com/terra/webhook status: pending last_status_code: 500 no_status_reason: null attempt_count: 2 next_attempt_at: '2026-07-02T18:05:42Z' completed_at: null attempts: - attempted_at: '2026-07-02T18:04:42Z' url: https://api.acme.com/terra/webhook status_code: 500 duration_ms: 3011 resend_id: null not_sent_reason: null - attempted_at: '2026-07-02T18:04:12Z' url: https://api.acme.com/terra/webhook status_code: 500 duration_ms: 2987 resend_id: null not_sent_reason: null - destination_id: '1937255512398764033' destination_type: s3 destination_url: null status: delivered last_status_code: 200 no_status_reason: null attempt_count: 1 next_attempt_at: null completed_at: '2026-07-02T18:04:12Z' attempts: - attempted_at: '2026-07-02T18:04:12Z' url: null status_code: 200 duration_ms: null resend_id: null not_sent_reason: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/events/{event_id}/payload: get: operationId: getWebhookEventPayload tags: - events summary: Fetch a delivery event's stored payload description: |- Returns the body delivered for an event (health data), content-addressed by event id. - The payload is retained separately from its event, for the window `event_id` states. security: - adminToken: - payloads:read parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/PayloadSamples' - name: event_id in: path required: true schema: type: string description: The delivery event to read, by the id events list returns. Bounded to the 14 days a payload is retained for. responses: '200': description: The stored payload. content: application/json: schema: type: object example: user: user_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a provider: GARMIN data: - metadata: start_time: '2026-07-02T06:31:04Z' end_time: '2026-07-02T07:12:40Z' type: 8 distance_data: summary: distance_metres: 7250.4 steps: 6812 type: activity '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/unified-api/processing: get: operationId: listProcessing tags: - unified-api summary: List processing types description: Lists the normalisation output formats with the dev-id's active selection, the second data-config axis. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The processing types. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/ProcessingType' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - type: fhir display_name: FHIR selected: false - type: fit display_name: FIT selected: false - type: json display_name: TERRA selected: true has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' patch: operationId: setProcessing tags: - unified-api summary: Set the processing type description: Switches the dev-id's normalisation output format and returns the updated list of processing types. security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - type: object - $ref: '#/components/schemas/DryRunResult' example: data: - type: fhir display_name: FHIR selected: false - type: fit display_name: FIT selected: true - type: json display_name: TERRA selected: false has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetProcessingTypeRequest' /environments/{dev_id}/tokens: get: operationId: listDataTokens tags: - tokens-and-keys summary: List a dev-id's data tokens description: |- Lists metadata for the environment's data tokens (`terra_dt_*`), the dev-scoped data-plane credential that succeeds the `client_secret`. - No bearer is returned; re-showing one is the separate `GET /environments/{dev_id}/tokens/{token_id}/secret`, which needs `keys:read`. security: - adminToken: - tokens:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The dev-id's data tokens. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/DataTokenSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - token_id: 2b3c4d5e-6f70-4a81-92b3-c4d5e6f70a81 token_hint: terra_dt_…k9zA dev_id: prod-app-x81LmQ scopes: - auth:write name: sdk-auth-only created_via: admin_api revealable: false created_at: '2026-07-03T09:15:00Z' expires_at: '2028-07-03T09:15:00Z' last_used_at: '2026-07-03T09:15:00Z' revoked_at: null has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' post: operationId: mintDataToken tags: - tokens-and-keys summary: Create a data access token description: |- Creates a long-lived data-plane token scoped to this environment and to explicit scopes (for example `auth:write` only, for SDK authentication), and returns its bearer. - Multiple tokens coexist per dev-id, so rotate by minting a new one and revoking the old; there is no shared-secret cutover. - A production environment's token is view-once (`revealable` `false`): its bearer is never stored, so save it now. - A sandbox token's bearer stays retrievable with `GET /environments/{dev_id}/tokens/{token_id}/secret` (`keys:read`), as API keys are. - An environment whose production flag is unknown counts as production. security: - adminToken: - tokens:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/MintDataTokenRequest' responses: '200': description: DryRunResult when ?dry_run=true. The preview omits token_id and token, which do not exist until the mint runs; it carries the expiry the token would get. The preview checks the current active-token limit with the same storage predicate as the write. The write rechecks it atomically; a preview does not reserve capacity. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: create preview: dev_id: prod-app-x81LmQ name: ingest worker scopes: - auth:write created_at: '2026-06-24T10:00:00Z' expires_at: '2026-09-22T10:00:00Z' last_used_at: null revoked_at: null revealable: false will_return_token: true '201': description: The minted token (bearer shown once). content: application/json: schema: $ref: '#/components/schemas/DataToken' example: token: terra_dt_Xp4…shown-once…k9zA token_id: 2b3c4d5e-6f70-4a81-92b3-c4d5e6f70a81 token_hint: terra_dt_…k9zA dev_id: prod-app-x81LmQ scopes: - auth:write name: sdk-auth-only created_via: admin_api revealable: false created_at: '2026-07-03T09:15:00Z' expires_at: '2028-07-03T09:15:00Z' last_used_at: null revoked_at: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/tokens/{token_id}: delete: operationId: revokeDataToken tags: - tokens-and-keys summary: Revoke a data access token description: Revokes a data token in this environment; revocation is immediate because tokens are validated per request. security: - adminToken: - tokens:write parameters: - $ref: '#/components/parameters/DevId' - name: token_id in: path required: true schema: type: string format: uuid description: The token to act on, by the id its creation returned. The token value itself is never accepted here. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: DryRunResult when ?dry_run=true. The preview is the token that would be revoked. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: revoke preview: token_id: 8b7f2c1e-4a5d-4f6e-9c3b-2d1a0e9f8b7a dev_id: prod-app-x81LmQ name: ingest worker scopes: - auth:write created_at: '2026-06-24T10:00:00Z' expires_at: '2026-09-22T10:00:00Z' last_used_at: null revoked_at: null '204': description: Revoked. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/tokens/{token_id}/secret: get: operationId: revealDataToken tags: - tokens-and-keys summary: Re-show a token's bearer description: |- Returns the data token including its bearer; sandbox tokens and legacy API keys stay retrievable, as the credential tokens succeed always was. - Sensitive plaintext disclosure, gated by `keys:read` (the same class as `GET /environments/{dev_id}/api-key`) and audited. - A production token minted since view-once tokens shipped (`revealable` `false`) was shown once at creation and returns `422 unsupported_operation`; mint a replacement, then revoke it. - Admin tokens and tokens outside this environment return 404. security: - adminToken: - keys:read parameters: - $ref: '#/components/parameters/DevId' - name: token_id in: path required: true schema: type: string format: uuid description: The token to act on, by the id its creation returned. The token value itself is never accepted here. responses: '200': description: The token with its bearer. content: application/json: schema: $ref: '#/components/schemas/DataToken' example: token: terra_dt_Xp4…full-bearer…k9zA token_id: 2b3c4d5e-6f70-4a81-92b3-c4d5e6f70a81 token_hint: terra_dt_…k9zA dev_id: staging-app-b52TnP scopes: - auth:write name: sdk-auth-only created_via: admin_api revealable: true created_at: '2026-07-03T09:15:00Z' expires_at: null last_used_at: '2026-07-15T08:00:00Z' revoked_at: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' /environments/{dev_id}/lab-reports/api-version: get: operationId: getLabReportsApiVersion tags: - lab-reports summary: Get the lab-reports API version pin description: |- Returns the lab-reports API version this environment's requests get when they send no `X-Terra-Version` header, with every supported version, newest first. - `pinned` is null when the environment has no pin, and such requests get the latest version. - A pin that cannot be read right now is a 503, never null. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The pin and the supported versions. content: application/json: schema: $ref: '#/components/schemas/LabReportsApiVersion' example: pinned: '2026-03-24' latest: '2026-10-21' versions: - version: '2026-10-21' summary: 'The report list is paginated: limit and cursor parameters, and a data/has_more/next_cursor envelope instead of sessions.' - version: '2026-03-24' summary: 'Original shape: the report list returns up to 500 reports in sessions, newest first, with no pagination.' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' put: operationId: setLabReportsApiVersion tags: - lab-reports summary: Change the lab-reports API version pin description: |- Pins the environment's lab-reports API version and returns the same shape as `GET /environments/{dev_id}/lab-reports/api-version`. - Any supported version can be pinned, older or newer than the current one, and takes effect on the environment's next lab-reports request. - An `X-Terra-Version` header on a request still overrides the pin for that request. - There is no unpin. - A version this API does not list is a 400. security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetLabReportsApiVersionRequest' example: version: '2026-03-24' responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/LabReportsApiVersion' - $ref: '#/components/schemas/DryRunResult' example: pinned: '2026-03-24' latest: '2026-10-21' versions: - version: '2026-10-21' summary: 'The report list is paginated: limit and cursor parameters, and a data/has_more/next_cursor envelope instead of sessions.' - version: '2026-03-24' summary: 'Original shape: the report list returns up to 500 reports in sessions, newest first, with no pagination.' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/api-version: get: operationId: getVantageApiVersion tags: - vantage summary: Get the Vantage API version pin description: |- Returns the Vantage API version this environment's requests are served in when they send no `X-Terra-Version` header, with every supported version. - `pinned` is `null` until the environment's first Vantage request pins it to the then-latest version. - A pin that cannot be read right now is a 503, never `null`. - `versions` lists every supported version, newest first. security: - adminToken: - vantageconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The pin and the supported versions. content: application/json: schema: $ref: '#/components/schemas/VantageApiVersion' example: pinned: '2026-09-27' latest: '2026-10-01' versions: - version: '2026-10-01' summary: 'Typed catalogue fields: name, description, collection method, turnaround, activation requirement and string availability.' - version: '2026-09-27' summary: Original catalogue shape with attribute bags and integer availability. '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' put: operationId: setVantageApiVersion tags: - vantage summary: Change the Vantage API version pin description: |- Pins the environment's Vantage requests to a supported API version, older or newer than the current one. - An `X-Terra-Version` header on a request still overrides the pin for that request. - There is no unpin. - A version this API does not list is a 400. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetVantageApiVersionRequest' example: version: '2026-09-27' responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/VantageApiVersion' - $ref: '#/components/schemas/DryRunResult' example: pinned: '2026-09-27' latest: '2026-10-01' versions: - version: '2026-10-01' summary: 'Typed catalogue fields: name, description, collection method, turnaround, activation requirement and string availability.' - version: '2026-09-27' summary: Original catalogue shape with attribute bags and integer availability. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/markets: get: operationId: getVantageMarkets tags: - vantage summary: Get the environment's Vantage markets description: |- Returns the markets whose products the environment's Vantage catalogue lists and its orders accept, and whether the environment can change them. - Vantage sells in the UK and the US, and each market offers different products. - `markets` is `null` until markets are chosen, while the environment has every market. - `editable` is `false` for a production environment, whose markets Terra sets during account setup; testing and staging environments choose their own. security: - adminToken: - vantageconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The environment's markets and every market Vantage sells in. content: application/json: schema: $ref: '#/components/schemas/VantageMarkets' example: markets: - uk editable: true available: - market: uk name: United Kingdom - market: us name: United States '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' put: operationId: setVantageMarkets tags: - vantage summary: Change the environment's Vantage markets description: |- Replaces the markets a testing or staging environment's Vantage catalogue lists and its orders accept, from its next request. - Products sold only in other markets leave the catalogue, and ordering one is refused. - A production environment's markets are set by Terra, so changing them here is a 422. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetVantageMarketsRequest' example: markets: - uk responses: '200': description: Updated (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/VantageMarkets' - $ref: '#/components/schemas/DryRunResult' example: markets: - uk editable: true available: - market: uk name: United Kingdom - market: us name: United States '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/webhook: get: operationId: getVantageWebhook tags: - vantage summary: Fetch the Vantage webhook description: |- Returns the HTTPS URL the environment's Vantage webhook events are delivered to, from the deployment its production setting selects. - `url` is `null` when none is set, and then events are not delivered. - Vantage keeps one webhook URL per environment, apart from unified-api destinations. - The secret deliveries are signed with is never returned here; `GET /environments/{dev_id}/vantage/webhook/secrets` reveals it under `keys:read`. security: - adminToken: - destinations:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The Vantage webhook. content: application/json: schema: $ref: '#/components/schemas/VantageWebhook' example: url: https://api.acme.com/terra/vantage '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' put: operationId: setVantageWebhook tags: - vantage summary: Replace the Vantage webhook description: |- Replaces the HTTPS URL the environment's Vantage webhook events are delivered to, production included. - Events raised while no URL is set are recorded as `canceled` with `no_status_reason` `no_destination`. - The next event is sent to the new URL, and a resend goes to it too. - The signing secret does not change; `GET /environments/{dev_id}/vantage/webhook/secrets` reveals it under `keys:read`. - A URL that is not HTTPS, or carries credentials, is a 400. - Setting the URL it already has is a noop and writes nothing; a `dry_run` preview validates the URL. security: - adminToken: - destinations:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SetVantageWebhookRequest' example: url: https://api.acme.com/terra/vantage responses: '200': description: The updated webhook, or DryRunResult when ?dry_run=true, whose preview is the webhook the write would leave. content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/VantageWebhook' - $ref: '#/components/schemas/DryRunResult' example: url: https://api.acme.com/terra/vantage '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/webhook/secrets: get: operationId: revealVantageWebhookSecrets tags: - vantage summary: Reveal the Vantage webhook's secrets description: |- Returns the secret the environment's Vantage webhook deliveries are signed with. - Each read is audited; `keys:read` makes it the same sensitive plaintext disclosure class as `GET /api-key`. - `signing_secret` is `null` while no URL is set, as nothing is delivered then. security: - adminToken: - keys:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The Vantage webhook's secrets. content: application/json: schema: $ref: '#/components/schemas/VantageWebhookSecrets' example: signing_secret: correct-horse-battery-staple '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/catalogue: get: operationId: listVantageCatalogue tags: - vantage summary: List the Vantage catalogue description: |- Lists every product in Vantage's catalogue with its variants, from the deployment the environment's production setting selects, ordered by `product_id`, complete in one response. - It is the same whatever the environment's markets: a product's `markets` says where it is sold, and the environment can enable and order it only when one of those is among its markets (`GET /environments/{dev_id}/vantage/markets`). - A variant is a way a product is sold, such as a home kit or a nurse visit. - The enabled ones are `GET /environments/{dev_id}/vantage/products` and `GET /environments/{dev_id}/vantage/variants`, which join on `product_id` and `variant_id`. security: - adminToken: - vantageconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The catalogue. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/VantageCatalogueProduct' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - product_id: '100010' name: General Health description: type: root children: - type: paragraph children: - type: text value: A broad blood panel covering heart, liver, kidney and thyroid health. bold: false italic: false strikethrough: false code: false product_type_id: '1' product_type: Blood Tests markets: - uk variants: - variant_id: '1000101' name: General Health - finger-prick kit - variant_id: '1000102' name: General Health - nurse visit at home - product_id: '200020' name: Ancestry description: type: root children: - type: paragraph children: - type: text value: A DNA test of ancestry and inherited traits. bold: false italic: false strikethrough: false code: false product_type_id: '2' product_type: DNA Tests markets: - us variants: - variant_id: '2000201' name: Ancestry - cheek swab kit has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/products: get: operationId: listVantageProducts tags: - vantage summary: List enabled Vantage products description: |- Lists the products the environment's Vantage catalogue lists and its orders accept, those sold in one of its markets that it has not disabled, ordered by `product_id`, complete in one response. - Every product in the environment's markets is enabled unless the environment disables it, including products added to the catalogue later. - A product outside its markets is never listed, enabled or not. - `GET /environments/{dev_id}/vantage/catalogue` lists every product with its markets, and joins this list on `product_id`. security: - adminToken: - vantageconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The enabled products. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/VantageProduct' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - product_id: '100010' has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/products/batch-enable: post: operationId: batchEnableVantageProducts tags: - vantage summary: Enable several Vantage products description: |- Enables up to 100 products in one transaction, so either every product is enabled or none is, and returns each product in request order. - Each is enabled exactly as the single enable does it: an already-enabled one is left as it is, so a repeat call is safe. - Products added to the catalogue later are enabled until disabled. - Every product is checked before anything is written; errors name each refused product's position in `product_ids`. - The preview's `would` is `noop` when every product is already enabled, and nothing is written. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchEnableVantageProductsRequest' example: product_ids: - '100010' - '100011' responses: '200': description: Enabled (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BatchEnabledVantageProducts' - $ref: '#/components/schemas/DryRunResult' example: data: - product_id: '100010' - product_id: '100011' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/products/batch-disable: post: operationId: batchDisableVantageProducts tags: - vantage summary: Disable several Vantage products description: |- Disables up to 100 products in one transaction, so either every product is disabled or none is. - Each is disabled exactly as the single disable does it: the catalogue stops listing it and orders for it are refused. - Orders already placed still exist, but an environment without a current Vantage grant no longer sees orders containing a disabled product in its order lists. - Every product is checked before anything is written; errors name each refused product's position in `product_ids`. - `POST /environments/{dev_id}/vantage/products/batch-enable` is the inverse. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchDisableVantageProductsRequest' example: product_ids: - '100010' - '100011' responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: disable preview: data: - product_id: '100010' - product_id: '100011' '204': description: Disabled. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/products/{product_id}: parameters: - $ref: '#/components/parameters/DevId' - name: product_id in: path required: true schema: type: string description: The product's id, as GET /environments/{dev_id}/vantage/catalogue lists it. An unknown product is a 404. put: operationId: enableVantageProduct tags: - vantage summary: Enable a Vantage product description: |- Enables one product, so the environment's Vantage catalogue lists it and its orders accept it. - The product must be sold in one of the environment's markets; one that is not is a 422, and an unknown product is a 404. - Enabling a product that is already enabled is a noop and writes nothing, so a repeat call is safe. - Every product in the environment's markets is enabled unless the environment disables it, and products added to the catalogue later are enabled until disabled. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: The enabled product (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/VantageProduct' - $ref: '#/components/schemas/DryRunResult' example: product_id: '100010' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' delete: operationId: disableVantageProduct tags: - vantage summary: Disable a Vantage product description: |- Disables one product, so the environment's Vantage catalogue stops listing it and orders for it are refused with a 403. - Orders already placed still exist, but an environment without a current Vantage grant no longer sees orders containing a disabled product in its order lists. - A product that is not enabled, including one outside the environment's markets, is a 404. - `PUT` on the same path is the inverse. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: disable preview: product_id: '100010' '204': description: Disabled. '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/variants: get: operationId: listVantageVariants tags: - vantage summary: List enabled Vantage variants description: |- Lists the variants the environment's Vantage catalogue lists and its orders accept, those of its enabled products that it has not disabled, ordered by `variant_id`, complete in one response. - Every variant of an enabled product is enabled unless the environment disables it, including variants added to the catalogue later. - A variant of a disabled product, or of one outside its markets, is never listed, enabled or not. - `GET /environments/{dev_id}/vantage/catalogue` lists every product with its variants, and joins this list on `variant_id`. security: - adminToken: - vantageconfig:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The enabled variants. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/VantageVariant' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - variant_id: '400011' product_id: '40001' has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/variants/batch-enable: post: operationId: batchEnableVantageVariants tags: - vantage summary: Enable several Vantage variants description: |- Enables up to 100 variants in one transaction, so either every variant is enabled or none is, and returns each variant in request order. - Each is enabled exactly as the single enable does it: an already-enabled one is left as it is, so a repeat call is safe. - Every variant is checked before anything is written; errors name each refused variant's position in `variant_ids`. - The preview's `would` is `noop` when every variant is already enabled, and nothing is written. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchEnableVantageVariantsRequest' example: variant_ids: - '400011' - '400012' responses: '200': description: Enabled (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/BatchEnabledVantageVariants' - $ref: '#/components/schemas/DryRunResult' example: data: - variant_id: '400011' product_id: '40001' - variant_id: '400012' product_id: '40001' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/variants/batch-disable: post: operationId: batchDisableVantageVariants tags: - vantage summary: Disable several Vantage variants description: |- Disables up to 100 variants in one transaction, so either every variant is disabled or none is. - Each is disabled exactly as the single disable does it: the catalogue stops listing it and orders for it are refused, while the product's other variants stay as they are. - Orders already placed still exist, but an environment without a current Vantage grant no longer sees orders containing a disabled variant in its order lists. - A product keeps at least one enabled variant: disable the product instead. - Every variant is checked before anything is written; errors name each refused variant's position in `variant_ids`. - `POST /environments/{dev_id}/vantage/variants/batch-enable` is the inverse. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BatchDisableVantageVariantsRequest' example: variant_ids: - '400011' - '400012' responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: disable preview: data: - variant_id: '400011' product_id: '40001' - variant_id: '400012' product_id: '40001' '204': description: Disabled. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/variants/{variant_id}: parameters: - $ref: '#/components/parameters/DevId' - name: variant_id in: path required: true schema: type: string description: The variant's id, as GET /environments/{dev_id}/vantage/catalogue lists it under its product. An unknown variant is a 404. put: operationId: enableVantageVariant tags: - vantage summary: Enable a Vantage variant description: |- Enables one variant, so the environment's Vantage catalogue lists it and its orders accept it. - Its product must be enabled and sold in one of the environment's markets; otherwise it is a 422, and an unknown variant is a 404. - Enabling a variant that is already enabled is a noop and writes nothing, so a repeat call is safe. - Every variant of an enabled product is enabled unless the environment disables it. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: The enabled variant (or DryRunResult when ?dry_run=true). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/VantageVariant' - $ref: '#/components/schemas/DryRunResult' example: variant_id: '400011' product_id: '40001' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' delete: operationId: disableVantageVariant tags: - vantage summary: Disable a Vantage variant description: |- Disables one variant, such as a product's nurse visit, so the environment's Vantage catalogue stops listing it and orders for it are refused with a 403; the product's other variants stay as they are. - Orders already placed still exist, but an environment without a current Vantage grant no longer sees orders containing a disabled variant in its order lists. - A variant that is not enabled, including one whose product is disabled or outside the environment's markets, is a 404. - The product's last enabled variant is a 422: disable the product instead. - `PUT` on the same path is the inverse. security: - adminToken: - vantageconfig:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: Dry-run preview. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: disable preview: variant_id: '400011' product_id: '40001' '204': description: Disabled. '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/events: get: operationId: listVantageEvents tags: - vantage summary: List Vantage webhook events description: |- Lists the webhook events Vantage raised for this environment, newest first, with where delivery stands: the status, the latest HTTP status and the attempt count. - An event is listed as soon as it happens, as `pending` until it is delivered; a pending event whose last attempt failed carries `next_attempt_at`, when Terra retries it. - Filters combine, and a row must match every one given. - No product grant is needed, as this is delivery metadata; the body is `GET /environments/{dev_id}/vantage/events/{event_id}/payload`, under `payloads:read`. security: - adminToken: - events:read parameters: - $ref: '#/components/parameters/DevId' - name: status in: query schema: type: string enum: - pending - delivered - failed - canceled description: Only events with this status. pending is an event not delivered yet, including one Terra will retry; delivered is a 2xx response; failed is an event Terra stopped trying to deliver; canceled is an event current access suppressed, so it was never sent. - name: event_type in: query schema: type: array items: type: string style: form explode: false description: Webhook event types, e.g. order.status_changed or order_item.results_status_change. An event matching any of them is returned; an unknown type is a 400. - name: order_id in: query schema: type: array items: type: string style: form explode: false description: Only events about these orders, matched exactly. Repeat the parameter or join the ids with commas; an event about any of them is returned. It reaches through the event's order, so it never matches a test event. - name: client_order_reference_id in: query schema: type: string description: Only events about the order with this reference, matched exactly. It reaches through the event's order, so it never matches a test event. - name: since in: query schema: type: string format: date-time description: Oldest event_created_at to return, inclusive, as RFC3339. Defaults to 30 days before until. - name: until in: query schema: type: string format: date-time description: Newest event_created_at to return, inclusive, as RFC3339. Defaults to now. - name: limit in: query schema: type: integer minimum: 1 default: 50 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window and sort the first page resolved, so since, until, order_by and order are ignored while it is set, though supplied values must still be valid. A cursor read before the environment's production setting changed is a 400. - name: order_by in: query schema: type: string enum: - event_created_at - completed_at default: event_created_at description: Field to sort by. Rows that tie fall back to event_id in the same direction, so every page is a stable slice. - $ref: '#/components/parameters/Order' responses: '200': description: A page of Vantage webhook events (keyset cursor). content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/VantageEvent' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - event_id: '249956485092777984' event_type: order.status_changed order_id: '333410942627700736' order_item_id: null client_order_reference_id: acme-order-1042 status: failed last_status_code: 500 no_status_reason: null attempt_count: 5 next_attempt_at: null completed_at: '2026-10-19T09:14:03.220Z' event_created_at: '2026-10-19T08:58:41.107Z' has_more: true next_cursor: MTc2MDg2MzkyMTEwNzAwMDAwMHwxNzU4MjcxOTIxMTA3MDAwMDAwfDE3NjA4NjM5MjExMDcwMDAwMDB8fHxjSEp2WkhWamRHbHZiZ3wyNDk5NTY0ODUwOTI3Nzc5ODQ '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/events/{event_id}: get: operationId: getVantageEvent tags: - vantage summary: Fetch a Vantage webhook event description: |- Returns one Vantage webhook event as the list returns it, plus the URL of its latest attempt and each attempt to deliver it, newest first. - Attempts are kept for 30 days, so an older event lists none. - The body is `GET /environments/{dev_id}/vantage/events/{event_id}/payload`, under `payloads:read`. security: - adminToken: - events:read parameters: - $ref: '#/components/parameters/DevId' - name: event_id in: path required: true schema: type: string description: The event to read, by the event_id the list returns. An id this environment's events do not include is a 404. responses: '200': description: The Vantage webhook event. content: application/json: schema: $ref: '#/components/schemas/VantageEventDetail' example: event_id: '249956485092777984' event_type: order.status_changed order_id: '333410942627700736' order_item_id: null client_order_reference_id: acme-order-1042 status: pending last_status_code: 500 no_status_reason: null attempt_count: 2 next_attempt_at: '2026-10-19T09:30:00.000Z' completed_at: null event_created_at: '2026-10-19T08:58:41.107Z' webhook_url: https://api.acme.com/terra/vantage attempts: - attempted_at: '2026-10-19T09:14:03.220Z' url: https://api.acme.com/terra/vantage status_code: 500 no_status_reason: null duration_ms: 412 - attempted_at: '2026-10-19T08:58:41.893Z' url: https://api.acme.com/terra/vantage status_code: null no_status_reason: connection_failed duration_ms: 10000 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/events/{event_id}/payload: get: operationId: getVantageEventPayload tags: - vantage summary: Fetch a Vantage webhook event's payload description: |- Returns the body the event's webhook carries, rebuilt from the stored event and rendered in the environment's pinned Vantage API version. - It names the test taker, so it takes the same access as reading the order: a current Vantage grant, or a verified purchase of the order; without either it is a 403. - A test event names no order and needs a current grant. - The body is readable as soon as the event exists, before it is delivered. - It is kept for 30 days after the event was created; an older event is a 404 whose remediation says so. security: - adminToken: - payloads:read parameters: - $ref: '#/components/parameters/DevId' - name: event_id in: path required: true schema: type: string description: The event to read, by the event_id the list returns. An id this environment's events do not include is a 404. responses: '200': description: The webhook body. content: application/json: schema: type: object example: event_id: '249956485092777984' event_type: order.status_changed timestamp: 1792513330 data: order_id: '333410942627700736' status: order.delivery_fulfilled '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/events/resend: post: operationId: resendVantageEvent tags: - vantage summary: Resend a Vantage webhook event description: |- Queues one Vantage webhook event to be sent again to the environment's current webhook URL, signed with its signing secret and rendered in its pinned API version. - A 202 with `dispatched` `true` means queued, not arrived; re-read the event for the outcome, where the resend replaces its earlier one. - The body is rebuilt from the stored event: it carries the status originally announced, not the order's current one, and keeps its `event_id`, so an endpoint that dedupes on it treats the resend as already processed. - An event can be resent for 30 days, then it is a 404; one still being sent is a 409 `not_ready` until its delivery has an outcome. - Without a webhook URL it is a 422; a `dry_run` preview checks the event can be resent without sending it. security: - adminToken: - events:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ResendVantageEventRequest' example: event_id: '249956485092777984' responses: '200': description: DryRunResult when ?dry_run=true. Every check a live resend makes has run; nothing is queued. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: resend preview: event_id: '249956485092777984' event_type: order.status_changed dispatched: false '202': description: Queued for redelivery. Dispatch is asynchronous, so a 202 means the event was accepted rather than delivered; re-read the event to see the outcome. content: application/json: schema: $ref: '#/components/schemas/VantageResendResult' example: event_id: '249956485092777984' event_type: order.status_changed dispatched: true '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/events/generate: post: operationId: generateVantageEvent tags: - vantage summary: Send a test Vantage webhook event description: |- Sends a generated event of one webhook type to the environment's current webhook URL through the same delivery as real events: signed with its signing secret, rendered in its pinned API version, retried the same way and listed among its events. - It carries `test` `true` and describes no real order: every order, order item, variant and test-taker id in it is `"0"`. It changes no order or result. - It is delivered only while the environment has a current Vantage grant. - Without a webhook URL it is a 422. - The response carries the payload in the latest API version; a `dry_run` preview returns it without sending. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/GenerateVantageEventRequest' example: event_type: order_item.results_status_change status: results.results_ready responses: '200': description: DryRunResult when ?dry_run=true, whose preview is the VantageGenerateResult a real call would return with dispatched false. Nothing is stored or sent, and the event_id is not a real event. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: dispatch preview: event_id: '249956485092777990' event_type: order.status_changed dispatched: false payload: event_id: '249956485092777990' event_type: order.status_changed test: true order_id: '0' status: order.delivery_fulfilled '202': description: Queued for delivery. Dispatch is asynchronous, so the event is accepted rather than delivered; it is listed among the environment's events under event_id. content: application/json: schema: $ref: '#/components/schemas/VantageGenerateResult' example: event_id: '249956485092777990' event_type: order.status_changed dispatched: true payload: event_id: '249956485092777990' event_type: order.status_changed test: true order_id: '0' status: order.delivery_fulfilled '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/orders: get: operationId: listVantageOrders tags: - vantage summary: List Vantage orders description: |- Lists the environment's Vantage orders, newest first, from the deployment its production setting selects. - Filters combine, and a row must match every one given. - Vantage applies the order read's access rule before paging: a current Vantage grant lists every order, and without one only orders with a verified purchase are listed. security: - adminToken: - vantage:read parameters: - $ref: '#/components/parameters/DevId' - name: status in: query schema: type: array items: $ref: '#/components/schemas/VantageOrderStatus' style: form explode: false description: Only orders in these statuses. An order in any of them is returned; an unknown status is a 400. - name: collection_type in: query schema: type: string enum: - AT_HOME - GO_TO_LAB description: Only home test kit (AT_HOME) or walk-in (GO_TO_LAB) orders. - name: recipient_name in: query schema: type: string description: Only orders whose recipient's full name, first then last, contains this text, ignoring case. - name: recipient_email in: query schema: type: string description: Only orders whose recipient's email contains this text, ignoring case. - name: variant_id in: query schema: type: array items: type: string style: form explode: false description: Only orders for these product variants, as the catalogue lists them. Repeat the parameter or join the ids with commas; at most 100. - name: order_id in: query schema: type: array items: type: string style: form explode: false description: Only these orders, matched exactly. Repeat the parameter or join the ids with commas; at most 100. - name: client_order_reference_id in: query schema: type: string description: Only orders for the order with this reference, matched exactly. - name: since in: query schema: type: string format: date-time description: Oldest created_at to return, inclusive, as RFC3339. Defaults to no lower bound. - name: until in: query schema: type: string format: date-time description: Newest created_at to return, inclusive, as RFC3339. Defaults to now. - name: limit in: query schema: type: integer minimum: 1 default: 50 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window and sort the first page resolved, so since, until, order_by and order are ignored while it is set, though supplied values must still be valid. A cursor read before the environment's production setting changed is a 400. - name: order_by in: query schema: type: string enum: - created_at default: created_at description: Field to sort by. Only created_at, the order an index serves; filter by status and date to narrow instead. - $ref: '#/components/parameters/Order' responses: '200': description: A page of VantageOrders (keyset cursor). content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/VantageOrder' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - order_id: '333410942627700736' client_order_reference_id: acme-order-1042 status: order.delivery_fulfilled collection_type: AT_HOME created_at: '2026-10-19T08:58:41.107Z' total_cents: 9900 currency: USD recipient: first_name: Sarah last_name: Johnson email: sarah.johnson@example.com items: - order_item_id: '333410942627700737' variant_id: '100011' product_name: General Health quantity: 1 has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/orders/{order_id}: get: operationId: getVantageOrder tags: - vantage summary: Fetch a Vantage order description: |- Returns one order with its recipient, addresses, lab, shipping, items and the order's own status history. - Results have their own status and history under results. - It takes the order read's access: a current Vantage grant, or a verified purchase of the order; without either it is a 403. security: - adminToken: - vantage:read parameters: - $ref: '#/components/parameters/DevId' - name: order_id in: path required: true schema: type: string description: The order to read. An id this environment's orders do not include is a 404. responses: '200': description: The order. content: application/json: schema: $ref: '#/components/schemas/VantageOrderDetail' example: order_id: '333410942627700736' client_order_reference_id: acme-order-1042 status: order.delivery_fulfilled collection_type: AT_HOME created_at: '2026-10-19T08:58:41.107Z' total_cents: 9900 currency: USD recipient: first_name: Sarah last_name: Johnson email: sarah.johnson@example.com phone_number: '+14155550142' date_of_birth: '1988-04-12' gender_at_birth: female shipping_address: country_code: US address_line_1: 120 Market Street address_line_2: Apt 4 city: San Francisco administrative_area: CA postal_code: '94105' requested_lab: null confirmed_lab: null shipping_carrier: USPS tracking_number: '9400111899223197428490' tracking_url: https://tools.usps.com/go/TrackConfirmAction?tLabels=9400111899223197428490 estimated_delivery_date: '2026-10-22T00:00:00.000Z' items: - order_item_id: '333410942627700737' variant_id: '100011' product_name: General Health quantity: 1 price_per_item_cents: 9900 shipping_status: delivered results_status: results.results_ready lab_tracking_number: null test_taker_id: '333410942627700738' kit_id: KIT-8F3K2Q collection_visit: null product_type_id: '1' status_history: - status: order.delivery_fulfilled changed_at: '2026-10-22T14:31:07.881Z' event_id: '7312946805437530113' - status: order.processing changed_at: '2026-10-19T09:02:10.004Z' event_id: '7311803116260720641' - status: order.payment_complete changed_at: '2026-10-19T08:58:43.512Z' event_id: '7311802248899624961' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/orders/{order_id}/payload: get: operationId: getVantageOrderPayload tags: - vantage summary: Fetch a Vantage order as the API serves it description: |- Returns the order exactly as Vantage's `GET /orders/{order_id}` serves it, rendered in the environment's pinned Vantage API version. - It names the recipient, so besides `payloads:read` it takes the order read's access: a current Vantage grant, or a verified purchase of the order. security: - adminToken: - payloads:read parameters: - $ref: '#/components/parameters/DevId' - name: order_id in: path required: true schema: type: string description: The order to read. An id this environment's orders do not include is a 404. responses: '200': description: The order body. content: application/json: schema: type: object example: order_id: '333410942627700736' client_order_reference_id: acme-order-1042 order_status: order.delivery_fulfilled collection_type: AT_HOME recipient: first_name: Sarah last_name: Johnson email: sarah.johnson@example.com items: - order_item_id: '333410942627700737' variant_id: '100011' quantity: 1 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/orders/{order_id}/simulate: post: operationId: simulateVantageOrder tags: - vantage summary: Simulate a Vantage order event description: |- Applies one lifecycle event to a sandbox order exactly as a supplier update would: the status history records it and its signed webhook is sent to the environment's webhook URL. - Only an event the order's current status accepts is applied; `GET /environments/{dev_id}/vantage/simulation` lists them. - An order event moves the order's status; a results event moves the results status of the item `order_item_id` names, or of every item when it is omitted. - `results_ready` also stores a sample result, so the result can be read and acknowledged. - A production environment cannot simulate and gets a 422. security: - adminToken: - testdata:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' - name: order_id in: path required: true schema: type: string description: The order to move. An id this environment's orders do not include is a 404. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SimulateVantageOrderRequest' example: event: kit_activated order_item_id: '333410942627700737' responses: '200': description: The event applied, or DryRunResult when ?dry_run=true, whose preview is the result a real call would return. A dry run applies nothing and sends no webhook. content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/VantageSimulateResult' - $ref: '#/components/schemas/DryRunResult' example: order_id: '333410942627700736' applied_event: kit_activated '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': description: The event is not one the current status accepts, with current_status and the valid_events it does accept; or the environment is in production, where orders cannot be simulated. content: application/problem+json: schema: allOf: - $ref: '#/components/schemas/AdminProblem' - type: object properties: current_status: type: string description: The status the event was checked against, the item's results status for a results event. valid_events: type: array description: The events that status accepts, sorted. items: type: string example: type: about:blank title: unprocessable entity detail: event "results_ready" is not a valid transition from item 333410942627700737's current results status instance: /api/v3/admin/environments/dev-a/vantage/orders/333410942627700736/simulate code: unsupported_operation remediation: Send one of valid_events, or read GET /environments/{dev_id}/vantage/simulation for every status's events. current_status: results.sample_processing_in_lab valid_events: - escalation_raised - genome_processing - lab_processing_error - sample_rejected '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/simulation: get: operationId: getVantageSimulation tags: - vantage summary: Fetch the Vantage simulation transitions description: |- Returns the events `POST /environments/{dev_id}/vantage/orders/{order_id}/simulate` accepts from each status, the rules it enforces. - Order transitions are the same for every order; results transitions depend on the item's product type, which each order item carries as `product_type_id`. - A DNA item passes through `genome_processing` on its way to `results_ready`. - A status that accepts no event is absent. - These rules are the sandbox simulator's; production status updates come from suppliers, and a production environment gets a 422. security: - adminToken: - vantage:read parameters: - $ref: '#/components/parameters/DevId' responses: '200': description: The simulation transitions. content: application/json: schema: $ref: '#/components/schemas/VantageSimulation' example: order: transitions: order.payment_processing: - cancelled - payment_complete - payment_failed order.delivery_fulfilled: - completed results: - product_type_id: '1' transitions: results.sample_processing_in_lab: - escalation_raised - lab_processing_error - partial_results_ready - results_ready - sample_rejected - product_type_id: '2' transitions: results.sample_processing_in_lab: - escalation_raised - genome_processing - lab_processing_error - sample_rejected '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/stats: get: operationId: getVantageStats tags: - vantage summary: Vantage statistics description: |- Returns Vantage statistics over [`since`, `until`), from the deployment the environment's production setting selects. - Orders count by when they were placed and by current status; results by when an item's first result arrived; failed webhooks by when delivery failed. - `current` holds point-in-time counts as of its `observed_at`, independent of the window; `timezone` echoes the zone buckets are truncated in. - `view=full` adds every bucket, the median time to result and the ten products ordered most. - Like the orders and results lists, every count covers the environment's grant or, without one, only its verified purchases. security: - adminToken: - vantage:read parameters: - $ref: '#/components/parameters/DevId' - name: since in: query description: Inclusive start in RFC3339 with at most millisecond precision. Defaults to 7 days before until. Must be within 1900-2299. schema: type: string format: date-time example: '2026-10-23T00:00:00Z' - name: until in: query description: Exclusive end in RFC3339 with at most millisecond precision. Must be after since. Must be within 1900-2299. schema: type: string format: date-time example: '2026-10-30T00:00:00Z' - name: granularity in: query description: Only affects view=full. Bucket size. Defaults to hour for windows up to 48 hours, day for windows up to 120 days, and week otherwise. The full-view window must fit at most 1500 buckets. schema: type: string enum: - hour - day - week example: day - name: compare in: query description: Requires view=full. Adds totals, time to result and a series for the previous equal-duration period. schema: type: string enum: - previous_period example: previous_period - name: timezone in: query description: IANA time zone name the buckets are truncated in. Defaults to UTC. Weeks start on Monday, and buckets are reported in UTC. schema: type: string example: America/New_York - name: view in: query description: Response detail level. Basic returns totals and current counts. Full keeps them and adds the series, time to result and breakdowns. Defaults to basic. schema: type: string enum: - basic - full default: basic example: full responses: '200': description: Totals and current counts in both views; full adds documented detail sections. content: application/json: schema: $ref: '#/components/schemas/VantageStats' examples: basic: summary: Default summary of the last 7 days value: since: '2026-10-23T00:00:00Z' until: '2026-10-30T00:00:00Z' view: basic timezone: UTC orders: total: 142 by_status: order.completed: 72 order.processing: 61 order.delayed: 1 order.payment_failed: 8 results: total: 87 webhooks: failed: 37 current: observed_at: '2026-10-30T00:00:00Z' unacknowledged_results: 2 delayed_orders: 1 payment_failed_orders_last_7d: 1 failed_webhooks_last_24h: 3 failed_results: 1 kits_awaiting_sample_14d: 2 full: summary: Daily statistics compared with the previous period value: since: '2026-10-28T00:00:00Z' until: '2026-10-30T00:00:00Z' view: full timezone: UTC orders: total: 30 by_status: order.completed: 12 order.processing: 18 results: total: 21 webhooks: failed: 3 current: observed_at: '2026-10-30T00:00:00Z' unacknowledged_results: 2 delayed_orders: 1 payment_failed_orders_last_7d: 1 failed_webhooks_last_24h: 3 failed_results: 1 kits_awaiting_sample_14d: 2 granularity: day series: - bucket_start: '2026-10-28T00:00:00Z' orders: 18 results: 10 failed_webhooks: 2 - bucket_start: '2026-10-29T00:00:00Z' orders: 12 results: 11 failed_webhooks: 1 time_to_result: median_hours: 100.8 samples: 21 breakdowns: products: - product_id: '10002' name: Essential Blood Panel orders: 20 - product_id: '10007' name: Thyroid Check orders: 10 comparison: since: '2026-10-26T00:00:00Z' until: '2026-10-28T00:00:00Z' orders: total: 25 by_status: order.completed: 25 results: total: 19 webhooks: failed: 0 time_to_result: median_hours: null samples: 0 series: - bucket_start: '2026-10-26T00:00:00Z' orders: 13 results: 9 failed_webhooks: 0 - bucket_start: '2026-10-27T00:00:00Z' orders: 12 results: 10 failed_webhooks: 0 '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/results: get: operationId: listVantageResults tags: - vantage summary: List Vantage results description: |- Lists the environment's Vantage results, one per order item that has a results status, newest order item first, from the deployment its production setting selects. - `since` and `until` bound when the results status last changed. - Filters combine. - Vantage applies the result read's access rule before paging. security: - adminToken: - vantage:read parameters: - $ref: '#/components/parameters/DevId' - name: status in: query schema: type: array items: $ref: '#/components/schemas/VantageResultStatus' style: form explode: false description: Only results whose latest stored results status is one of these, the same statuses Vantage's own results list filters on. Acknowledgement is the is_acknowledged filter and acknowledged_at, not a status. An unknown status is a 400. - name: is_acknowledged in: query schema: type: boolean description: Only results you have acknowledged (true) or not yet acknowledged (false), whatever their status. - name: variant_id in: query schema: type: array items: type: string style: form explode: false description: Only results for these product variants, as the catalogue lists them. Repeat the parameter or join the ids with commas; at most 100. - name: order_id in: query schema: type: array items: type: string style: form explode: false description: Only results for these orders, matched exactly. Repeat the parameter or join the ids with commas; at most 100. - name: client_order_reference_id in: query schema: type: string description: Only results for the order with this reference, matched exactly. - name: since in: query schema: type: string format: date-time description: Oldest updated_at to return, inclusive, as RFC3339. Defaults to no lower bound. - name: until in: query schema: type: string format: date-time description: Newest updated_at to return, inclusive, as RFC3339. Defaults to now. - name: limit in: query schema: type: integer minimum: 1 default: 50 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window and sort the first page resolved, so since, until, order_by and order are ignored while it is set, though supplied values must still be valid. A cursor read before the environment's production setting changed is a 400. - name: order_by in: query schema: type: string enum: - created_at default: created_at description: Field to sort by. Only created_at; status and status-change times are each the newest history row, so filter by status and date to narrow instead. - $ref: '#/components/parameters/Order' responses: '200': description: A page of VantageResults (keyset cursor). content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/VantageResult' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - order_item_id: '333410942627700737' order_id: '333410942627700736' client_order_reference_id: acme-order-1042 variant_id: '100011' product_name: General Health status: results.results_ready created_at: '2026-10-19T08:58:41.107Z' updated_at: '2026-10-21T16:12:42.000Z' acknowledged_at: null test_taker_id: '333410942627700738' has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/results/{order_item_id}: get: operationId: getVantageResult tags: - vantage summary: Fetch a Vantage result description: |- Returns one result with its test taker, kit and results status history, including escalations and failure causes. - It takes the result read's access: a current Vantage grant, or a verified purchase of its order. security: - adminToken: - vantage:read parameters: - $ref: '#/components/parameters/DevId' - name: order_item_id in: path required: true schema: type: string description: The order item whose result to read. One that has no results status, or is not this environment's, is a 404. responses: '200': description: The result. content: application/json: schema: $ref: '#/components/schemas/VantageResultDetail' example: order_item_id: '333410942627700737' order_id: '333410942627700736' client_order_reference_id: acme-order-1042 variant_id: '100011' product_name: General Health status: results.results_ready created_at: '2026-10-19T08:58:41.107Z' updated_at: '2026-10-21T16:12:42.000Z' acknowledged_at: null test_taker_id: '333410942627700738' test_taker: first_name: Sarah last_name: Johnson email: sarah.johnson@example.com phone_number: null date_of_birth: '1988-04-12' gender_at_birth: female result_type: fhir_bundle result_version: 1 ready_at: '2026-10-21T16:12:42.000Z' shipping_status: delivered kit_id: KIT-8F3K2Q lab_tracking_number: 1Z999AA10123456784 collection_visit: null status_history: - status: results.results_ready changed_at: '2026-10-21T16:12:42.000Z' escalation_level: not_escalated acknowledgment_due_by: '2026-10-24T16:12:42.000Z' failure_cause: null - status: results.sample_processing_in_lab changed_at: '2026-10-20T11:05:31.000Z' escalation_level: null acknowledgment_due_by: null failure_cause: null - status: results.kit_activated changed_at: '2026-10-19T18:40:12.000Z' escalation_level: null acknowledgment_due_by: null failure_cause: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/vantage/results/{order_item_id}/payload: get: operationId: getVantageResultPayload tags: - vantage summary: Fetch a Vantage result file description: |- Returns the stored result file: a FHIR bundle, or a DNA result for a DNA product. - Result files are not versioned; this is the file the result download serves. - It is health data, so besides `payloads:read` it takes the result read's access. - It is a 409 `not_ready` until the file is stored, which happens when the item's results status reaches `results.results_ready`. security: - adminToken: - payloads:read parameters: - $ref: '#/components/parameters/DevId' - name: order_item_id in: path required: true schema: type: string description: The order item whose result file to read. responses: '200': description: The result file. content: application/json: schema: type: object example: resourceType: Bundle type: collection entry: - resource: resourceType: Observation status: final code: text: Haemoglobin A1c valueQuantity: value: 5.4 unit: '%' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /environments/{dev_id}/workouts/metadata: get: operationId: listWorkoutMetadata tags: - planned-workouts responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/WorkoutMetadata' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - workout_id: '910989' created_at: '2026-05-01T12:00:00Z' pace_units: running: min_per_km has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List the dev-id's workout metadata description: |- Lists the dev-id's workout metadata rows, cursor-paginated. - Only workouts that have a metadata row appear, so this is not a list of the environment's workouts. - An environment with no rows gets an empty page, not a 404. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' /environments/{dev_id}/workouts/{workout_id}/metadata: get: operationId: getWorkoutMetadata tags: - planned-workouts responses: '200': description: OK content: application/json: schema: type: object properties: workout: $ref: '#/components/schemas/WorkoutMetadata' required: - workout example: workout: workout_id: '910989' created_at: '2026-05-01T12:00:00Z' pace_units: running: min_per_km '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Get one workout's metadata description: |- Returns Terra's own metadata for one workout, its `pace_units` and when the row was created, never the workout's data. - 404 when there is no metadata row for that id, which says nothing about whether the workout exists. security: - adminToken: - dataconfig:read parameters: - $ref: '#/components/parameters/DevId' - name: workout_id in: path required: true schema: type: string description: The workout whose metadata this addresses. This surface annotates a workout, it never creates one. put: operationId: putWorkoutMetadata tags: - planned-workouts responses: '200': description: Stored (or DryRunResult when ?dry_run=true; the preview checks the workout target and returns the same 404 as the write). content: application/json: schema: type: object anyOf: - type: object properties: workout: $ref: '#/components/schemas/WorkoutMetadata' required: - workout - $ref: '#/components/schemas/DryRunResult' example: workout: workout_id: '910989' created_at: '2026-05-01T12:00:00Z' pace_units: running: min_per_km '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Upsert a workout's metadata description: |- Sets `pace_units` on an existing workout, preserving rather than replacing what is stored. - An absent or null `pace_units` leaves the stored value in place, so this cannot clear it; `DELETE /environments/{dev_id}/workouts/{workout_id}/metadata` does. - An unknown `workout_id` is a 404. - `created_at` is accepted but ignored; the response carries the workout's own creation time. security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - name: workout_id in: path required: true schema: type: string description: The workout whose metadata this addresses. This surface annotates a workout, it never creates one. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PutWorkoutMetadataRequest' delete: operationId: deleteWorkoutMetadata tags: - planned-workouts summary: Delete a workout's metadata description: |- Deletes the workout's metadata row, the stored `pace_units`; the workout and its data are untouched. - The 204 carries nothing, so pass `dry_run=true` first for a preview of the row that would go. security: - adminToken: - dataconfig:write parameters: - $ref: '#/components/parameters/DevId' - name: workout_id in: path required: true schema: type: string description: The workout whose metadata this addresses. This surface annotates a workout, it never creates one. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: DryRunResult when ?dry_run=true. The preview is the metadata row that would be removed. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: delete preview: workout: workout_id: 3f8e2b1c-4d5a-4e6f-9a0b-1c2d3e4f5a6b dev_id: prod-app-x81LmQ pace_units: unit: min_per_km '204': description: Deleted. '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' /team/members: get: operationId: listTeamMembers tags: - team responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/TeamMemberSummary' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - user_id: usr_8f2a1c name: Alex Doe email: alex@acme.example role: admin - user_id: usr_3d9e77 name: Sam Lee email: sam@acme.example role: viewer has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: List the company's team members description: |- Lists the company's users as a lean projection of id, name, email and role, not the full user record. - Do not treat `role` as an enum: its vocabulary is not frozen yet, and it can be `null` for members carried over from the legacy path. security: - adminToken: - team:read /team/members/{user_id}: get: operationId: getTeamMember parameters: - name: user_id in: path required: true schema: type: string description: The team member's id, as returned by GET /team/members. tags: - team responses: '200': description: OK content: application/json: schema: type: object properties: user: $ref: '#/components/schemas/DashboardUser' required: - user example: user: user_id: usr_8f2a1c email: alex@acme.example verified: true name: Alex Doe phone_number: '+15551234567' created_at: '2025-01-10T09:00:00Z' last_login: '2026-07-01T09:00:00Z' company_id: cus_9f3k2m role: admin '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Get a team member description: |- Returns one member of the company by id. - `404 not_found` when `user_id` does not exist or belongs to a different company, identical either way, so it is no existence oracle. security: - adminToken: - team:read patch: operationId: patchTeamMember tags: - team responses: '200': description: Updated (or DryRunResult when ?dry_run=true, whose settles_grant_epoch reports whether the change would strand the member's tokens). content: application/json: schema: type: object anyOf: - type: object properties: user: $ref: '#/components/schemas/DashboardUser' required: - user - $ref: '#/components/schemas/DryRunResult' example: user: user_id: usr_8f2a1c email: alex@acme.example verified: true name: Alex Doe phone_number: '+15551234567' created_at: '2025-01-10T09:00:00Z' last_login: '2026-07-01T09:00:00Z' company_id: cus_9f3k2m role: editor '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Update a team member description: |- Updates a member of the company by id. - `404 not_found` when `user_id` does not exist or belongs to a different company, identical either way, so it is no existence oracle. - `409 conflict` when the change would leave the company with no admin; make another member an admin first. security: - adminToken: - team:write parameters: - name: user_id in: path required: true schema: type: string description: The team member's id, as returned by GET /team/members. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/PatchTeamMemberRequest' delete: operationId: removeTeamMember tags: - team responses: '200': description: DryRunResult when ?dry_run=true. The preview is the member that would be removed, or reports that nothing would change when the user is not a member (the live DELETE is idempotent). content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: delete preview: user: user_id: usr_8f2a1c email: dana@example.com role: developer revokes_tokens: true '204': description: Detached (or already not a member — idempotent). '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' summary: Remove a team member from the company description: |- Detaches a user from the company by clearing their `company_id`; it never touches a row in another company. - Idempotent: removing a user who is already not a member is not an error. - `409 conflict` when the user is the company's last admin; make another member an admin first. security: - adminToken: - team:write parameters: - name: user_id in: path required: true schema: type: string description: The team member's id, as returned by GET /team/members. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' /environments/{dev_id}/models/runs: get: operationId: listModelRuns tags: - models summary: Model-run history description: |- Lists a page of the environment's model runs, newest first, one per `GET /v2/models/run` call. - Runs come from a 30-day run log. security: - adminToken: - models:read parameters: - $ref: '#/components/parameters/DevId' - name: user_id in: query schema: type: string format: uuid description: Terra user id whose runs to return, matched against the id stored on the run itself. The stored Terra user UUID is matched directly, with no resolution. - name: model in: query schema: type: string description: One model name, matched exactly. An unrecognised name is an empty page rather than a 400, since this plane does not carry the model catalog. - name: status in: query schema: type: string enum: - success - error description: Outcome of the run. - name: run_id in: query schema: type: string description: Exact run id within the selected window. Defaults to the last 30 days, as browsing does; since, until and cursor still apply. - name: q in: query schema: type: string minLength: 3 maxLength: 128 description: A case-insensitive substring to find in the run's user_id, run_id or error, trimmed, 3 to 128 characters. Combines with every other filter and with cursor paging, except run_id, which is a 400. - name: since in: query schema: type: string format: date-time description: Oldest submitted_at to return, inclusive, as RFC3339. Defaults to 30 days before until, which is the whole retained history. - name: until in: query schema: type: string format: date-time description: Newest submitted_at to return, inclusive, as RFC3339. Defaults to now. - name: limit in: query schema: type: integer default: 50 minimum: 1 description: Rows per page. Defaults to 50; a larger value is clamped to 200 rather than refused. - name: cursor in: query schema: type: string description: The previous page's next_cursor. It carries the window the first page resolved, so since and until are ignored while it is set. responses: '200': description: A page of model runs (keyset cursor). content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/ModelRunRecord' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - run_id: 5f0b7d2e-9c1a-4e5b-8f3d-6a7b8c9d0e1f user_id: 00000000-0000-0000-0000-000000000101 model: sleep-quality status: success latency_ms: 412 start_time: '2026-07-09T00:00:00Z' end_time: '2026-07-16T00:00:00Z' submitted_at: '2026-07-16T09:14:02.113Z' output_truncated: false output: score: 82 has_more: false next_cursor: null '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '503': $ref: '#/components/responses/ServiceUnavailable' /models/catalog: get: operationId: getModelsCatalog tags: - models summary: Models catalog description: |- Returns the static catalog of generally-available models the Models product exposes. - Account-level and identical for every caller. - Run a model with `GET /v2/models/run`; `GET /environments/{dev_id}/models/runs` lists an environment's runs. security: - adminToken: - models:read responses: '200': description: The catalog of GA models. content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/ModelCatalogEntry' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - id: health_terrain name: Health Terrain description: Maps how a user's body shifted over a week across 15 broad health areas, relative to their own recent baseline. A wellness indicator, not a medical diagnosis. data_type: daily - id: sleep_window name: Sleep Window description: Recommends a steady, personalised sleep schedule to help keep sleep and wake times consistent. A wellness indicator, not a medical tool. data_type: sleep has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' /team/invitations: post: operationId: createTeamInvitation tags: - team summary: Invite someone to the company description: |- Records a pending membership in the caller's own company and returns the one-use invitation token. - The company comes from the token's principal and cannot be named in the body. - Only the token's digest is stored, so this response is the only copy: a lost token must be replaced, not recovered. - The invitee redeems it during dashboard sign-in, which is where the company and role are applied. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateTeamInvitationRequest' responses: '200': description: DryRunResult when ?dry_run=true. The preview carries the deterministic expiry; the invitation token itself does not exist until the invitation does. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: create preview: email: dana@example.com role: developer expires_at: '2026-07-01T10:00:00Z' will_return_token: true '201': description: Created content: application/json: schema: $ref: '#/components/schemas/TeamInvitationResponse' example: token: gJ7pR2mQx4Vd8sLwK1nZbT6yH0aCfEu3 expires_at: '2026-08-05T09:15:00Z' '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '409': $ref: '#/components/responses/Conflict' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' security: - adminToken: - team:write parameters: - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' get: operationId: listTeamInvitations tags: - team summary: List outstanding invitations description: |- Lists the caller's company's invitations that are still claimable: unclaimed and unexpired. - Claimed and expired invitations stay on record as what happened but are not listed. - The invitation token is never returned: only its digest is stored, so an invitation cannot be recovered, only revoked and reissued. responses: '200': description: OK content: application/json: schema: type: object properties: data: type: array items: $ref: '#/components/schemas/TeamInvitation' has_more: type: boolean next_cursor: type: - string - 'null' required: - data - has_more - next_cursor example: data: - id: 3f1c0a7e-9b52-4d61-8a3f-5c9e2d7b1a04 company_id: cus_acme email: new.engineer@acme.test role: developer source: null invited_by_user_id: usr_admin_acme created_at: '2026-07-29T09:15:00Z' expires_at: '2026-08-05T09:15:00Z' claimed_at: null claimed_by_user_id: null has_more: false next_cursor: null '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' security: - adminToken: - team:read /team/invitations/{invitation_id}: delete: operationId: revokeTeamInvitation tags: - team summary: Revoke an invitation description: |- Withdraws an unclaimed invitation in the caller's company. - The delete carries the caller's own company, so an id belonging to another company matches nothing and answers 404 rather than confirming it exists. - A claimed invitation is also a 404: that person is already a member, and removing them is `DELETE /team/members/{user_id}`. parameters: - name: invitation_id in: path required: true schema: type: string description: The invitation's id, as returned by GET /team/invitations. - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' responses: '200': description: DryRunResult when ?dry_run=true. The preview is the pending invitation that would be revoked. content: application/json: schema: $ref: '#/components/schemas/DryRunResult' example: dry_run: true would: revoke preview: invitation: id: inv_7d2f1c3a email: dana@example.com role: developer created_at: '2026-06-24T10:00:00Z' expires_at: '2026-07-01T10:00:00Z' '204': description: No Content '400': $ref: '#/components/responses/ValidationError' '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' '503': $ref: '#/components/responses/ServiceUnavailable' security: - adminToken: - team:write /environments/{dev_id}/api-key/rotate: post: operationId: rotateEnvironmentApiKey tags: - tokens-and-keys responses: '200': description: Rotated (or DryRunResult when ?dry_run=true; the new key is never previewed). content: application/json: schema: type: object anyOf: - $ref: '#/components/schemas/RotatedApiKey' - $ref: '#/components/schemas/DryRunResult' example: dev_id: prod-app-x81LmQ api_key: 6f8c…new-secret…2a1b '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/RateLimited' '500': $ref: '#/components/responses/InternalError' summary: Replace your API key security: - adminToken: - keys:write parameters: - $ref: '#/components/parameters/DevId' - $ref: '#/components/parameters/DryRun' - $ref: '#/components/parameters/IdempotencyKey' description: |- Mints a new API key for this environment and returns it; the rotated-away key stops working immediately. - Needs `keys:write`, the dangerous scope reserved for legacy-key mutation, which a default token does not hold; `keys:read` alone reveals the key but never rotates it. - Prefer coexisting data tokens (mint new, revoke old), which need no atomic swap; this exists for the dashboard settings page's legacy key. components: securitySchemes: adminToken: type: oauth2 description: |- An admin access token (`terra_at_*`), scoped to one customer. Get one with the RFC 8628 device flow (`POST /auth/device`, approve in the dashboard, poll `POST /auth/token`), the authorization-code grant (`GET /auth/authorize`, consent in the dashboard, S256 exchange at `POST /auth/token`), or from the dashboard. - This API accepts only admin tokens. Data tokens (`terra_dt_*`, minted at `POST /environments/{dev_id}/tokens`) authenticate only the APIs your product calls at runtime, under `/api/v2` and `/api/v3`. - Each operation names the scope it needs. An admin token may also be limited to some environments. - The scopes below cover both planes. `POST /auth/device` grants only admin-plane scopes and refuses the rest with 400 `invalid_scope`; `x-scope-planes` says which plane each scope belongs to, and a data-plane scope's description starts with `Data plane:`. - `x-scope-dangerous` (off by default, mapped to what each puts at stake), `x-scope-sensitive` (on by default, labelled), `x-scope-account-level` (not available to an environment-limited token) and `x-scope-presets` (the approval page's grant sets) classify the admin scopes. Each scope's description is the sentence the approval page shows. - The `deviceAuthorization` flow is the device grant and the `authorizationCode` flow the browser grant; both take the same scopes. There is no client-credentials grant: the `clientCredentials` flow only carries the scopes and the `x-scope-*` lists, where existing clients read them. flows: clientCredentials: tokenUrl: /api/v3/admin/auth/token scopes: account:read: See your account details and environment IDs. keys:read: See your API key, the secret values of your data access tokens and the credentials your destinations use. keys:write: Replace your API key. Anything using the old key will stop working. providers:read: See which wearables and apps are turned on, and their settings. providers:write: Turn wearables and apps on or off, and change their sign-in settings. destinations:read: See where your data is sent, like a webhook or Supabase. destinations:write: Add, change or remove where your data is sent. events:read: See a log of the data sent to you, without its contents. events:write: Send data again. connections:read: See which of your users have connected. payloads:read: See your users' health data, both what was sent to you and what is stored for them. dataconfig:read: See which health data fields you get. dataconfig:write: Change which health data fields you get. vantageconfig:read: See which Vantage products and markets are turned on, and the products you can turn on. vantageconfig:write: Turn Vantage products and markets on or off, and change the Vantage API version. scores:read: See which scores are turned on, and their settings. scores:write: Turn scores on and change their settings. models:read: See the available models and their past results. models:run: 'Data plane: run a model over a user''s stored data.' workouts:read: 'Data plane: read workout templates and planned workouts.' workouts:write: 'Data plane: create workout templates and plan workouts for users.' labreports:read: 'Data plane: read lab reports.' labreports:write: 'Data plane: reprocess or delete lab reports.' testdata:write: Send made-up health data to where your data goes, from one-off events or test users you can start and stop. billing:read: See your plan, invoices, payment method and usage. billing:write: Change your plan, pay invoices and update payment details. This can spend money. tokens:admin: See and revoke every token across your account, including other people's. entitlements:read: See which features your company has access to. auth:write: 'Data plane: create user authentication flows — widget sessions, auth tokens (in place of a client_secret).' connections:write: 'Data plane: deauthenticate users and update connection attributes.' data:read: 'Data plane: read stored end-user health data (activity, sleep, body, …).' data:write: 'Data plane: push or delete end-user health data.' routes:read: 'Data plane: read routes and pushed routes.' routes:write: 'Data plane: create, update, push, and delete routes.' datalinks:read: 'Data plane: read data links.' datalinks:write: 'Data plane: create and delete data links.' graphs:read: 'Data plane: read graph sessions.' graphs:write: 'Data plane: create and manage graph sessions (public renders of health data).' vantage:read: See your Vantage orders and results, including who they are for. vantage:write: 'Data plane: create Vantage orders, simulate orders and update configuration or result acknowledgments. Includes vantage:read.' agents:read: 'Data plane: read agents, bundles, jobs, and schedules.' agents:write: 'Data plane: create, update, and delete agents and their configuration.' agents:run: 'Data plane: execute agents and bundles (incurs model spend).' ai:run: 'Data plane: run AI-context queries and the MCP proxy.' tokens:read: See the data access tokens in an environment, but not their secret values. tokens:write: Create and revoke data access tokens in an environment, including other people's. A new token can do anything it's given access to. account:write: Change your profile and your company's details. team:read: See who is on your team. team:write: Invite, change or remove team members. This can take away someone's access. x-scope-planes: account:read: admin keys:read: admin keys:write: admin providers:read: both providers:write: both destinations:read: admin destinations:write: admin events:read: admin events:write: both connections:read: both payloads:read: admin dataconfig:read: admin dataconfig:write: admin vantageconfig:read: admin vantageconfig:write: admin scores:read: admin scores:write: admin models:read: both models:run: data workouts:read: data workouts:write: data labreports:read: data labreports:write: data testdata:write: both billing:read: admin billing:write: admin tokens:admin: admin entitlements:read: admin auth:write: data connections:write: data data:read: data data:write: data routes:read: data routes:write: data datalinks:read: data datalinks:write: data graphs:read: data graphs:write: data vantage:read: both vantage:write: data agents:read: data agents:write: data agents:run: data ai:run: data tokens:read: admin tokens:write: admin account:write: admin team:read: admin team:write: admin x-scope-dangerous: billing:write: money keys:write: access team:write: team tokens:admin: access tokens:write: access x-scope-sensitive: - keys:read - payloads:read - vantage:read x-scope-account-level: - account:read - account:write - billing:read - billing:write - entitlements:read - team:read - team:write - tokens:admin x-scope-presets: - name: Coding agent mcp_name: MCP mcp_summary: Connect an AI assistant. Reads integration data, writes integration config, resends events and creates test users. Cannot spend, remove people, issue credentials, or rotate the key. summary: A developer or their coding agent at the terminal. Reads everything, writes integration config, resends events, creates test users. Cannot spend, remove people, issue credentials, or rotate the key. scopes: - account:read - account:write - billing:read - connections:read - dataconfig:read - dataconfig:write - destinations:read - destinations:write - entitlements:read - events:read - events:write - keys:read - models:read - payloads:read - providers:read - providers:write - scores:read - scores:write - team:read - testdata:write - tokens:read - vantage:read - vantageconfig:read - vantageconfig:write - name: Read only summary: Auditing, onboarding a teammate, or a demo. Every read except credential material, payload bodies and Vantage orders and results. scopes: - account:read - billing:read - connections:read - dataconfig:read - destinations:read - entitlements:read - events:read - models:read - providers:read - scores:read - team:read - tokens:read - vantageconfig:read - name: Full access summary: Every admin-grantable scope, dangerous ones included. scopes: - account:read - account:write - billing:read - billing:write - connections:read - dataconfig:read - dataconfig:write - destinations:read - destinations:write - entitlements:read - events:read - events:write - keys:read - keys:write - models:read - payloads:read - providers:read - providers:write - scores:read - scores:write - team:read - team:write - testdata:write - tokens:admin - tokens:read - tokens:write - vantage:read - vantageconfig:read - vantageconfig:write x-not-a-real-flow: Scope registry only. Token issuance is the device flow or the authorizationCode flow (see scheme description); this tokenUrl does not accept client_credentials grants. authorizationCode: authorizationUrl: /api/v3/admin/auth/authorize tokenUrl: /api/v3/admin/auth/token scopes: account:read: See your account details and environment IDs. keys:read: See your API key, the secret values of your data access tokens and the credentials your destinations use. keys:write: Replace your API key. Anything using the old key will stop working. providers:read: See which wearables and apps are turned on, and their settings. providers:write: Turn wearables and apps on or off, and change their sign-in settings. destinations:read: See where your data is sent, like a webhook or Supabase. destinations:write: Add, change or remove where your data is sent. events:read: See a log of the data sent to you, without its contents. events:write: Send data again. connections:read: See which of your users have connected. payloads:read: See your users' health data, both what was sent to you and what is stored for them. dataconfig:read: See which health data fields you get. dataconfig:write: Change which health data fields you get. vantageconfig:read: See which Vantage products and markets are turned on, and the products you can turn on. vantageconfig:write: Turn Vantage products and markets on or off, and change the Vantage API version. scores:read: See which scores are turned on, and their settings. scores:write: Turn scores on and change their settings. models:read: See the available models and their past results. models:run: 'Data plane: run a model over a user''s stored data.' workouts:read: 'Data plane: read workout templates and planned workouts.' workouts:write: 'Data plane: create workout templates and plan workouts for users.' labreports:read: 'Data plane: read lab reports.' labreports:write: 'Data plane: reprocess or delete lab reports.' testdata:write: Send made-up health data to where your data goes, from one-off events or test users you can start and stop. billing:read: See your plan, invoices, payment method and usage. billing:write: Change your plan, pay invoices and update payment details. This can spend money. tokens:admin: See and revoke every token across your account, including other people's. entitlements:read: See which features your company has access to. auth:write: 'Data plane: create user authentication flows — widget sessions, auth tokens (in place of a client_secret).' connections:write: 'Data plane: deauthenticate users and update connection attributes.' data:read: 'Data plane: read stored end-user health data (activity, sleep, body, …).' data:write: 'Data plane: push or delete end-user health data.' routes:read: 'Data plane: read routes and pushed routes.' routes:write: 'Data plane: create, update, push, and delete routes.' datalinks:read: 'Data plane: read data links.' datalinks:write: 'Data plane: create and delete data links.' graphs:read: 'Data plane: read graph sessions.' graphs:write: 'Data plane: create and manage graph sessions (public renders of health data).' vantage:read: See your Vantage orders and results, including who they are for. vantage:write: 'Data plane: create Vantage orders, simulate orders and update configuration or result acknowledgments. Includes vantage:read.' agents:read: 'Data plane: read agents, bundles, jobs, and schedules.' agents:write: 'Data plane: create, update, and delete agents and their configuration.' agents:run: 'Data plane: execute agents and bundles (incurs model spend).' ai:run: 'Data plane: run AI-context queries and the MCP proxy.' tokens:read: See the data access tokens in an environment, but not their secret values. tokens:write: Create and revoke data access tokens in an environment, including other people's. A new token can do anything it's given access to. account:write: Change your profile and your company's details. team:read: See who is on your team. team:write: Invite, change or remove team members. This can take away someone's access. deviceAuthorization: deviceAuthorizationUrl: /api/v3/admin/auth/device tokenUrl: /api/v3/admin/auth/token scopes: account:read: See your account details and environment IDs. keys:read: See your API key, the secret values of your data access tokens and the credentials your destinations use. keys:write: Replace your API key. Anything using the old key will stop working. providers:read: See which wearables and apps are turned on, and their settings. providers:write: Turn wearables and apps on or off, and change their sign-in settings. destinations:read: See where your data is sent, like a webhook or Supabase. destinations:write: Add, change or remove where your data is sent. events:read: See a log of the data sent to you, without its contents. events:write: Send data again. connections:read: See which of your users have connected. payloads:read: See your users' health data, both what was sent to you and what is stored for them. dataconfig:read: See which health data fields you get. dataconfig:write: Change which health data fields you get. vantageconfig:read: See which Vantage products and markets are turned on, and the products you can turn on. vantageconfig:write: Turn Vantage products and markets on or off, and change the Vantage API version. scores:read: See which scores are turned on, and their settings. scores:write: Turn scores on and change their settings. models:read: See the available models and their past results. models:run: 'Data plane: run a model over a user''s stored data.' workouts:read: 'Data plane: read workout templates and planned workouts.' workouts:write: 'Data plane: create workout templates and plan workouts for users.' labreports:read: 'Data plane: read lab reports.' labreports:write: 'Data plane: reprocess or delete lab reports.' testdata:write: Send made-up health data to where your data goes, from one-off events or test users you can start and stop. billing:read: See your plan, invoices, payment method and usage. billing:write: Change your plan, pay invoices and update payment details. This can spend money. tokens:admin: See and revoke every token across your account, including other people's. entitlements:read: See which features your company has access to. auth:write: 'Data plane: create user authentication flows — widget sessions, auth tokens (in place of a client_secret).' connections:write: 'Data plane: deauthenticate users and update connection attributes.' data:read: 'Data plane: read stored end-user health data (activity, sleep, body, …).' data:write: 'Data plane: push or delete end-user health data.' routes:read: 'Data plane: read routes and pushed routes.' routes:write: 'Data plane: create, update, push, and delete routes.' datalinks:read: 'Data plane: read data links.' datalinks:write: 'Data plane: create and delete data links.' graphs:read: 'Data plane: read graph sessions.' graphs:write: 'Data plane: create and manage graph sessions (public renders of health data).' vantage:read: See your Vantage orders and results, including who they are for. vantage:write: 'Data plane: create Vantage orders, simulate orders and update configuration or result acknowledgments. Includes vantage:read.' agents:read: 'Data plane: read agents, bundles, jobs, and schedules.' agents:write: 'Data plane: create, update, and delete agents and their configuration.' agents:run: 'Data plane: execute agents and bundles (incurs model spend).' ai:run: 'Data plane: run AI-context queries and the MCP proxy.' tokens:read: See the data access tokens in an environment, but not their secret values. tokens:write: Create and revoke data access tokens in an environment, including other people's. A new token can do anything it's given access to. account:write: Change your profile and your company's details. team:read: See who is on your team. team:write: Invite, change or remove team members. This can take away someone's access. x-grant-type: urn:ietf:params:oauth:grant-type:device_code sessionToken: type: http scheme: bearer bearerFormat: terra_st_... description: 'A dashboard session token, minted per login. Routes that record who a person is talking to accept ONLY this kind — a device-flow admin token carrying the same scopes is rejected. Scopes are enforced per operation and named in each description: an HTTP bearer scheme cannot carry an OAuth2 scope list, so the security requirement is necessarily empty.' parameters: SyntheticUserId: name: user_id in: path required: true schema: type: string format: uuid description: The synthetic user to act on, by the id its creation returned. DevId: name: dev_id in: path required: true schema: type: string description: The developer-id (the only tenant-targeting input). IdempotencyKey: name: Idempotency-Key in: header required: false schema: type: string description: 'Stripe-style idempotency: same key + same body replays the stored response; same key + different body → 409. Mutations only.' DryRun: name: dry_run in: query required: false schema: type: boolean description: When true the operation commits nothing and answers 200 with a DryRunResult — {dry_run, would, preview} — whatever its live success code is. Operations whose live success is also 200 publish both the live response and DryRunResult in the response schema. Order: name: order in: query required: false schema: type: string enum: - asc - desc default: desc description: Direction of the order_by sort. Defaults to desc. A cursor keeps the order its first page was read in, so order is ignored while cursor is set, though it must still be valid. PayloadSamples: name: samples in: query required: false schema: type: boolean default: true description: When false, arrays named samples or ending in _samples are removed from the returned payload, which keeps it small enough to read. It changes only this response; the stored payload keeps its samples. responses: Unauthorized: description: Missing/invalid/expired admin token. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: unauthorized detail: unknown access token instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: unauthorized remediation: Obtain a new one via the device flow or your dashboard. Forbidden: description: The token is missing the required scope. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: forbidden detail: 'token is missing the required scope: providers:write' instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: scope_missing remediation: Request a new token that includes providers:write (device flow or dashboard) and approve the additional scope. NotFound: description: Resource not found (or not owned — no existence oracle). content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: not found detail: dev-id not found instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: dev_id_not_found remediation: Confirm the dev-id via `GET /environments`. ValidationError: description: Request validation failed (see errors[]). content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: bad request detail: approved scope was not requested instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: validation_failed errors: - 'scopes: at least one required' RateLimited: description: Per-token rate limit exceeded; see Retry-After. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: too many requests detail: per-token rate limit exceeded instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: rate_limited remediation: Back off and retry after the Retry-After interval. Conflict: description: Idempotency-Key reuse with a different body, or a precondition conflict. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: conflict detail: the account has reached its active-token limit instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: token_limit_reached remediation: Revoke unused tokens, then retry. ServiceUnavailable: description: A required subsystem is not available on this deployment. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: service unavailable detail: billing is not available on this deployment instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: service_unavailable InternalError: description: Unexpected server-side failure while processing the request. content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: internal server error detail: an internal error occurred instance: /api/v3/admin/company code: internal_error UnprocessableEntity: description: The request is well-formed but the target resource can't perform it (e.g. provider disallows custom credentials). content: application/problem+json: schema: $ref: '#/components/schemas/AdminProblem' example: type: about:blank title: unprocessable entity detail: this provider does not support custom credentials instance: /api/v3/admin/environments/prod-app-x81LmQ/unified-api/sources/garmin code: unsupported_operation schemas: AccountSummary: type: object properties: customer_id: type: string dev_id_count: type: integer company: $ref: '#/components/schemas/CompanyProfile' billing: description: Whether the account has a billing account. Never carries its identifiers. null exactly when `company` is null. oneOf: - $ref: '#/components/schemas/AccountBilling' - type: 'null' required: - billing PayInvoiceRequest: type: object properties: invoice_id: type: string description: Invoice belonging to this account. required: - invoice_id InvoiceDetailsRequest: type: object properties: billing_name: type: string description: Legal entity invoices are billed to. Omitted keeps the current name. tax_id: type: string description: EU (including XI), UK or Swiss (CHE…MWST/TVA/IVA/VAT) VAT number. Replaces any other number of the same type; other regimes are rejected. startup_onboarding: type: boolean description: 'First event-plan onboarding. Only first customer creation sets the historical startup credit alert threshold; an existing customer is unchanged. Rejected once the company has finished onboarding, and on its own: billing_name or tax_id is required.' BillingState: type: object properties: state: type: string enum: - ok - requires_action - closed payment_url: type: string description: Stripe-hosted invoice URL where the human finishes payment. Present only with requires_action. client_secret: type: string description: Invoice confirmation secret for embedded Stripe confirmation. Only returned for pending payment to the authenticated billing caller; never log or persist in dashboard caches. cancelled: type: integer description: Number of incomplete subscriptions cancelled by the explicit cancellation operation. cancelled_operation_keys: type: array description: Supplied operation keys confirmed to belong to this customer's canceled or incomplete_expired subscriptions, including earlier cancellations whose response was lost. Active subscriptions and pending updates are excluded. items: type: string required: - state BatchCreateDestinationsRequest: type: object properties: items: type: array description: 'The destinations to create, each shaped like a single create: at least 1 and at most 100. Every item is validated before anything is written, and an invalid one is a 400 naming its position, so either every destination is created or none is. Through the MCP, a batch whose result would not fit in one tool result is a 400 asking for smaller batches.' items: $ref: '#/components/schemas/BatchDestinationItem' minItems: 1 maxItems: 100 required: - items BatchCreatedDestinations: type: object properties: data: type: array description: One created destination per item, in request order. items: $ref: '#/components/schemas/CreatedDestination' required: - data BatchDestinationItem: type: object properties: type: type: string description: Where data is delivered, e.g. webhook, s3, gcs. Omitted defaults to webhook, which is the common case; an unrecognised type is a 400. default: webhook config: description: The type's configuration; GET unified-api/destination-types lists each type's fields. An active destination needs every required field, and each missing one is a 400 naming it. An inactive destination may be saved incomplete as a draft and finished with a PATCH. anyOf: - $ref: '#/components/schemas/WebhookDestinationConfig' - $ref: '#/components/schemas/S3DestinationConfig' - $ref: '#/components/schemas/SqsDestinationConfig' - $ref: '#/components/schemas/GcsDestinationConfig' - $ref: '#/components/schemas/FirestoreDestinationConfig' - $ref: '#/components/schemas/SupabaseDestinationConfig' - $ref: '#/components/schemas/MongodbDestinationConfig' - $ref: '#/components/schemas/KafkaDestinationConfig' - $ref: '#/components/schemas/SqlDestinationConfig' - $ref: '#/components/schemas/AzureblobDestinationConfig' event_types: type: array description: Which events to deliver here, as a list of event-type names. Omitted or empty delivers every event type, and an unrecognised name is a 400 naming it. items: type: string active: type: boolean description: Whether to start delivering immediately. Omitted defaults to true. default: true signing_secret_source: type: string enum: - destination description: 'Deprecated: every webhook signs with its own secret, generated here and returned once. Webhooks only; environment is rejected.' default: destination BatchDisableSourcesRequest: type: object properties: providers: type: array description: 'The providers to disable, as slugs, e.g. garmin: at least 1 and at most 100, each listed once. An unrecognised or repeated provider is a 400, and one that is not enabled is a 404, each naming its position, and then nothing is disabled.' items: type: string minItems: 1 maxItems: 100 uniqueItems: true required: - providers BatchEnableSourcesRequest: type: object properties: providers: type: array description: 'The providers to enable, as slugs, e.g. garmin: at least 1 and at most 100, each listed once. An unrecognised or repeated provider is a 400, and one in private preview for which this environment has no preview is a 422, each naming its position, and then nothing is enabled.' items: type: string minItems: 1 maxItems: 100 uniqueItems: true required: - providers BatchEnabledSources: type: object properties: data: type: array description: One entry per requested provider, in request order. items: $ref: '#/components/schemas/Source' required: - data CompanyProfile: type: - object - 'null' description: dashboard.company_info row for the customer, joined with its dashboard.company_billing row, or null if no company_info row exists yet. The billing columns (stripe_customer_id, stripe_subscription_id, stripe_metering_type) are never included in the response. additionalProperties: true CreateDestinationRequest: type: object properties: type: type: string description: Where data is delivered, e.g. webhook, s3, gcs. Omitted defaults to webhook, which is the common case; an unrecognised type is a 400. default: webhook config: description: The type's configuration; GET unified-api/destination-types lists each type's fields. An active destination needs every required field, and each missing one is a 400 naming it. An inactive destination may be saved incomplete as a draft and finished with a PATCH. anyOf: - $ref: '#/components/schemas/WebhookDestinationConfig' - $ref: '#/components/schemas/S3DestinationConfig' - $ref: '#/components/schemas/SqsDestinationConfig' - $ref: '#/components/schemas/GcsDestinationConfig' - $ref: '#/components/schemas/FirestoreDestinationConfig' - $ref: '#/components/schemas/SupabaseDestinationConfig' - $ref: '#/components/schemas/MongodbDestinationConfig' - $ref: '#/components/schemas/KafkaDestinationConfig' - $ref: '#/components/schemas/SqlDestinationConfig' - $ref: '#/components/schemas/AzureblobDestinationConfig' event_types: type: array description: Which events to deliver here, as a list of event-type names. Omitted or empty delivers every event type, and an unrecognised name is a 400 naming it. items: type: string active: type: boolean description: Whether to start delivering immediately. Omitted defaults to true. default: true signing_secret_source: type: string enum: - destination description: 'Deprecated: every webhook signs with its own secret, generated here and returned once. Webhooks only; environment is rejected.' default: destination url: type: string description: 'Deprecated: send config instead. The delivery location in the stored form; cannot be combined with config.' deprecated: true metadata: type: string description: 'Deprecated: send config instead. Credential JSON in the stored form; cannot be combined with config.' deprecated: true CreateTeamInvitationRequest: type: object description: 'A new invitation. There is deliberately no company_id and no source: the invited company is the caller''s own, read from the token''s principal, and source is provenance a customer-authenticated caller must not be able to set (it would let an invite grant a capability nobody sanctioned). Both are rejected, not ignored.' properties: email: type: string format: email description: The address being invited. The claim only succeeds for a user signing in with this address. role: type: string enum: - admin - developer description: The role the invitee gets on joining. superadmin is not assignable, matching PATCH /team/members/{user_id}. required: - email - role additionalProperties: false CreatedDestination: type: object description: A newly created destination, plus its own webhook signing secret when it is a webhook. properties: id: type: string description: string-encoded 64-bit id type: type: string url: type: string description: Where the destination delivers, as stored, without any embedded user and password. An azureblob URL omits its SAS token, which retrieving the destination's secrets returns. active: type: boolean event_types: type: array description: The event types delivered here. An empty list delivers every event type. items: type: string disabled_reason: type: - string - 'null' enum: - owner - auto_disabled_failed_delivery - unrecorded - null description: 'Why the destination is off: owner (turned off through the API or dashboard), auto_disabled_failed_delivery (Terra turned it off after deliveries failed for 24 hours), or unrecorded (turned off before Terra recorded why). Null while active.' disabled_at: type: - string - 'null' format: date-time description: When the destination was turned off. Null while active, and when it was turned off before Terra recorded when (disabled_reason unrecorded). configured: type: boolean description: Whether the configuration has every field the type needs to deliver. A draft saved inactive reads false until it is completed. missing: type: array description: The required configuration fields still unset, as config.. Empty when configured. items: type: string config: description: Null when the stored configuration cannot be read; configured is then false, and config cannot be changed until the destination is recreated. anyOf: - $ref: '#/components/schemas/DestinationConfigView' - type: 'null' signing_secret: type: - string - 'null' description: The secret this destination signs its webhook payloads with. Set for webhook destinations; null otherwise and on an Idempotency-Key replay. Retrieving the destination's secrets returns it again. required: - id - type - url - active - disabled_reason - disabled_at - configured - missing - config - signing_secret DashboardUser: type: - object - 'null' description: 'A dashboard user: user_id, email, verified, name, phone_number, created_at, last_login, company_id, role. No credential material — passwords live in a separate credential table this surface never reads. null when the caller''s token has no resolvable own user (see PatchMeRequest''s description).' additionalProperties: true DataToken: type: object description: A data token together with its bearer, which is shown at mint and afterwards only through the keys:read secret endpoint, and only while the token is revealable. properties: token_id: type: string token_hint: type: - string - 'null' description: The bearer's kind prefix and last 4 characters (terra_dt_…x7Kq), or …a1b2 for a backfilled legacy API key. null when the secret is under 32 characters or the token predates hints. dev_id: type: string scopes: type: array items: type: string name: type: string created_via: type: string description: 'How the token was made: `admin_api` when minted here, `backfill` for a legacy API key carried over as a token.' revealable: type: boolean description: Whether the secret endpoint can show the bearer again; false for a token with no stored bearer. created_at: type: string format: date-time expires_at: type: - string - 'null' format: date-time description: Expiry; null = never expires. last_used_at: type: - string - 'null' format: date-time description: When the token last authenticated a request; null if it never has. A data token unused for 365 days is revoked, after email warnings 30 and 7 days before. revoked_at: type: - string - 'null' format: date-time token: type: - string - 'null' description: The bearer (terra_dt_*). Shown once at mint; null in an Idempotency-Key replay. required: - token_id - dev_id - scopes - name - created_at - expires_at DataTokenSummary: type: object description: 'A data token''s metadata. The bearer is deliberately absent: listing tokens must not disclose credentials, so the list endpoint returns this shape and only the mint and secret endpoints return DataToken.' properties: token_id: type: string token_hint: type: - string - 'null' description: The bearer's kind prefix and last 4 characters (terra_dt_…x7Kq), or …a1b2 for a backfilled legacy API key. null when the secret is under 32 characters or the token predates hints. dev_id: type: string scopes: type: array items: type: string name: type: string created_via: type: string description: 'How the token was made: `admin_api` when minted here, `backfill` for a legacy API key carried over as a token.' revealable: type: boolean description: Whether the secret endpoint can show the bearer again; false for a token with no stored bearer. created_at: type: string format: date-time expires_at: type: - string - 'null' format: date-time description: Expiry; null = never expires. last_used_at: type: - string - 'null' format: date-time description: When the token last authenticated a request; null if it never has. A data token unused for 365 days is revoked, after email warnings 30 and 7 days before. revoked_at: type: - string - 'null' format: date-time required: - token_id - dev_id - scopes - name - created_at - expires_at DestinationSummary: type: object properties: id: type: string description: string-encoded 64-bit id type: type: string url: type: string description: Where the destination delivers, as stored, without any embedded user and password. An azureblob URL omits its SAS token, which retrieving the destination's secrets returns. active: type: boolean event_types: type: array description: The event types delivered here. An empty list delivers every event type. items: type: string disabled_reason: type: - string - 'null' enum: - owner - auto_disabled_failed_delivery - unrecorded - null description: 'Why the destination is off: owner (turned off through the API or dashboard), auto_disabled_failed_delivery (Terra turned it off after deliveries failed for 24 hours), or unrecorded (turned off before Terra recorded why). Null while active.' disabled_at: type: - string - 'null' format: date-time description: When the destination was turned off. Null while active, and when it was turned off before Terra recorded when (disabled_reason unrecorded). required: - id - type - url - active - disabled_reason - disabled_at Destination: type: object description: 'A destination with its configuration. Secrets are never returned: each is replaced by a masked form ending in its last four characters, or null when unset.' properties: id: type: string description: string-encoded 64-bit id type: type: string url: type: string description: Where the destination delivers, as stored, without any embedded user and password. An azureblob URL omits its SAS token, which retrieving the destination's secrets returns. active: type: boolean event_types: type: array description: The event types delivered here. An empty list delivers every event type. items: type: string disabled_reason: type: - string - 'null' enum: - owner - auto_disabled_failed_delivery - unrecorded - null description: 'Why the destination is off: owner (turned off through the API or dashboard), auto_disabled_failed_delivery (Terra turned it off after deliveries failed for 24 hours), or unrecorded (turned off before Terra recorded why). Null while active.' disabled_at: type: - string - 'null' format: date-time description: When the destination was turned off. Null while active, and when it was turned off before Terra recorded when (disabled_reason unrecorded). configured: type: boolean description: Whether the configuration has every field the type needs to deliver. A draft saved inactive reads false until it is completed. missing: type: array description: The required configuration fields still unset, as config.. Empty when configured. items: type: string config: description: Null when the stored configuration cannot be read; configured is then false, and config cannot be changed until the destination is recreated. anyOf: - $ref: '#/components/schemas/DestinationConfigView' - type: 'null' required: - id - type - url - active - disabled_reason - disabled_at - configured - missing - config DestinationHealth: type: object description: A destination's delivery health, worked out from the outcomes of the last 24 hours of deliveries and judged on the last hour. properties: destination_id: type: string description: string-encoded 64-bit id status: type: string enum: - healthy - degraded - failing - idle - disabled - unknown description: 'healthy: delivering. degraded: some deliveries in the last hour failed, a delivery has waited on automatic retries for 15 minutes, a resend failed in the last hour and is still retrying, or most deliveries in the last hour needed a retry. failing: every delivery that finished in the last hour failed, deliveries have waited on automatic retries for an hour with none delivered, every delivery that finished in 24 hours failed, or retries ran out and none has been delivered since. idle: no deliveries in 24 hours. disabled: the destination is off. unknown: delivery state could not be read; this is never reported as healthy.' info: description: The deliveries behind the status. Null when unknown. anyOf: - $ref: '#/components/schemas/DestinationHealthInfo' - type: 'null' error: description: Why the destination is not healthy. Null when healthy or idle, and for degraded or failing when the failure left no detail. anyOf: - $ref: '#/components/schemas/DestinationHealthError' - type: 'null' required: - destination_id - status - info - error DestinationHealthInfo: type: object description: The deliveries behind a destination's status. These are the deliveries listWebhookEvents shows for the destination. properties: failing_since: type: - string - 'null' format: date-time description: 'When the current failure began: the first delivery whose retries ran out with no success since. Null when not failing, or failing for less than one full retry chain.' last_delivered_at: type: - string - 'null' format: date-time description: The last delivery that arrived in the last 24 hours, or null. last_failure_at: type: - string - 'null' format: date-time description: The last failed or retrying delivery's latest attempt, or null. last_failure_status_code: type: - integer - 'null' description: 'The HTTP status a webhook answered on its last failure. Null for other destination types, and when there was no answer: a timeout or a connection failure.' pending: type: integer description: Deliveries still waiting on a retry, including a resend still retrying after its event was delivered. listWebhookEvents shows such a delivery as delivered until the resend ends; health counts it here because it is how the destination is answering now. oldest_pending_at: type: - string - 'null' format: date-time description: When the oldest delivery still waiting on an automatic retry was created, or null. A resend keeps its event's creation time, so its age is unknown and it is not counted here. counts: $ref: '#/components/schemas/DestinationHealthCounts' required: - failing_since - last_delivered_at - last_failure_at - last_failure_status_code - pending - oldest_pending_at - counts DestinationHealthError: type: object description: Why a destination is not healthy. properties: code: type: string description: 'A stable code. For degraded or failing: unauthorized, forbidden, not_found, gone, payload_too_large, rate_limited, timeout (no answer in time, or a 408 or 504), unreachable (could not connect), paused (Terra is holding deliveries back after repeated failures), server_error, rejected, unexpected_status, no_response, retrying (deliveries arrive but most needed a retry), or delivery_error for non-webhook destinations. For disabled: the disabled_reason. For unknown: check_unavailable.' message: type: string description: The code in a sentence. required: - code - message DestinationHealthCounts: type: object description: Delivery counts over the last hour and the last 24 hours, by when each delivery reached its outcome. properties: last_hour: $ref: '#/components/schemas/DestinationDeliveryCounts' last_24h: $ref: '#/components/schemas/DestinationDeliveryCounts' required: - last_hour - last_24h DestinationDeliveryCounts: type: object description: 'Deliveries that reached an outcome in a window, counted once per event and destination however many attempts they took. A delivery Terra could not send because it could not load the payload is not counted: that failure is Terra''s, not the destination''s.' properties: delivered: type: integer description: Deliveries that arrived. failed: type: integer description: Deliveries whose retries ran out, or whose retry is more than six hours overdue. retried: type: integer description: Delivered deliveries that took more than one attempt. required: - delivered - failed - retried DoctorReport: type: object description: The environment's lints, worked out when asked. properties: lints: type: array description: Problems found, errors first. Checks that could not run are check_unavailable lints, one per cause, never a pass. Empty when there are none. items: $ref: '#/components/schemas/DoctorLint' required: - lints DoctorLint: type: object description: One problem with the environment, or a check that could not run. properties: name: type: string description: The check that found it, or check_unavailable. title: type: string level: type: string enum: - error - warn - info description: error stops data reaching you or breaks your integration; warn needs attention; info is worth knowing. facing: type: string enum: - external description: 'Always external: every lint concerns your use of Terra.' categories: type: array description: security, performance or health. items: type: string enum: - security - performance - health description: type: string description: What the check looks for, the same for every lint it makes. detail: type: string description: This lint in particular. remediation: $ref: '#/components/schemas/DoctorRemediation' metadata: $ref: '#/components/schemas/DoctorLintMetadata' cache_key: type: string description: 'Stable for the same problem across runs: the check, plus the id of what it concerns when there is one.' observed_at: type: string format: date-time description: When the check ran. required: - name - title - level - facing - categories - description - detail - remediation - metadata - cache_key - observed_at DoctorLintMetadata: type: object description: What a lint concerns, and the facts behind it. properties: type: type: string description: destination, source, token, subscription, meter, invitation, data_type, api_version, model, route, environment, account (the problem is account-wide and shows in every environment), or check for a check_unavailable lint. id: type: - string - 'null' description: The id of what the lint concerns, string-encoded. Null for the environment as a whole, and for a check_unavailable lint. name: type: - string - 'null' description: A display name for it, or null. reason: type: - string - 'null' description: 'A stable reason code: a delivery error code, a disabled reason, a subscription or certificate state, or why checks could not run (missing_scope, dependency_unavailable). Null when there is none.' scope: type: - string - 'null' description: The admin scope the token needs, when a check could not run for want of it. x-scope-plane: admin since: type: - string - 'null' format: date-time description: When the problem began or comes due, when Terra knows. observed: description: The counts behind the lint, keyed by name. omitted, on the last lint a check returns, counts the lints left out once a check reaches 25. $ref: '#/components/schemas/RecordInteger' checks: type: - array - 'null' description: The checks a check_unavailable lint covers. Null for every other lint. items: type: string required: - type - id - name - reason - scope - since - observed - checks $defs: RecordInteger: type: object unevaluatedProperties: type: integer DoctorRemediation: type: object description: How to act on a lint. properties: text: type: string description: What to do, in a sentence. action: type: - string - 'null' description: The operationId of the admin call that inspects or fixes the problem, or null. docs_url: type: - string - 'null' description: The check's section in the environment doctor docs. required: - text - action - docs_url DestinationType: type: object properties: type: type: string description: The value create takes as type. display_name: type: string icon_url: type: string config_fields: type: array items: $ref: '#/components/schemas/DestinationConfigField' aws_role_setup: description: 'On s3 and sqs, when Terra can assume a role in your AWS account instead of using an access key: what you need to create that role. Absent on the public catalogue.' $ref: '#/components/schemas/AwsRoleSetup' required: - type - display_name - icon_url - config_fields DestinationSecrets: type: object description: A destination's stored secrets in plaintext. properties: id: type: string description: string-encoded 64-bit id type: type: string secrets: $ref: '#/components/schemas/DestinationSecretValues' required: - id - type - secrets RotatedSigningSecret: type: object description: A webhook destination's new signing secret. properties: id: type: string description: string-encoded 64-bit id signing_secret: type: - string - 'null' description: The new secret. Deliveries are signed with it from now on. Null on an Idempotency-Key replay; retrieving the destination's secrets returns it again. required: - id - signing_secret DevDetail: type: object properties: dev_id: type: string name: type: string label: type: string active: type: boolean billable: type: boolean is_production: type: boolean description: Whether this is a production environment. Production environments use production Vantage; every other environment uses sandbox. Set when the environment is created. profile: $ref: '#/components/schemas/EnvironmentProfile' api_key_masked: type: string user_limit: type: integer format: int64 required: - is_production DevKeys: type: object properties: dev_id: type: string api_key: type: string description: full client_secret — returned once, keys:read only DevSummary: type: object properties: dev_id: type: string name: type: string label: type: string active: type: boolean billable: type: boolean is_production: type: boolean description: Whether this is a production environment. Production environments use production Vantage; every other environment uses sandbox. Set when the environment is created. profile: $ref: '#/components/schemas/EnvironmentProfile' required: - is_production DeviceStartFormRequest: type: object description: RFC 8628 §3.1 device authorization request (form-encoded wire mode). properties: client_id: type: string description: Public client identifier; recorded as the pairing session's client name. scope: type: string description: Space-separated scopes; omitted = the default grantable set. The device flow issues an admin token, so the grantable names are the ones the adminToken scope registry marks `admin` or `both` in x-scope-planes. Data-plane names are rejected with 400 invalid_scope. x-scope-plane: admin requested_dev_ids: type: string description: Optional space-separated audience dev-ids (Terra extension parameter). Omitted = the whole account. Account-level scopes cannot be combined with an audience. requester_hostname: type: string description: The requesting machine's hostname, shown on the approval page. Display-only and unverified; the user code remains the check. required: - client_id DeviceStartResponse: type: object description: RFC 8628 §3.2 device authorization response. The four fields the RFC requires are required here; a client that cannot read device_code has no way to poll. properties: device_code: type: string user_code: type: string verification_uri: type: string expires_in: type: integer verification_uri_complete: type: string interval: type: integer description: 'Polling interval in seconds. RFC 8628 §3.2: absent means 5.' required: - device_code - user_code - verification_uri - expires_in DryRunPreview: type: object description: |- The representation the live call would return, or for a delete the representation of what would go. A value that cannot exist without committing is omitted rather than invented, and the will_return_* flags below say one is coming. properties: will_return_token: type: boolean description: The call would issue a bearer token, returned once by the live call. will_return_signing_secret: type: boolean description: The call would issue a webhook signing secret, returned once by the live call. will_return_api_key: type: boolean description: The call would issue an API key, returned once by the live call. will_return_authorization_url: type: boolean description: The call would return an authorization URL to send the user to. will_return_database_password: type: boolean description: The call would generate a database password, returned once by the live call. unevaluatedProperties: {} DryRunResult: type: object description: Returned by any mutating endpoint invoked with ?dry_run=true. properties: dry_run: type: boolean enum: - true would: type: string description: the action that would be taken preview: $ref: '#/components/schemas/DryRunPreview' required: - dry_run - would - preview Entitlement: type: object properties: capability: type: string source: type: string EnvironmentProfile: type: - object - 'null' description: The dev-id's environment profile, or null when no profile row exists yet. The widget configuration is the inlined widget_config document; widget_config_url is retired and no longer returned. properties: dev_id: type: string company_id: type: string name: type: string billable: type: - boolean - 'null' widget_config_url: type: - string - 'null' description: 'Retired: no longer returned. The configuration is served inline as widget_config.' widget_config: type: - object - 'null' description: The widget configuration document, served inline. additionalProperties: true widget_name: type: - string - 'null' app_logo: type: - string - 'null' additionalProperties: false EventStatsCounts: type: object description: Counts of recorded outbound delivery attempts. Retries are separate observations. properties: delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. required: - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate EventStatsTotals: type: object description: Whole-window delivery attempt counts and latency percentiles calculated from eligible observations. properties: delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. response_time_samples: type: integer description: Delivery attempts with finite, positive response_time, regardless of outcome or destination. Missing or non-positive durations are excluded. p50_response_time_ms: type: - number - 'null' description: Approximate TDigest median response time in milliseconds across eligible delivery attempts. Null without eligible observations. p95_response_time_ms: type: - number - 'null' description: Approximate TDigest 95th-percentile response time in milliseconds across eligible delivery attempts. Null without eligible observations. p99_response_time_ms: type: - number - 'null' description: Approximate TDigest 99th-percentile response time in milliseconds across eligible delivery attempts. Null without eligible observations. required: - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate - response_time_samples - p50_response_time_ms - p95_response_time_ms - p99_response_time_ms GenerateEventRequest: type: object properties: type: type: string description: The data type to generate, e.g. daily, activity, sleep, body, nutrition or menstruation. Required. provider: type: string description: The provider slug the event should appear to come from, e.g. garmin (case-insensitive). Omitted, the data is drawn from every field any provider reports for the type and the event carries no provider. A provider that does not support the type is a 400. user_id: type: string format: uuid description: The Terra user id to stamp on the event, as a UUID. Omitted, a fresh id is minted per event. reference_id: type: string description: Your own id for that user. Omitted, a fresh UUID is minted. destination_id: type: string description: 'Deliver to this one destination only, by the id the destinations list reports. Omitted, the event goes to every destination the dispatcher would deliver it to: active, of a deliverable type, and with event_types that admit the type. An unknown id is a 404; an inactive, non-accepting or undeliverable one is a 422.' start_time: type: string format: date-time description: The moment the generated data is anchored to, RFC 3339. Omitted, now. samples: type: boolean description: Whether the generated event carries its time-series samples. False removes them before the event is stored and delivered, as an environment with samples disabled receives it. default: true dispatch: type: boolean description: 'Whether to store the event and queue it for delivery. False only builds and returns the payload: no destination is consulted, so it answers whether or not one is registered, and destination_id is a 400.' default: true required: - type GenerateEventResult: type: object properties: event_id: type: string description: The id of the generated event; the same id the delivery history and resend use. user_id: type: string format: uuid reference_id: type: string type: type: string description: The generated event's type, e.g. unified_api.daily.updated. payload_type: type: string description: The type the generated payload carries, e.g. daily. provider: type: - string - 'null' description: The lower-case provider slug the event carries. null when none was requested. destination_id: type: - string - 'null' description: The single destination delivered to, echoing the request. null when the event went to every active destination. dispatched: type: boolean description: True when the payload was stored and queued for delivery; false for a ?dry_run=true preview. payload: type: object description: The normalised payload exactly as destinations receive it. required: - provider - destination_id EventStatsBucket: type: object description: Delivery attempt counts within a UTC bucket, clipped to the requested window. properties: bucket_start: type: string format: date-time description: Inclusive bucket boundary in UTC. The first bucket may start before since. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. required: - bucket_start - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate EventStatsEventType: type: object description: Delivery attempt counts grouped by event type and the payload type delivered. properties: type: type: string description: The event type, e.g. unified_api.sleep.updated. A payload type with no registered event type reads unknown.. payload_type: type: string description: The type the delivered payloads carried, e.g. sleep. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. required: - type - payload_type - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate EventStatsProvider: type: object description: Delivery attempt counts grouped by the recorded provider slug. properties: provider: type: string description: Provider slug recorded on these delivery attempts. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. required: - provider - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate EventStatsDestinationType: type: object description: Delivery attempt counts grouped by destination type. properties: destination_type: type: string description: Destination type recorded on these delivery attempts, such as webhook or s3. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. required: - destination_type - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate EventStatsHTTPStatus: type: object description: Delivery attempt counts grouped by recorded HTTP status. properties: http_status: type: integer description: Recorded HTTP status code; zero denotes a missing response. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. required: - http_status - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate EventStatsBreakdowns: type: object description: Whole-window breakdowns. Arrays are sorted by their dimension and empty without delivery attempts. properties: type: type: array description: Delivery attempt counts per event type and payload type, sorted by type, then payload_type. items: $ref: '#/components/schemas/EventStatsEventType' provider: type: array description: Delivery attempt counts per recorded provider, sorted lexicographically by provider. items: $ref: '#/components/schemas/EventStatsProvider' destination_type: type: array description: Delivery attempt counts per destination type, sorted lexicographically by destination_type. items: $ref: '#/components/schemas/EventStatsDestinationType' http_status: type: array description: Delivery attempt counts per HTTP status code, sorted numerically by http_status. items: $ref: '#/components/schemas/EventStatsHTTPStatus' required: - type - provider - destination_type - http_status EventStatsHistogramBucket: type: object description: Number of eligible delivery attempt response times within a half-open millisecond range. properties: lower_bound_ms: type: number description: Inclusive response-time lower bound in milliseconds. upper_bound_ms: type: - number - 'null' description: Exclusive response-time upper bound in milliseconds; null for the final open-ended bucket. count: type: integer description: Delivery attempts with a finite, positive response time within this range. required: - lower_bound_ms - upper_bound_ms - count EventStatsComparison: type: object description: Delivery attempt summary for the equal-duration window immediately preceding since. properties: since: type: string format: date-time description: Inclusive start of the preceding window in UTC, with at most millisecond precision. until: type: string format: date-time description: Exclusive end of the preceding window in UTC, equal to the requested since. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. response_time_samples: type: integer description: Delivery attempts with finite, positive response_time, regardless of outcome or destination. Missing or non-positive durations are excluded. p50_response_time_ms: type: - number - 'null' description: Approximate TDigest median response time in milliseconds across eligible delivery attempts. Null without eligible observations. p95_response_time_ms: type: - number - 'null' description: Approximate TDigest 95th-percentile response time in milliseconds across eligible delivery attempts. Null without eligible observations. p99_response_time_ms: type: - number - 'null' description: Approximate TDigest 99th-percentile response time in milliseconds across eligible delivery attempts. Null without eligible observations. required: - since - until - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate - response_time_samples - p50_response_time_ms - p95_response_time_ms - p99_response_time_ms EventStatsResponse: type: object description: Recorded outbound delivery attempt analytics for CLI output and dashboard charts. properties: since: type: string format: date-time description: Inclusive requested start in UTC, with at most millisecond precision. until: type: string format: date-time description: Exclusive requested end in UTC, with at most millisecond precision. view: type: string enum: - basic - full description: Resolved response detail level. Defaults to basic. granularity: type: string enum: - minute - hour - day description: Present only in the full view. UTC interval used to group series buckets, as requested or resolved from the window duration. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including initial and retry attempts. successful_attempts: type: integer description: Delivery attempts with HTTP status 200 through 299. failed_attempts: type: integer description: Delivery attempts with any other HTTP status, including zero for a missing response. retry_attempts: type: integer description: Delivery attempts whose recorded retries counter is greater than zero, not the sum of retry ordinals. bytes: type: integer description: Sum of recorded outbound payload sizes in bytes, including retry attempts and failures. success_rate: type: - number - 'null' description: successful_attempts / delivery_attempts, from 0 to 1. Null when delivery_attempts is zero. response_time_samples: type: integer description: Delivery attempts with finite, positive response_time, regardless of outcome or destination. Missing or non-positive durations are excluded. p50_response_time_ms: type: - number - 'null' description: Approximate TDigest median response time in milliseconds across eligible delivery attempts. Null without eligible observations. p95_response_time_ms: type: - number - 'null' description: Approximate TDigest 95th-percentile response time in milliseconds across eligible delivery attempts. Null without eligible observations. p99_response_time_ms: type: - number - 'null' description: Approximate TDigest 99th-percentile response time in milliseconds across eligible delivery attempts. Null without eligible observations. series: type: array description: Present only in the full view. Delivery attempt counts in ascending UTC buckets, including zero-count buckets. At most 1500 buckets. items: $ref: '#/components/schemas/EventStatsBucket' breakdowns: description: Present only in the full view. Whole-window delivery attempt counts grouped independently by each recorded dimension. $ref: '#/components/schemas/EventStatsBreakdowns' response_time_histogram: type: array description: 'Present only in the full view. Eligible response times in milliseconds: 100 ms buckets below 1 second, then 1-2 s, 2-5 s, and 5 s or more. Includes zero-count buckets.' items: $ref: '#/components/schemas/EventStatsHistogramBucket' comparison: description: Delivery attempt summary for the preceding window. Present only in the full view when compare=previous_period was requested. $ref: '#/components/schemas/EventStatsComparison' required: - since - until - view - delivery_attempts - successful_attempts - failed_attempts - retry_attempts - bytes - success_rate - response_time_samples - p50_response_time_ms - p95_response_time_ms - p99_response_time_ms EventType: type: object properties: type: type: string description: The event type, as .., e.g. unified_api.sleep.updated. The events list's type filter takes it. product: type: string description: The product the event belongs to, e.g. unified_api or lab_reports. description: type: string description: When the event occurs. payload_types: type: array description: The type values the event's webhook payload carries today, e.g. sleep. items: type: string required: - type - product - description - payload_types Event: type: object properties: event_id: type: string description: The event's id, as its webhook's terra-reference header and payload carry it. Every delivery and resend of the event shares it. type: type: string description: What happened, as .., e.g. unified_api.sleep.updated or unified_api.auth.succeeded. A payload type with no registered event type reads unknown.. payload_type: type: string description: The type the delivered payload carried, e.g. sleep or auth_success. provider: type: - string - 'null' description: The provider slug the event came from, e.g. garmin. null for an event no provider produced. connection_id: type: - string - 'null' description: String-encoded 64-bit id of the connection the event is about. null for an event with no connection. user_id: type: - string - 'null' format: uuid description: The Terra user the event is about, as a UUID. null when the event has no user, or its connection has since been deleted. reference_id: type: - string - 'null' description: Your own id for that user, as set on the connection. null when none is set, or the connection has since been deleted. status: type: string enum: - pending - delivered - failed - canceled description: |- Where delivery stands across the event's destinations. pending: at least one destination has not been delivered to yet and Terra will try it again. failed: no destination is pending, and Terra stopped trying at least one of them. canceled: no destination was sent the event, because Terra refused every delivery before sending it. delivered: every other case: each destination was delivered to, or canceled after another was delivered to. destination_count: type: integer description: How many destinations the event was sent to, or was due to be. minimum: -2147483648 maximum: 2147483647 attempt_count: type: integer description: How many requests were sent across every destination, resends included. A try the safety valve held back sent nothing and is not counted. minimum: -2147483648 maximum: 2147483647 created_at: type: string format: date-time description: When the event was created. since and until filter on this. completed_at: type: - string - 'null' format: date-time description: When the last destination reached its status. null while status is pending, or when a delivery failed by an overdue retry. required: - event_id - type - payload_type - provider - connection_id - user_id - reference_id - status - destination_count - attempt_count - created_at - completed_at EventDetail: type: object description: A webhook event with each destination's delivery and its attempts. properties: event_id: type: string description: The event's id, as its webhook's terra-reference header and payload carry it. Every delivery and resend of the event shares it. type: type: string description: What happened, as .., e.g. unified_api.sleep.updated or unified_api.auth.succeeded. A payload type with no registered event type reads unknown.. payload_type: type: string description: The type the delivered payload carried, e.g. sleep or auth_success. provider: type: - string - 'null' description: The provider slug the event came from, e.g. garmin. null for an event no provider produced. connection_id: type: - string - 'null' description: String-encoded 64-bit id of the connection the event is about. null for an event with no connection. user_id: type: - string - 'null' format: uuid description: The Terra user the event is about, as a UUID. null when the event has no user, or its connection has since been deleted. reference_id: type: - string - 'null' description: Your own id for that user, as set on the connection. null when none is set, or the connection has since been deleted. status: type: string enum: - pending - delivered - failed - canceled description: |- Where delivery stands across the event's destinations. pending: at least one destination has not been delivered to yet and Terra will try it again. failed: no destination is pending, and Terra stopped trying at least one of them. canceled: no destination was sent the event, because Terra refused every delivery before sending it. delivered: every other case: each destination was delivered to, or canceled after another was delivered to. destination_count: type: integer description: How many destinations the event was sent to, or was due to be. minimum: -2147483648 maximum: 2147483647 attempt_count: type: integer description: How many requests were sent across every destination, resends included. A try the safety valve held back sent nothing and is not counted. minimum: -2147483648 maximum: 2147483647 created_at: type: string format: date-time description: When the event was created. since and until filter on this. completed_at: type: - string - 'null' format: date-time description: When the last destination reached its status. null while status is pending, or when a delivery failed by an overdue retry. deliveries: type: array description: One delivery per destination the event was sent to. items: $ref: '#/components/schemas/EventDelivery' required: - event_id - type - payload_type - provider - connection_id - user_id - reference_id - status - destination_count - attempt_count - created_at - completed_at - deliveries EventDelivery: type: object description: The delivery of one event to one destination. properties: destination_id: type: - string - 'null' description: String-encoded id of the destination, as recorded at delivery time. null when the destination had no id. destination_type: type: string description: The destination kind, e.g. webhook, s3 or kafka. destination_url: type: - string - 'null' description: The destination URL recorded at delivery time, including for a destination since edited or deleted. null for a destination without one. status: type: string enum: - pending - delivered - failed - canceled description: |- Where this delivery stands. A resend runs alongside any automatic retries; a delivery that reached delivered stays delivered until a later resend ends otherwise. pending: not delivered yet; Terra tries again at next_attempt_at. delivered: the destination accepted the event. failed: Terra stopped trying after the last retry, a scheduled retry is more than six hours overdue with no recorded result, or Terra refused a retry after requests had been sent (no_status_reason says why). canceled: Terra refused the delivery before sending any request; no_status_reason says why. last_status_code: type: - integer - 'null' description: The HTTP status the destination returned to the latest attempt, including a non-2xx one. A destination that is not HTTP, such as s3, kafka or a database, records 200 when the write succeeded and 500 when it failed. null when no_status_reason is set. minimum: -2147483648 maximum: 2147483647 no_status_reason: type: - string - 'null' enum: - timed_out - connection_failed - destination_paused - destination_disabled - destination_deleted - destination_changed - environment_disabled - connection_withdrawn - destination_unavailable - access_withdrawn - payload_unavailable - unsupported_event - null description: |- Why last_status_code is null. timed_out: the destination did not answer in time, so Terra has no status for a request it sent. connection_failed: no HTTP response, for example a refused connection or TLS failure. destination_paused: Terra held the try back while the destination was failing, without sending it. destination_disabled: the destination was turned off, by its owner or by Terra after sustained failures, so Terra refused the try. destination_deleted: the destination was deleted, so Terra refused the try. destination_changed: the destination's event types or format changed and no longer take this event, so Terra refused the try. environment_disabled: the environment was disabled, so Terra refused the try. connection_withdrawn: the user's connection was removed, became inactive, or lost the scope or consent this data needs, so Terra refused the try. destination_unavailable: Terra refused the try because the destination or source changed in a way it does not classify. access_withdrawn: the environment no longer has access to the event's product, so Terra refused the try. payload_unavailable: Terra could not load the stored payload or build the request from it, so nothing was sent; it retries, and fails once the payload is gone or the retries run out. unsupported_event: the destination's type cannot take this event, for example a database destination given data it cannot store, so nothing was sent (status canceled). attempt_count: type: integer description: How many requests were sent to this destination, resends included. minimum: -2147483648 maximum: 2147483647 next_attempt_at: type: - string - 'null' format: date-time description: When Terra next tries this destination. Set only while status is pending. completed_at: type: - string - 'null' format: date-time description: When the delivery reached its status. null while status is pending, and for a delivery failed by an overdue retry. attempts: type: array description: The newest 1,000 requests sent to the destination, plus each try Terra refused to send (not_sent_reason set), newest first. attempt_count counts only the requests sent, so a refused try is listed but not counted. A try held back by the safety valve sent nothing and is not listed. items: $ref: '#/components/schemas/EventAttempt' required: - destination_id - destination_type - destination_url - status - last_status_code - no_status_reason - attempt_count - next_attempt_at - completed_at - attempts EventAttempt: type: object description: 'One try at a destination: a request sent, or a try Terra refused to send.' properties: attempted_at: type: string format: date-time description: When the request was sent, or when Terra refused the try. url: type: - string - 'null' description: The URL the request was sent to. null for a destination without one. status_code: type: - integer - 'null' description: The HTTP status recorded for the request. A timeout records 504 and a connection failure 503. A destination that is not HTTP records 200 for a successful write and 500 for a failed one. null when Terra refused the try, so no request was sent. minimum: -2147483648 maximum: 2147483647 duration_ms: type: - integer - 'null' format: int64 description: How long the request took, in milliseconds. null when it was not measured. resend_id: type: - string - 'null' description: The resend this request belongs to, as the resend returned it. null for the event's own delivery and its automatic retries. not_sent_reason: type: - string - 'null' enum: - destination_disabled - destination_deleted - destination_changed - environment_disabled - connection_withdrawn - destination_unavailable - access_withdrawn - unsupported_event - null description: Why Terra refused this try and sent nothing; null for a request that was sent. Each reason has the meaning it has on the delivery's no_status_reason. required: - attempted_at - url - status_code - duration_ms - resend_id - not_sent_reason InvoiceSummary: type: object properties: subscription_id: type: string number: type: string total: type: integer format: int64 amount_paid: type: integer format: int64 period_start: type: - string - 'null' format: date-time period_end: type: - string - 'null' format: date-time lines: type: array items: $ref: '#/components/schemas/InvoiceLineSummary' id: type: string status: type: string amount_due: type: integer format: int64 currency: type: string created_at: type: - string - 'null' format: date-time hosted_invoice_url: type: string invoice_pdf: type: string DocsAskRequest: type: object properties: question: type: string description: The question, in natural language. maxLength: 4000 required: - question DocsAskResponse: type: object properties: answer: type: string description: The answer as markdown, with footnote markers referring to sources. Empty when nothing was found. confidence: type: string enum: - high - medium - low - unknown description: How sure the search is of the answer. `unknown` means it returned no rating. sources: type: array description: The pages the answer came from. Empty when there are none. items: $ref: '#/components/schemas/DocsSource' required: - answer - confidence - sources DocsSource: type: object description: One documentation page the answer drew on. properties: label: type: string description: The footnote marker the answer refers to, e.g. "1". title: type: string description: type: string url: type: string type: type: string description: What kind of record the source is, such as documentation. breadcrumbs: type: array description: Where the page sits in the documentation navigation. items: type: string required: - url MeResponse: type: object properties: token_id: type: string kind: type: string enum: - admin - session - data description: The credential class. `admin` and `session` authenticate the admin API, and `data` the APIs your product calls at runtime under `/api/v2` and `/api/v3`; neither kind is accepted by the other's APIs. `session` is a short-lived per-login dashboard credential and never appears in token lists. customer_id: type: string scopes: type: array items: type: string dev_ids: type: - array - 'null' description: 'Audience: the dev-ids this token may act on. null = every dev of the account.' items: type: string name: type: string created_via: type: string expires_at: type: - string - 'null' format: date-time description: Expiry; null = never expires. grant_anchor_at: type: string format: date-time last_used_at: type: - string - 'null' format: date-time user: $ref: '#/components/schemas/DashboardUser' staff: type: boolean description: Terra-staff signal read from the staff grant table for the resolved user; false whenever user is null. Gate staff-only UI on this, never on an email suffix. MintDataTokenRequest: type: object properties: name: type: string description: What this token is for, shown wherever tokens are listed. Required, so a credential is identifiable when it needs revoking. scopes: type: array description: Data-plane scopes only (e.g. ["auth:write"] for an SDK-authentication-only token) — the names the adminToken scope registry marks `data` or `both` in x-scope-planes. Admin-plane names are rejected with 400 validation_failed. items: type: string x-scope-plane: data expires_in_days: type: integer description: Default 365 (restricted-key shape), max 1825. Mutually exclusive with never_expires. minimum: 1 maximum: 1825 default: 365 never_expires: type: boolean description: Mint a non-expiring credential (the primary 'API key' shape). Mutually exclusive with expires_in_days. Safe because tokens — unlike the legacy secret — are revocable, coexisting, and per-credential observable. default: false required: - name - scopes ModelCatalogEntry: type: object properties: id: type: string name: type: string description: type: string data_type: type: string ModelRunRecord: type: object properties: run_id: type: string user_id: type: string model: type: string status: type: string error: type: string latency_ms: type: integer start_time: type: string format: date-time end_time: type: string format: date-time submitted_at: type: string format: date-time output_truncated: type: boolean output: description: The run's JSON output; a JSON string when output_truncated is true. required: - run_id - user_id - model - status - latency_ms - start_time - end_time - submitted_at - output_truncated - output OAuthError: type: object description: RFC 6749 §5.2 error envelope, returned to form-encoded (RFC 8628 wire mode) requests. properties: error: type: string enum: - invalid_request - invalid_scope - invalid_grant - unsupported_grant_type - authorization_pending - slow_down - access_denied - expired_token - server_error - invalid_client - temporarily_unavailable - invalid_client_metadata - invalid_redirect_uri error_description: type: string required: - error OAuthTokenResponse: type: object description: RFC 6749 §5.1 token response, returned to form-encoded (RFC 8628 wire mode) polls. No refresh tokens are issued — rotate via POST /tokens/self/rotate instead. properties: access_token: type: string description: The minted bearer, returned once by the token endpoint. token_type: type: string enum: - Bearer expires_in: type: integer description: Seconds until the access token expires. Omitted when the token never expires. scope: type: string description: Space-separated granted scopes. token_id: type: string format: uuid required: - access_token - token_type - scope - token_id PatchCompanyRequest: type: object description: Partial update of the company profile. Every property is optional; unknown fields, created_at, the billing columns (stripe_customer_id, stripe_subscription_id, stripe_metering_type — this route does not write billing) and the retired app_logo, widget_name and agreed_to_terms_at are rejected with 400. properties: name: type: string description: 'The company''s name. Cannot be cleared: null is rejected.' billing_email: type: string description: 'Where invoices and billing notices are sent. Cannot be cleared: null is rejected.' website_url: type: string description: 'The company''s website. Cannot be cleared: null is rejected.' learn_about_us: type: string description: 'How you first heard about Terra, as free text. Cannot be cleared: null is rejected.' onboarded: type: boolean description: Whether the company has finished onboarding. app_logo: type: - string - 'null' description: 'Retired: rejected with 400. The widget logo is set per dev-id on the environment''s widget config.' description: type: - string - 'null' description: Free-text description of the company. null clears it. org_name: type: - string - 'null' description: Legal or trading name, where it differs from name. null clears it. tos_url: type: - string - 'null' description: Link to your own terms of service, shown to end users in the connection widget. null clears it. privacy_policy_url: type: - string - 'null' description: Link to your own privacy policy, shown to end users in the connection widget. null clears it. data_usage_description: type: - string - 'null' description: What you tell end users their data is used for, shown in the connection widget. null clears it. widget_name: type: - string - 'null' description: 'Retired: rejected with 400. The widget name is set per dev-id on the environment''s widget config.' user_flow_done: type: boolean description: Whether the company has finished the guided setup flow. agreed_to_terms_at: type: - string - 'null' format: date-time description: 'Retired: rejected with 400. Terms are accepted in the dashboard.' additionalProperties: false minProperties: 1 PatchDestinationRequest: type: object properties: active: type: boolean description: Whether the destination is delivering. Omitted leaves it as it is. Activating needs a complete configuration. event_types: type: array description: Which events to deliver here, replaced wholesale, so send the full list rather than the additions. Omitted leaves the current set alone, an empty list delivers every event type, and an unrecognised name is a 400 naming it. items: type: string config: description: 'Fields to change, merged over the stored configuration: an omitted field keeps its value, secrets included, and null clears an optional one. Changing where a secret is sent (a database''s scheme, host, port, database or username, a Kafka host or port, a Supabase project_url, an Azure account_url) requires resending that secret, because a stored secret is never sent to a new endpoint; a missing one is a 400 naming it. An empty secret is a 400. The type cannot change.' anyOf: - $ref: '#/components/schemas/WebhookDestinationConfig' - $ref: '#/components/schemas/S3DestinationConfig' - $ref: '#/components/schemas/SqsDestinationConfig' - $ref: '#/components/schemas/GcsDestinationConfig' - $ref: '#/components/schemas/FirestoreDestinationConfig' - $ref: '#/components/schemas/SupabaseDestinationConfig' - $ref: '#/components/schemas/MongodbDestinationConfig' - $ref: '#/components/schemas/KafkaDestinationConfig' - $ref: '#/components/schemas/SqlDestinationConfig' - $ref: '#/components/schemas/AzureblobDestinationConfig' PatchMeRequest: type: object description: Partial update of the calling principal's own dashboard user. Every property is optional; at least one is required. Gated on account:write (in the default mint set); the write is strictly self-scoped. Requires the token to resolve to an own user (see DashboardUser) — otherwise 404 not_found. properties: name: type: string description: 'Your display name. Cannot be cleared: null is rejected.' phone_number: type: - string - 'null' description: Your phone number, as free text. null clears it. minProperties: 1 PatchScoreRequest: type: object description: At least one of active/weights required. properties: active: type: boolean description: Whether Terra computes this score for the environment. Omitted leaves it as it is. weights: type: object description: How much each contributor counts toward the score, as contributor name to weight. Each weight is 0 to 200; replaced wholesale, so send every contributor rather than the ones being changed, and an empty object is a 400. additionalProperties: type: integer minimum: 0 maximum: 200 minProperties: 1 PatchSourceRequest: type: object properties: active: type: boolean description: false pauses the provider and true resumes it. Omitted leaves it as it is. auth_variant: type: string enum: - standard - byo description: standard connects users through Terra's OAuth app and byo through your own, which the provider must support. Omitted leaves it as it is. PatchTeamMemberRequest: type: object description: Partial update of a teammate's dashboard user. Every property is optional; at least one is required. Email, company_id and the rest of the row are not reassignable here. properties: name: type: string description: 'The member''s display name. Cannot be cleared: null is rejected.' phone_number: type: - string - 'null' description: The member's phone number, as free text. null clears it. role: type: - string - 'null' enum: - admin - developer - null description: The member's dashboard role. superadmin is recognised by the dashboard but is not assignable here — the dashboard's own team editor never offers it. minProperties: 1 PaymentMethodSummary: type: object properties: method: type: string description: Native Stripe payment method type; absent when no method is available. brand: type: string last4: type: string exp_month: type: integer format: int64 exp_year: type: integer format: int64 has_card: type: boolean AdminProblem: allOf: - $ref: '#/components/schemas/Problem' - $ref: '#/components/schemas/ProblemExtensions' Problem: type: object description: | An error response, following RFC 9457 (Problem Details for HTTP APIs, which obsoletes RFC 7807). Returned with `Content-Type: application/problem+json` on every 4xx/5xx response. The HTTP status line carries the status code; it is intentionally not repeated in the body. `type`, `title` and `instance` are always present; `detail` is included when a specific explanation is available. properties: type: type: string description: A URI reference identifying the problem type. Defaults to `about:blank`. example: about:blank title: type: string description: A short, human-readable summary of the problem type (the lowercased HTTP status text). example: unauthorized instance: type: string description: The request path, including any query string, that produced this problem. example: /api/v2/activity?user_id=d4aba475-f714-4663-88fe-28f18b8599b0&to_webhook=false code: type: string description: 'Stable error classification: branch on this, not on `detail`. A refused credential returns unauthorized (401: missing, invalid, expired or revoked), scope_missing (403: the credential lacks the scope the operation requires) or audience_restricted (403: the credential is not granted for this dev-id). authorization_unavailable (503) means the credential or the product access could not be checked; retry later. Product gates return entitlement_required (403) or environment_disabled (403). service_unavailable (503) means the request never reached the service; dependency_failed (502 or 504) means the service did not complete it, though it may already have acted on it. Report uploads return validation_failed, unsupported_file_type or too_many_files (400), payload_too_large (413) and rate_limited (429).' product: type: string description: The product checked by the authorization gate, when classified. detail: type: string description: A human-readable explanation specific to this occurrence of the problem. example: dev-id or x-api-key headers are missing required: - type - title - instance ProblemExtensions: type: object description: 'The admin surface''s additions to the shared RFC 9457 Problem in specs/components/common.yaml, which contributes type/title/instance/detail. Composed with it via allOf in apis/admin.yaml rather than restated, so the two cannot drift. No `status`: httptools.Problem.MarshalJSON never writes it — the response line is authoritative.' properties: code: type: string enum: - access_denied - api_key_not_found - audience_restricted - authorization_pending - authorization_unavailable - billing_unavailable - conflict - dependency_failed - dev_id_not_found - device_code_expired - endpoint_moved - entitlement_required - environment_disabled - idempotency_key_reuse - internal_error - not_claimable - not_found - not_ready - precondition_failed - provider_credentials_rejected - rate_limited - rotation_conflict - rotation_expired - scope_missing - service_unavailable - slow_down - token_expired - token_limit_reached - token_not_found - unauthorized - unsupported_operation - validation_failed description: Stable error code — branch on this, not on prose. remediation: type: string description: How an agent can recover. errors: type: array description: 'Field-level validation errors ("field: message").' items: type: string required: - code ProcessingType: type: object properties: type: type: string enum: - json - fit - fhir display_name: type: string selected: type: boolean required: - type - display_name - selected ProviderCredentialMaterial: type: object properties: provider_client_id: type: string provider_client_secret_masked: type: - string - 'null' description: The client secret with all but its last four characters masked. Null when secret_ref reads it from a secret store. redirect_url: type: - string - 'null' description: The OAuth redirect URL users return to. Null when the provider has none. sandbox: type: boolean description: Whether auth runs against the provider's sandbox. oauth_version: type: - string - 'null' enum: - '1' - '2' - null description: The OAuth version the stored app uses. Null for providers that do not sign in with OAuth. has_verification_secret: type: boolean description: Whether a webhook verification secret is stored. The secret itself is never returned. secret_ref: description: Where the client secret is read from in a secret store, or null when Terra stores it. oneOf: - $ref: '#/components/schemas/ProviderSecretRefDetails' - type: 'null' required: - provider_client_id - provider_client_secret_masked - redirect_url - sandbox - oauth_version - has_verification_secret - secret_ref ProviderCredentialPatch: type: object properties: client_id: type: string description: The customer's OAuth client id. Omit to keep the stored one. client_secret: type: string description: A new OAuth client secret (write-only). Omit to keep the stored one; an empty string is rejected. redirect_url: type: - string - 'null' description: A new OAuth redirect URL, whose host must be Terra's or a custom domain set up for this provider. Null resets it to the provider default; omit to keep it. verification_secret: type: - string - 'null' description: A new webhook verification secret (write-only). Null clears it; omit to keep it. Not accepted for an OAuth 1.0 app. sandbox: type: boolean description: Use the provider's sandbox environment. Omit to keep the stored setting. Not accepted for an OAuth 1.0 app. secret_ref: description: Read the client secret from a secret store you own from now on. Not allowed with client_secret. Null, sent with client_secret, moves the secret back to Terra, as client_secret alone does. oneOf: - $ref: '#/components/schemas/ProviderSecretRef' - type: 'null' not: anyOf: - properties: secret_ref: type: object required: - client_secret - secret_ref - properties: secret_ref: type: object required: - client_id_field required: - client_id - secret_ref - properties: secret_ref: type: 'null' required: - secret_ref not: required: - client_secret minProperties: 1 ProviderCredentialWrite: type: object properties: client_id: type: string description: The customer's OAuth client id for this provider. Required unless secret_ref.client_id_field reads it. client_secret: type: string description: The customer's OAuth client secret (write-only; reads are masked). Required unless secret_ref is sent. secret_ref: description: Read the client secret from a secret store you own instead of sending it. Not allowed with client_secret; null keeps the secret with Terra. oneOf: - $ref: '#/components/schemas/ProviderSecretRef' - type: 'null' redirect_url: type: string description: Override the OAuth redirect URL (defaults to the provider default). Its host must be Terra's or a custom domain set up for this provider. verification_secret: type: string description: Optional webhook verification secret. Not accepted for an OAuth 1.0 app. sandbox: type: boolean description: Use the provider's sandbox environment. Not accepted for an OAuth 1.0 app. oneOf: - required: - client_id - client_secret not: properties: secret_ref: type: object required: - secret_ref - properties: secret_ref: type: object not: required: - client_id_field required: - client_id - secret_ref not: required: - client_secret - properties: secret_ref: type: object required: - client_id_field required: - secret_ref not: anyOf: - required: - client_secret - required: - client_id ProviderCredentials: type: object properties: provider: type: string has_credentials: type: boolean description: Whether this environment has its own OAuth app for the provider. terra_owned: type: boolean description: Whether the provider runs on Terra's own OAuth app. credential: description: Your own OAuth app, with its secret masked. Null when none is set or Terra's app is in use. oneOf: - $ref: '#/components/schemas/ProviderCredentialMaterial' - type: 'null' required: - provider - has_credentials - terra_owned - credential ProviderSecretRef: type: object description: A provider secret kept in a secret store you own, which Terra reads instead of storing it. Only the sources the store lists accept it. properties: store: type: string description: 'The secret store to read from: aws or gcp. An unrecognised store is a 400.' minLength: 1 config: description: Where in the store the secret is. $ref: '#/components/schemas/SecretRefConfig' client_secret_field: type: string description: The key to read the client secret from when the secret is a JSON object or an env file. Omit to use the whole value. minLength: 1 client_id_field: type: string description: The key to read the client_id from in the same JSON object or env file. Omit to send client_id yourself. minLength: 1 required: - store - config additionalProperties: false ProviderSecretRefDetails: type: object description: Where a provider secret is read from in a secret store. properties: store: type: string description: 'The secret store the secret is read from, as its type: aws or gcp.' config: $ref: '#/components/schemas/SecretRefConfigView' client_secret_field: type: - string - 'null' description: The key the client secret is read from. Null when the whole value is the secret. client_id_field: type: - string - 'null' description: The key the client_id is read from. Null when the client_id is stored with Terra. required: - store - config - client_secret_field - client_id_field SourceType: type: object properties: provider: type: string description: The provider's slug, e.g. apple_health. Sources and every other route name the provider by this value. display_name: type: string description: The provider's name as shown to end users. icon: type: string description: URL of the provider's icon. auth_type: type: string enum: - oauth2 - oauth1 - login - sdk description: 'How end users connect: oauth2 or oauth1 through the provider''s consent screen, login with their provider username and password, or sdk through the mobile SDK on their device.' setup: type: - string - 'null' description: What setting the provider up involves, from its configuration, e.g. setup_not_required or api_keys_required. Null when the configuration does not say. data_types: type: array description: The data types the provider can supply, as slugs. items: type: string deprecated: type: boolean description: Whether the provider is being retired. A deprecated provider is listed only for environments with access to it. byo_supported: type: boolean description: Whether users can connect through your own provider app instead of Terra's. custom_scopes_supported: type: boolean description: Whether the provider has OAuth scopes you can switch on or off, through the source's scopes. customer_credentials_required: type: boolean description: Whether you must add your own provider credentials before users can connect, because Terra has no app for this provider. custom_credentials_allowed: type: boolean description: Whether you may set your own provider credentials. required: - provider - display_name - icon - auth_type - setup - data_types - deprecated - byo_supported - custom_scopes_supported - customer_credentials_required - custom_credentials_allowed ProviderScope: type: object description: One OAuth scope a provider can request. properties: scope: type: string description: The scope as the provider names it. name: type: string description: A display name, or an empty string when there is none. description: type: string description: What the scope grants, or an empty string when there is no description. required: type: boolean description: Whether the scope is always requested. A required scope cannot be switched off. enabled: type: boolean description: Whether a new connection's OAuth request asks for this scope. required: - scope - name - description - required - enabled ProviderScopes: type: object description: Every OAuth scope a provider can request, and which of them this environment requests. properties: provider: type: string description: The provider's slug, e.g. fitbit. customised: type: boolean description: Whether this environment has chosen its own scopes. false means it requests the scopes its selected data types need. scopes: type: array description: Every scope the provider can request, sorted by scope. Empty, never null, for a provider with none. items: $ref: '#/components/schemas/ProviderScope' required: - provider - customised - scopes PutWorkoutMetadataRequest: type: object description: 'Upsert semantics on an existing workout: an absent or null pace_units preserves whatever is already stored (COALESCE); created_at is accepted but ignored.' properties: pace_units: type: - object - 'null' description: Pace units for the workout, as an object. Absent or null preserves what is stored, which is how this differs from PATCH. additionalProperties: true created_at: type: - string - 'null' format: date-time description: 'Accepted but ignored, as RFC3339: the response carries the workout''s own creation time.' ReplaceDataTypesRequest: type: object description: The complete desired data-type selection. Upper-case data-type tokens; ATHLETE is implicit and need not be sent; SAMPLES sets the per-row samples flag rather than selecting a data type; blank entries are skipped; an unrecognised token is a 400. An empty array clears the selection down to ATHLETE. properties: scopes: type: array description: The complete data-type selection to persist, replacing what is stored. Required; send the full list, since anything left out is deselected. items: type: string required: - scopes additionalProperties: false ResendEventRequest: type: object properties: event_id: type: string description: The event to resend. Required. Its stored payload is sent again, so an event whose payload has expired is a 404. destination_id: type: string description: The destination to resend to, by the id its delivery reports. Required. An unknown id is a 404; an inactive destination, or one that does not accept the event's type, is a 422. required: - event_id - destination_id ResendResult: type: object properties: event_id: type: string type: type: string description: The event's type, e.g. unified_api.sleep.updated. payload_type: type: string description: The type the resent payload carries, e.g. sleep. destination_id: type: string description: The destination the event was resent to. resend_id: type: string description: Identifies this resend. Its attempts are recorded apart from the event's automatic retries, which carry on. dispatched: type: boolean required: - event_id - type - payload_type - destination_id - resend_id - dispatched RotatedApiKey: type: object properties: dev_id: type: string api_key: type: string description: The new client_secret, shown once. The signing secret is per-destination and is not rotated with it. required: - dev_id - api_key ScopePreset: type: object description: A named grant set the approval page offers, from x-scope-presets. properties: name: type: string summary: type: string description: What the preset is for, as the approval page shows it. mcp_name: type: string description: The label an MCP client's approval page shows instead of name; present on exactly one preset. mcp_summary: type: string description: The summary shown beside mcp_name. scopes: type: array items: type: string x-scope-plane: admin required: - name - summary - scopes ScopeRegistry: type: object description: 'The adminToken scope registry this deployment grants from: the same vocabulary and lists securitySchemes.adminToken publishes, served live so a client can read them without pinning a copy of the spec.' properties: scopes: type: object description: Every scope on both planes, keyed by name, each with the sentence an approval page shows the person granting it. additionalProperties: type: string planes: type: object description: Which token kinds may hold each scope, as in x-scope-planes. POST /auth/device grants only `admin` and `both`. additionalProperties: type: string enum: - admin - data - both dangerous: type: object description: Each dangerous scope and what it puts at stake, as in x-scope-dangerous. A default grant leaves these off. additionalProperties: type: string enum: - money - access - team sensitive: type: array description: Scopes that disclose what the approver already sees in the dashboard, as in x-scope-sensitive. Granted by default, labeled. items: type: string account_level: type: array description: Scopes that act on the whole account, as in x-scope-account-level. A token limited to environments cannot hold them. items: type: string presets: type: array description: The named grant sets, in the order the approval page offers them. The first is the default. items: $ref: '#/components/schemas/ScopePreset' required: - scopes - planes - dangerous - sensitive - account_level - presets ScopesRequest: type: object properties: scopes: type: array description: The optional scopes to request. The provider's required scopes are always requested, whether listed or not, so an empty array requests only those. A scope the provider does not accept is a 400. items: type: string required: - scopes ScoreAnalytics: type: object properties: covered_users: type: integer description: Distinct provider_user_ids with a score in the window. updates: type: integer description: Score rows written in the window. required: - covered_users - updates ScoreConfig: type: object properties: type: type: string active: type: boolean ScoreHistoryRecord: type: object properties: provider_user_id: type: string description: The provider-side user id the score was computed for. user_id: type: - string - 'null' description: The Terra user_id this provider_user_id maps to for this environment, or null if the connection could not be resolved. provider: type: string description: Source data provider (clean name, e.g. "garmin"). score: type: string description: Score type (clean name, e.g. "sleep"). value: type: number description: The computed score value. dimensions: type: array description: The score's contributor dimensions (fixed length 8; -1 where unused). items: type: number start_time: type: string format: date-time end_time: type: string format: date-time inserted_at: type: string format: date-time description: When the score row was written. required: - provider_user_id - user_id - provider - score - value - dimensions - start_time - end_time - inserted_at ScoreResult: type: object properties: score: type: string active: type: boolean weights: type: object additionalProperties: type: integer SelectableDataType: type: object properties: data_type: type: string description: A data type the PUT on unified-api/scopes accepts for this environment, e.g. activity. Upper-case it to send it there. required: - data_type SelectedDataField: type: object properties: data_type: type: string fields: type: array items: type: string samples_enabled: type: boolean SelectedDataFieldsRequest: type: object properties: data_type: type: string description: The data type whose field selection to replace, e.g. activity or sleep. Required; an unrecognised type is a 400. fields: type: array description: The fields to keep for that data type, replaced wholesale, so send the full list rather than the additions. Omitted or empty selects no fields. items: type: string required: - data_type SelectedDataTypes: type: object description: The data-type selection actually persisted, including the implicit ATHLETE. properties: scopes: type: array items: type: string samples_enabled: type: boolean required: - scopes - samples_enabled SetProcessingTypeRequest: type: object properties: type: type: string enum: - json - fit - fhir description: The normalization output format to switch to. Required. Applies to the whole environment, not to one data type. required: - type SetSourceDomainRequest: type: object properties: hostname: type: string description: A subdomain you own, e.g. whoop.acme.com. Use a different one for each provider. required: - hostname Source: type: object description: A provider enabled for an environment, as every sources operation returns it. properties: provider: type: string description: The provider's slug, e.g. garmin or apple_health. active: type: boolean description: Whether the provider accepts new connections. A paused provider is false and stays listed with its credentials and scopes. auth_redirect_url: type: - string - 'null' description: Where the provider sends users back after they authorize, or null when it has none. auth_variant: type: string enum: - standard - byo description: 'How users connect by default: standard through Terra''s OAuth app, or byo through your own.' required: - provider - active - auth_redirect_url - auth_variant SourceDomain: type: object description: A subdomain you own that a provider's OAuth redirect, and for some providers its webhooks, run through. properties: provider: type: string description: The provider's slug, e.g. whoop. hostname: type: string description: The subdomain, lower-cased. state: type: string enum: - PROVISIONING - ACTIVE - FAILED description: PROVISIONING until the certificate is issued, then ACTIVE. FAILED needs the DNS record or CAA fixed; reason and detail say which. reason: type: - string - 'null' description: Why issuance is failing, as a machine-readable reason such as CAA. Null while nothing is wrong. detail: type: - string - 'null' description: What to fix, in words. Null while nothing is wrong. dns_record: description: The DNS record to publish at your DNS provider. $ref: '#/components/schemas/SourceDomainDnsRecord' resolved_ip: type: - string - 'null' description: The address the hostname resolves to now, preferring one of Terra's edge addresses. Null when it does not resolve. resolved_ips: type: array description: Every address the hostname publishes, both families. Empty when it does not resolve. items: type: string serving: type: boolean description: Whether Terra's edge answers TLS for the hostname. Only true once ACTIVE, and only then is the domain live. expires_at: type: - string - 'null' format: date-time description: When the certificate expires, as an ISO 8601 timestamp. Null until it is first issued. shared: type: boolean description: Whether another of your environments holds the certificate and this one reuses it. redirect_served: type: boolean description: Whether this environment's stored redirect for the provider is on this hostname. required: - provider - hostname - state - reason - detail - dns_record - resolved_ip - resolved_ips - serving - expires_at - shared - redirect_served SourceDomainDnsRecord: type: object description: The single record that points a subdomain at Terra's edge. properties: type: type: string enum: - A name: type: string description: The record name, which is the hostname. value: type: string description: The address to point it at. required: - type - name - value SubscribeRequest: type: object properties: startup_onboarding: type: boolean description: First event-plan onboarding. Only first customer creation sets the historical startup credit alert threshold; an existing customer is unchanged. scope: type: string enum: - startup - event_monthly - event_annual_base - metered - growth - graph_api - compliance_baa - enterprise_sla - data_enrichment - vantage - lab_reports - streaming - models - planned_workouts description: The plan or add-on selected by the admin API's server-owned Stripe price catalogue. schedule: type: string enum: - monthly - annual description: Required for startup. For other scopes, must match the configured price cadence. promo_code: type: string description: A promotional code to apply. Omitted applies none; an invalid one is rejected by the billing system rather than ignored. resume_only: type: boolean description: Resume only the original Idempotency-Key and purchase inputs. Never plans or creates a new purchase if its receipt is missing. Completion-only requests cannot preview a new purchase. required: - scope SubscriptionSummary: type: object properties: id: type: string status: type: string cancel_at_period_end: type: boolean collection_method: type: string cancel_at: type: - string - 'null' format: date-time description: Scheduled cancellation time; null when no explicit cancellation is scheduled. pause_collection: description: Stripe collection pause only; does not imply a paused subscription or service access. anyOf: - $ref: '#/components/schemas/SubscriptionPauseSummary' - type: 'null' items: type: array description: Native Stripe facts for every subscription item, including archived/custom prices. Never grants access or authorizes a purchase. items: $ref: '#/components/schemas/SubscriptionItemSummary' scopes: type: array description: Billing plan labels, not product access. Empty for canceled, incomplete or paused subscriptions; product access comes from /entitlements. items: type: string required: - cancel_at - pause_collection - items - scopes SupabaseCreateProject: type: object description: A new Supabase project to create and connect. properties: name: type: string description: The new project's name. organization_id: type: string description: The organization to create it in. It must be one listed in meta.organizations by the projects step, or this is a 400. region: type: string description: The Supabase region to create it in, such as us-east-1. Required; there is no default. required: - name - organization_id - region SupabaseOrganization: type: object description: A Supabase organization the OAuth session can see. properties: id: type: string name: type: string required: - id - name SupabaseProject: type: object description: A Supabase project the OAuth session can see. properties: id: type: string description: The project reference. Pass it to provision as project_ref. name: type: string organization_id: type: string description: The organization the project belongs to; its name is in meta.organizations. region: type: string status: type: string description: Supabase's own project status, such as ACTIVE_HEALTHY or INACTIVE. required: - id - name - organization_id - region - status SupabaseProvisionRequest: type: object properties: oauth_session_id: type: string description: The session handle the start step returned. Required. It must have reached the ready state, and not be provisioning or have provisioned already, or this is a 409; the Supabase access token stays server-side and is never sent here. project_ref: type: string description: 'An existing Supabase project to provision into: the id of a row from the projects step. Its status must not be paused, failed or removed, or this is a 422. Send exactly one of project_ref and create_project.' project_name: type: string description: Display only, with project_ref; defaults to the project's Supabase name. Not accepted with create_project, which names the project itself. create_project: description: 'A new project to create in one of the session''s organizations and provision into. Send exactly one of project_ref and create_project. Supabase may bill for the new project. Its database password is generated by Terra and returned once in the response, so send an Idempotency-Key: once a call succeeds, a retry with the same key returns the stored result with database_password null. If a call fails after Supabase created the project, retrying the same create_project on the same session resumes that project instead of creating a second one, and returns its password once it is connected.' $ref: '#/components/schemas/SupabaseCreateProject' replace_destination_id: type: string description: An existing Supabase destination in this environment to delete once the new one is written, such as a placeholder being replaced. A destination outside this environment is a 404 and one of another type a 400, both before anything is created. required: - oauth_session_id SupabaseProvisioned: type: object properties: provisioned: type: boolean project_ref: type: string description: 'The project provisioned into: the one passed, or the reference of the project created.' project_created: type: boolean description: Whether this call created the project. destination_id: type: string description: Id of the created Supabase data destination (string-encoded). It delivers every event type; manage it, including narrowing its event_types, via the destinations CRUD. database_password: type: - string - 'null' description: The new project's database password, returned once, by the call that connects the project it created. Terra holds it on the OAuth session only until then. Null when no project was created, and in an Idempotency-Key replay. replaced_destination_id: type: - string - 'null' description: The destination deleted in place of replace_destination_id. Null when none was requested, or when that delete failed after the new destination was written; delete it through the destinations endpoint then. required: - provisioned - project_ref - project_created - destination_id - database_password - replaced_destination_id SupabaseStartRequest: type: object properties: return_to: type: string enum: - cli - dashboard description: Where the browser lands after the user approves access. cli (the default) shows a page telling them to return to their terminal; dashboard returns to the Terra dashboard's connections page with the oauth_session_id in the query string, or with an error reason if the authorization failed. A closed set, never a URL. SupabaseStartResponse: type: object properties: authorization_url: type: string oauth_session_id: type: string expires_in: type: integer interval: type: integer SupabaseState: type: object properties: state: type: string description: pending | ready | failed TeamInvitation: type: object properties: id: type: string company_id: type: string email: type: string format: email role: type: string enum: - admin - developer source: description: Signup-path marker; null for an ordinary team invite. oneOf: - type: string - type: 'null' invited_by_user_id: oneOf: - type: string - type: 'null' created_at: type: string format: date-time expires_at: type: string format: date-time claimed_at: oneOf: - type: string format: date-time - type: 'null' claimed_by_user_id: oneOf: - type: string - type: 'null' required: - id - company_id - email - role - created_at - expires_at TeamInvitationResponse: type: object properties: token: type: string description: The one-use invitation token. Returned only here; only its digest is stored. expires_at: type: string format: date-time description: When the invitation stops being claimable (7 days after issue). required: - token - expires_at TeamMemberSummary: type: object description: 'One row of GET /team/members: a lean projection, not the full dashboard user.' properties: user_id: type: string name: type: string email: type: string format: email role: type: - string - 'null' description: 'null only on the legacy path, whose role column is nullable. Not an enum: the role vocabulary is not frozen until accounts.customer_member gains its CHECK.' required: - user_id - name - email - role AuthorizationCodeFormRequest: type: object description: Authorization-code exchange with mandatory S256 PKCE, authenticated as a public client by client_id alone. properties: grant_type: type: string enum: - authorization_code code: type: string redirect_uri: type: string code_verifier: type: string resource: type: string enum: - https://access.tryterra.co/api/v3/admin/mcp client_id: type: string description: The client ID metadata document URL. client_assertion_type: description: Not sent by public clients; a private_key_jwt client sends both assertion fields and matches the assertion variant. not: {} client_assertion: description: Not sent by public clients; a private_key_jwt client sends both assertion fields and matches the assertion variant. not: {} required: - grant_type - code - code_verifier - resource - client_id AuthorizationCodeAssertionFormRequest: type: object description: Authorization-code exchange with mandatory S256 PKCE, authenticated by a private_key_jwt assertion whose sub names the client. properties: grant_type: type: string enum: - authorization_code code: type: string redirect_uri: type: string code_verifier: type: string resource: type: string enum: - https://access.tryterra.co/api/v3/admin/mcp client_id: type: string description: Optional with an assertion; when present it must equal the assertion's iss and sub. client_assertion_type: type: string enum: - urn:ietf:params:oauth:client-assertion-type:jwt-bearer client_assertion: type: string description: An asymmetrically signed JWT of at most 4096 bytes with iss and sub equal to client_id, a single-valued aud equal to the issuer https://access.tryterra.co or the token endpoint https://access.tryterra.co/api/v3/admin/auth/token, a single-use jti and an exp at most five minutes ahead. required: - grant_type - code - code_verifier - resource - client_assertion_type - client_assertion TokenPollFormRequest: type: object description: RFC 8628 §3.4 device access token request (form-encoded wire mode). properties: grant_type: type: string enum: - urn:ietf:params:oauth:grant-type:device_code device_code: type: string client_id: type: string description: Must match the client_id the device_code was issued to; a mismatch is invalid_grant. required: - grant_type - device_code - client_id TokenResponse: type: object properties: token: type: string description: The bearer, shown once at mint or rotation. token_id: type: string kind: type: string enum: - admin - session - data description: The credential class. `admin` and `session` authenticate the admin API, and `data` the APIs your product calls at runtime under `/api/v2` and `/api/v3`; neither kind is accepted by the other's APIs. `session` is a short-lived per-login dashboard credential and never appears in token lists. customer_id: type: string scopes: type: array items: type: string dev_ids: type: - array - 'null' description: 'Audience: the dev-ids this token may act on. null = every dev of the account.' items: type: string expires_at: type: - string - 'null' format: date-time description: Expiry; null = never expires. name: type: string TokenSummary: type: object properties: oauth_client: type: string description: Durable OAuth client label, independent of the editable token name. token_id: type: string token_hint: type: - string - 'null' description: The bearer's kind prefix and last 4 characters (terra_at_…x7Kq, or …a1b2 for a legacy API key). null when the secret is under 32 characters or the token predates hints. kind: type: string enum: - admin - session - data description: The credential class. `admin` and `session` authenticate the admin API, and `data` the APIs your product calls at runtime under `/api/v2` and `/api/v3`; neither kind is accepted by the other's APIs. `session` is a short-lived per-login dashboard credential and never appears in token lists. name: type: string scopes: type: array items: type: string dev_ids: type: - array - 'null' description: 'Audience: the dev-ids this token may act on. null = every dev of the account.' items: type: string created_by: type: string created_via: type: string created_at: type: string format: date-time expires_at: type: - string - 'null' format: date-time description: Expiry; null = never expires. last_used_at: type: - string - 'null' format: date-time revoked_at: type: - string - 'null' format: date-time CurrentUsageResponse: type: object description: Current live metered items. Rows are independent; do not sum across currencies, meters or overlapping periods. properties: rows: type: array items: $ref: '#/components/schemas/CurrentUsageRow' meters: description: Every provider meter, including inactive meters needed to label invoice history. $ref: '#/components/schemas/RecordUsageMeter' required: - rows - meters $defs: RecordUsageMeter: type: object unevaluatedProperties: $ref: '#/components/schemas/UsageMeter' UserStatsCurrent: type: object description: Current log-derived balances, independent of the requested window. properties: observed_at: type: string format: date-time description: UTC time the connection statistics were read. This is an observation time, not an ingestion watermark or an atomic snapshot across stores. net_connections: type: integer description: Sum of provider net_connections. May differ from the number of active connections. providers: type: array description: Providers with recorded connection events, sorted by slug. Zero balances are retained. items: $ref: '#/components/schemas/UserStatsProvider' required: - observed_at - net_connections - providers UserStatsBucket: type: object description: Daily connection balances and activity counts within the requested window. properties: bucket_start: type: string format: date-time description: Inclusive UTC bucket boundary. The first bucket may start before since; activity is clipped to the requested window. net_connections: type: integer description: All-time CREATE minus DELETE balance at the end of this interval (exclusive), including quiet intervals. This is a closing balance, not a sum across buckets. net_connection_change: type: integer description: Connections created minus connections deleted within the interval. May be negative. connections_created: type: integer description: Connection CREATE events, not distinct people. connections_deleted: type: integer description: Connection DELETE events, not distinct people. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including retries and failures. bytes: type: integer description: Sum of outbound payload sizes in bytes, including retries and failed deliveries. required: - bucket_start - net_connections - net_connection_change - connections_created - connections_deleted - delivery_attempts - bytes UserStatsProvider: type: object description: Current all-time connection balance for one provider, independent of since and until. properties: provider: type: string description: Clean provider slug, for example garmin. net_connections: type: integer description: All recorded CREATE events minus DELETE events. Not a distinct-user or active-connection count. required: - provider - net_connections UserStatsResponse: type: object description: Connection and delivery analytics. Basic returns only scalar summary fields; full adds daily buckets and current provider balances. properties: since: type: string format: date-time description: Inclusive start of the event window, normalized to UTC. At most millisecond precision. until: type: string format: date-time description: Exclusive end of the event window, normalized to UTC. At most millisecond precision. Must be after since. view: type: string enum: - basic - full description: Resolved response detail level. Defaults to basic. net_connections: type: integer description: All-time CREATE minus DELETE balance at the end of this interval (exclusive), including quiet intervals. This is a closing balance, not a sum across buckets. net_connection_change: type: integer description: Connections created minus connections deleted within the interval. May be negative. connections_created: type: integer description: Connection CREATE events, not distinct people. connections_deleted: type: integer description: Connection DELETE events, not distinct people. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including retries and failures. bytes: type: integer description: Sum of outbound payload sizes in bytes, including retries and failed deliveries. granularity: type: string enum: - day description: Present only in the full view. UTC calendar-day aggregation. current: description: Present only in the full view. Latest observed log-derived connection balances, independent of the requested window. $ref: '#/components/schemas/UserStatsCurrent' series: type: array description: Present only in the full view. Ascending UTC daily buckets, including inactive days. Activity counts are zero-filled and connection balances carry forward. At most 1500 buckets. items: $ref: '#/components/schemas/UserStatsBucket' required: - since - until - view - net_connections - net_connection_change - connections_created - connections_deleted - delivery_attempts - bytes UserStatsTotals: type: object description: Window counts, closing connection balance, and net connection growth. properties: net_connections: type: integer description: All-time CREATE minus DELETE balance at the end of this interval (exclusive), including quiet intervals. This is a closing balance, not a sum across buckets. net_connection_change: type: integer description: Connections created minus connections deleted within the interval. May be negative. connections_created: type: integer description: Connection CREATE events, not distinct people. connections_deleted: type: integer description: Connection DELETE events, not distinct people. delivery_attempts: type: integer description: Recorded outbound delivery attempts, including retries and failures. bytes: type: integer description: Sum of outbound payload sizes in bytes, including retries and failed deliveries. required: - net_connections - net_connection_change - connections_created - connections_deleted - delivery_attempts - bytes UserSummary: type: object properties: user_id: type: string reference_id: type: string provider: type: string active: type: boolean scopes: type: array description: Scopes the user granted the provider when connecting. Empty when the provider reports none. items: type: string created_at: type: - string - 'null' format: date-time last_updated_at: type: - string - 'null' format: date-time most_recent_data_at: type: - string - 'null' format: date-time required: - scopes LabReportsApiVersion: type: object description: The environment's pinned lab-reports API version. X-Terra-Version on a request still overrides the pin for that request. properties: pinned: type: - string - 'null' description: The version requests without X-Terra-Version are served. null when the environment has no pin, in which case they are served the latest version. latest: type: string description: The newest version, which an environment without a pin is served. versions: type: array description: Every version the pin can be set to, newest first. items: $ref: '#/components/schemas/ApiVersionEntry' required: - pinned - latest - versions ApiVersionEntry: type: object description: One servable API version of a versioned product and what it changed. properties: version: type: string description: The version's date, as sent in X-Terra-Version. summary: type: string description: What this version changed from the one before it. required: - version - summary SetLabReportsApiVersionRequest: type: object properties: version: type: string description: The version to pin, one of the versions GET lists. Takes effect on the environment's next request. required: - version additionalProperties: false VantageApiVersion: type: object description: The environment's pinned Vantage API version. An environment is pinned to the then-latest version on its first Vantage request; X-Terra-Version on a request still overrides the pin for that request. properties: pinned: type: - string - 'null' description: The version requests without X-Terra-Version are served. null until the environment's first Vantage request pins it. latest: type: string description: The newest version, which an environment is pinned to on its first request. versions: type: array description: Every version the pin can be set to, newest first. items: $ref: '#/components/schemas/ApiVersionEntry' required: - pinned - latest - versions VantageMarkets: type: object description: The markets whose products the environment's Vantage catalogue lists and its orders accept. Vantage sells in the UK and the US, and each market offers different products. Testing and staging environments choose their own markets; Terra sets a production environment's during account setup. properties: markets: type: - array - 'null' description: The markets the environment's catalogue lists and its orders accept, ordered by identifier. null until markets are chosen, while the environment has every market, including any added later. items: type: string minItems: 1 uniqueItems: true editable: type: boolean description: Whether this environment can change its own markets. false for a production environment, whose markets Terra sets. available: type: array description: Every market Vantage sells in. items: $ref: '#/components/schemas/VantageMarketEntry' required: - markets - editable - available VantageMarketEntry: type: object properties: market: type: string description: The market's identifier, as sent in markets. name: type: string description: The market's display name. required: - market - name SetVantageMarketsRequest: type: object properties: markets: type: - array - 'null' description: The full set of markets to sell in, at least one, each one of the markets GET lists; replaces the current set. null clears the choice, so the environment has every market. items: type: string minItems: 1 uniqueItems: true required: - markets additionalProperties: false VantageWebhook: type: object description: Where the environment's Vantage webhook events are delivered. Vantage keeps one webhook URL per environment; retrieving its secrets reveals the secret deliveries are signed with. properties: url: type: - string - 'null' description: The HTTPS URL Vantage webhook events are delivered to. null when none is set, so events are not delivered. required: - url VantageWebhookSecrets: type: object description: The Vantage webhook's secrets in plaintext. properties: signing_secret: type: - string - 'null' description: The secret deliveries are signed with. null while no URL is set, as nothing is delivered. required: - signing_secret SetVantageWebhookRequest: type: object properties: url: type: - string - 'null' description: The HTTPS URL to deliver Vantage webhook events to, replacing the current one, without credentials in it. null stops delivery. required: - url additionalProperties: false VantageCatalogueProduct: type: object description: One product in Vantage's catalogue. The catalogue is the same whatever the environment's markets; markets says where each product is sold. properties: product_id: type: string description: The product's id, as products and its variants name it. name: type: string description: The product's name. description: description: The product's description as rich text, exactly as the Vantage API's latest version serves it. $ref: '#/components/schemas/VantageRichText' product_type_id: type: string description: The id of the product's type, the category the Vantage API lists products under. product_type: type: string description: The name of the product's type, e.g. Blood Tests. markets: type: array description: The markets the product is sold in, e.g. uk or us, ordered by identifier. An environment can enable and order it only when one of these is among its markets. items: type: string variants: type: array description: The ways the product is sold, such as a home kit or a nurse visit, ordered by variant_id. An order names one by its variant_id. items: $ref: '#/components/schemas/VantageCatalogueVariant' required: - product_id - name - description - product_type_id - product_type - markets - variants VantageProduct: type: object description: A product the environment's Vantage catalogue lists and its orders accept. Its name, type and markets are on the catalogue. properties: product_id: type: string description: The product's id, as the catalogue lists it. required: - product_id BatchEnableVantageProductsRequest: type: object properties: product_ids: type: array description: 'The products to enable, by id: at least 1 and at most 100, each listed once. An unrecognised or repeated product is a 400, and one not sold in the environment''s markets is a 422, each naming its position, and then nothing is enabled.' items: type: string minItems: 1 maxItems: 100 uniqueItems: true required: - product_ids additionalProperties: false BatchDisableVantageProductsRequest: type: object properties: product_ids: type: array description: 'The products to disable, by id: at least 1 and at most 100, each listed once. An unrecognised or repeated product is a 400, and one that is not enabled is a 404, each naming its position, and then nothing is disabled.' items: type: string minItems: 1 maxItems: 100 uniqueItems: true required: - product_ids additionalProperties: false BatchEnabledVantageProducts: type: object properties: data: type: array description: One entry per requested product, in request order. items: $ref: '#/components/schemas/VantageProduct' required: - data VantageCatalogueVariant: type: object description: One way a catalogue product is sold. properties: variant_id: type: string description: The variant's id, as orders and the variant enablement routes name it. name: type: string description: The variant's name, e.g. Men's Health - nurse visit at home. required: - variant_id - name VantageVariant: type: object description: 'A variant the environment''s Vantage catalogue lists and its orders accept: its product is enabled and the environment has not disabled the variant. Its name is on the catalogue.' properties: variant_id: type: string description: The variant's id, as the catalogue lists it. product_id: type: string description: The id of the product the variant belongs to, as the catalogue lists it. required: - variant_id - product_id BatchEnableVantageVariantsRequest: type: object properties: variant_ids: type: array description: 'The variants to enable, by id: at least 1 and at most 100, each listed once. An unrecognised or repeated variant is a 400, and one whose product is not enabled or not sold in the environment''s markets is a 422, each naming its position, and then nothing is enabled.' items: type: string minItems: 1 maxItems: 100 uniqueItems: true required: - variant_ids additionalProperties: false BatchDisableVantageVariantsRequest: type: object properties: variant_ids: type: array description: 'The variants to disable, by id: at least 1 and at most 100, each listed once. An unrecognised or repeated variant is a 400, one that is not enabled is a 404, and one whose product would be left with no enabled variant is a 422, each naming its position, and then nothing is disabled.' items: type: string minItems: 1 maxItems: 100 uniqueItems: true required: - variant_ids additionalProperties: false BatchEnabledVantageVariants: type: object properties: data: type: array description: One entry per requested variant, in request order. items: $ref: '#/components/schemas/VantageVariant' required: - data ResendVantageEventRequest: type: object properties: event_id: type: string description: The event to send again, by its event_id from the event list. An unknown event is a 404, as is one Vantage no longer keeps the body of. required: - event_id additionalProperties: false VantageResendResult: type: object properties: event_id: type: string event_type: type: string description: The webhook's event type, e.g. order.status_changed. dispatched: type: boolean description: Whether the event was queued. false in a dry-run preview. required: - event_id - event_type - dispatched GenerateVantageEventRequest: type: object properties: event_type: type: string description: 'The webhook type to send: order.status_changed or order_item.results_status_change. Required.' status: type: - string - 'null' description: The status the event announces, one that type of webhook carries, e.g. order.delivery_fulfilled or results.results_ready. Omitted or null, order.delivery_fulfilled for an order event and results.results_ready for a results event. required: - event_type additionalProperties: false VantageGenerateResult: type: object properties: event_id: type: string description: The generated event's id, the one its delivery is listed under. event_type: type: string description: The webhook's event type. dispatched: type: boolean description: Whether the event was queued. false in a dry-run preview. payload: description: The body the webhook carries, in the latest Vantage API version. Its test field is true, and every order, item, variant and test-taker id in it is "0". $ref: '#/components/schemas/RecordUnknown' required: - event_id - event_type - dispatched - payload $defs: RecordUnknown: type: object unevaluatedProperties: {} SimulateVantageOrderRequest: type: object properties: event: type: string description: The lifecycle event to apply, e.g. processing or results_ready. GET /environments/{dev_id}/vantage/simulation lists the events each status accepts. Required. order_item_id: type: string description: The item a results event applies to. Omitted, a results event applies to every item of the order, and is refused unless every item accepts it. Ignored for an order event. required: - event additionalProperties: false VantageSimulateResult: type: object properties: order_id: type: string applied_event: type: string description: The event applied, or that would be in a dry-run preview. required: - order_id - applied_event VantageSimulation: type: object description: The events the sandbox order simulator accepts from each status. Simulation steps through these one event at a time; production status updates come from suppliers and are not bound to them. properties: order: description: Order status transitions, the same for every order. $ref: '#/components/schemas/VantageSimulationTransitions' results: type: array description: Results status transitions per product type. A product type that produces no result, such as a supplement, is absent. items: $ref: '#/components/schemas/VantageResultsSimulation' required: - order - results VantageSimulationTransitions: type: object description: The events accepted from each status. A status that accepts none is absent. properties: transitions: description: Keyed by status; each value lists the events accepted from it, sorted. $ref: '#/components/schemas/RecordArrayString' required: - transitions $defs: RecordArrayString: type: object unevaluatedProperties: type: array items: type: string VantageResultsSimulation: type: object properties: transitions: description: Keyed by status; each value lists the events accepted from it, sorted. $ref: '#/components/schemas/RecordArrayString' product_type_id: type: string description: The product type these results transitions apply to, as order items carry it. required: - transitions - product_type_id $defs: RecordArrayString: type: object unevaluatedProperties: type: array items: type: string VantageStats: type: object description: Vantage order, result and webhook statistics for CLI output and dashboard charts. properties: since: type: string format: date-time description: Inclusive requested start in UTC, with at most millisecond precision. until: type: string format: date-time description: Exclusive requested end in UTC, with at most millisecond precision. view: type: string enum: - basic - full description: Resolved response detail level. Defaults to basic. timezone: type: string description: The IANA time zone buckets are truncated in, as requested. UTC by default. orders: $ref: '#/components/schemas/VantageStatsOrders' results: $ref: '#/components/schemas/VantageStatsResults' webhooks: $ref: '#/components/schemas/VantageStatsWebhooks' current: $ref: '#/components/schemas/VantageStatsCurrent' granularity: type: string enum: - hour - day - week description: Present only in the full view. Bucket size, as requested or resolved from the window duration. series: type: array description: Present only in the full view. Counts in ascending buckets, including empty ones. At most 1500 buckets. items: $ref: '#/components/schemas/VantageStatsBucket' time_to_result: description: Present only in the full view. $ref: '#/components/schemas/VantageStatsTimeToResult' breakdowns: description: Present only in the full view. $ref: '#/components/schemas/VantageStatsBreakdowns' comparison: description: Present only in the full view when compare=previous_period was requested. $ref: '#/components/schemas/VantageStatsComparison' required: - since - until - view - timezone - orders - results - webhooks - current VantageStatsBreakdowns: type: object properties: products: type: array description: The ten products ordered most in the window, most first. items: $ref: '#/components/schemas/VantageStatsProduct' required: - products VantageStatsBucket: type: object description: Counts within one bucket. properties: bucket_start: type: string format: date-time description: Bucket start in UTC, truncated in the requested time zone. The first bucket may start before since. orders: type: integer results: type: integer failed_webhooks: type: integer required: - bucket_start - orders - results - failed_webhooks VantageStatsComparison: type: object description: The equal-duration window immediately preceding since. properties: since: type: string format: date-time description: Inclusive start of the preceding window in UTC. until: type: string format: date-time description: Exclusive end of the preceding window, equal to the requested since. orders: $ref: '#/components/schemas/VantageStatsOrders' results: $ref: '#/components/schemas/VantageStatsResults' webhooks: $ref: '#/components/schemas/VantageStatsWebhooks' time_to_result: $ref: '#/components/schemas/VantageStatsTimeToResult' series: type: array description: Counts in ascending buckets, including empty ones. items: $ref: '#/components/schemas/VantageStatsBucket' required: - since - until - orders - results - webhooks - time_to_result - series VantageStatsCurrent: type: object description: Counts as of observed_at, independent of the window. properties: observed_at: type: string format: date-time description: 'UTC time the counts were read: the request time.' unacknowledged_results: type: integer description: Order items with a results status that are not acknowledged, as the results list shows with is_acknowledged=false. delayed_orders: type: integer description: Orders whose current status is order.delayed. payment_failed_orders_last_7d: type: integer description: Orders placed in the last 7 days whose current status is order.payment_failed. failed_webhooks_last_24h: type: integer description: Webhook deliveries that failed in the last 24 hours. failed_results: type: integer description: Order items whose current results status became results.sample_rejected, results.lab_processing_error or results.escalation_raised in the last 30 days. kits_awaiting_sample_14d: type: integer description: Order items whose current results status has been results.awaiting_sample for more than 14 days. required: - observed_at - unacknowledged_results - delayed_orders - payment_failed_orders_last_7d - failed_webhooks_last_24h - failed_results - kits_awaiting_sample_14d VantageStatsOrders: type: object description: Orders placed in the window, by their current status. properties: total: type: integer by_status: description: Order counts keyed by current status, such as order.completed. $ref: '#/components/schemas/RecordInteger' required: - total - by_status $defs: RecordInteger: type: object unevaluatedProperties: type: integer VantageStatsProduct: type: object properties: product_id: type: string name: type: string orders: type: integer description: Orders in the window with at least one item of this product. required: - product_id - name - orders VantageStatsResults: type: object properties: total: type: integer description: Order items whose first result arrived in the window. required: - total VantageStatsTimeToResult: type: object properties: median_hours: type: - number - 'null' description: Median hours from order placement to an item's first result, over items whose result arrived in the window. Null without samples. samples: type: integer required: - median_hours - samples VantageStatsWebhooks: type: object properties: failed: type: integer description: Webhook deliveries that failed in the window. required: - failed VantageEvent: type: object description: One Vantage webhook event and where its delivery stands. Production and sandbox are separate Vantage deployments with their own events; a production environment's events are in production Vantage, and every other environment's are in sandbox. properties: event_id: type: string description: The event's id, as the webhook's event_id carries it. event_type: type: string description: The webhook's event type, e.g. order.status_changed or order_item.results_status_change. order_id: type: - string - 'null' description: The order the event is about. null for a test event, which has no order. order_item_id: type: - string - 'null' description: The order item the event is about. null when the event is about the whole order. client_order_reference_id: type: - string - 'null' description: Your reference for the order, as set when it was created. null when there is none, and for a test event. status: type: string enum: - pending - delivered - failed - canceled description: |- Where delivery stands. An event exists as soon as it happens, before Terra first tries to deliver it. pending: not delivered yet, either because no attempt has been made or because the last attempt failed and Terra will retry it at next_attempt_at. delivered: your endpoint returned a 2xx response. failed: Terra stopped trying, after a response it does not retry, a URL that can never be delivered to, or the last retry. canceled: never sent, because current access suppressed it; no_status_reason says why. last_status_code: type: - integer - 'null' description: The HTTP status your endpoint returned to the latest attempt, including a non-2xx one. null when no_status_reason is set, and before the first attempt. minimum: -2147483648 maximum: 2147483647 no_status_reason: type: - string - 'null' enum: - no_destination - no_access - catalogue_restricted - order_missing - environment_missing - source_mismatch - owner_changed - recipient_changed - invalid_url - host_not_found - connection_failed - not_recorded - null description: |- Why last_status_code is null. At most one of the two is non-null; both are null before the first attempt, while status is pending. Never sent, because current access suppressed the delivery (status canceled): no_destination (no webhook URL is set for the environment), no_access (the environment does not hold Vantage, or is not served by this deployment), catalogue_restricted (the order item's product is disabled in your catalogue), order_missing (the order no longer exists), environment_missing (the environment no longer exists), source_mismatch (the event's ids do not match the order), owner_changed (the environment or customer that owns the work changed), recipient_changed (an event queued before account snapshots whose original URL or signing secret is no longer current). No response to the latest attempt: invalid_url (the URL can never be delivered to: it does not parse, has no host, or is not http or https; status is failed and it is not retried), host_not_found (the attempt found no DNS record for the URL's host), connection_failed (the attempt got no HTTP response, for example a refused connection, TLS failure or timeout). not_recorded: no attempt result is known, either because the event was recorded before the reason was stored or because it failed without one. attempt_count: type: integer description: How many delivery attempts were made. minimum: -2147483648 maximum: 2147483647 next_attempt_at: type: - string - 'null' format: date-time description: When Terra next tries to deliver the event. Set only while status is pending with a retry scheduled. completed_at: type: - string - 'null' format: date-time description: When delivery reached its status. null while status is pending. event_created_at: type: string format: date-time description: When the event was created. since and until filter on this. required: - event_id - event_type - order_id - order_item_id - client_order_reference_id - status - last_status_code - no_status_reason - attempt_count - next_attempt_at - completed_at - event_created_at VantageEventDetail: type: object description: A Vantage webhook event with each attempt to deliver it. properties: event_id: type: string description: The event's id, as the webhook's event_id carries it. event_type: type: string description: The webhook's event type, e.g. order.status_changed or order_item.results_status_change. order_id: type: - string - 'null' description: The order the event is about. null for a test event, which has no order. order_item_id: type: - string - 'null' description: The order item the event is about. null when the event is about the whole order. client_order_reference_id: type: - string - 'null' description: Your reference for the order, as set when it was created. null when there is none, and for a test event. status: type: string enum: - pending - delivered - failed - canceled description: |- Where delivery stands. An event exists as soon as it happens, before Terra first tries to deliver it. pending: not delivered yet, either because no attempt has been made or because the last attempt failed and Terra will retry it at next_attempt_at. delivered: your endpoint returned a 2xx response. failed: Terra stopped trying, after a response it does not retry, a URL that can never be delivered to, or the last retry. canceled: never sent, because current access suppressed it; no_status_reason says why. last_status_code: type: - integer - 'null' description: The HTTP status your endpoint returned to the latest attempt, including a non-2xx one. null when no_status_reason is set, and before the first attempt. minimum: -2147483648 maximum: 2147483647 no_status_reason: type: - string - 'null' enum: - no_destination - no_access - catalogue_restricted - order_missing - environment_missing - source_mismatch - owner_changed - recipient_changed - invalid_url - host_not_found - connection_failed - not_recorded - null description: |- Why last_status_code is null. At most one of the two is non-null; both are null before the first attempt, while status is pending. Never sent, because current access suppressed the delivery (status canceled): no_destination (no webhook URL is set for the environment), no_access (the environment does not hold Vantage, or is not served by this deployment), catalogue_restricted (the order item's product is disabled in your catalogue), order_missing (the order no longer exists), environment_missing (the environment no longer exists), source_mismatch (the event's ids do not match the order), owner_changed (the environment or customer that owns the work changed), recipient_changed (an event queued before account snapshots whose original URL or signing secret is no longer current). No response to the latest attempt: invalid_url (the URL can never be delivered to: it does not parse, has no host, or is not http or https; status is failed and it is not retried), host_not_found (the attempt found no DNS record for the URL's host), connection_failed (the attempt got no HTTP response, for example a refused connection, TLS failure or timeout). not_recorded: no attempt result is known, either because the event was recorded before the reason was stored or because it failed without one. attempt_count: type: integer description: How many delivery attempts were made. minimum: -2147483648 maximum: 2147483647 next_attempt_at: type: - string - 'null' format: date-time description: When Terra next tries to deliver the event. Set only while status is pending with a retry scheduled. completed_at: type: - string - 'null' format: date-time description: When delivery reached its status. null while status is pending. event_created_at: type: string format: date-time description: When the event was created. since and until filter on this. webhook_url: type: - string - 'null' description: The URL of the latest attempt. null before the first attempt. attempts: type: array description: Each attempt to deliver the event, newest first. Attempts are kept for 30 days, so an older event has none listed. items: $ref: '#/components/schemas/VantageEventAttempt' required: - event_id - event_type - order_id - order_item_id - client_order_reference_id - status - last_status_code - no_status_reason - attempt_count - next_attempt_at - completed_at - event_created_at - webhook_url - attempts VantageOrder: type: object description: One Vantage order, as the order list shows it. Production and sandbox are separate Vantage deployments with their own orders; a production environment's orders are in production Vantage, and every other environment's are in sandbox. properties: order_id: type: string client_order_reference_id: type: - string - 'null' description: Your reference for the order, as set when it was created. null when there is none. status: description: 'The order''s own status: payment, fulfilment and completion. Each item''s results have their own status.' $ref: '#/components/schemas/VantageOrderStatus' collection_type: type: - string - 'null' enum: - AT_HOME - GO_TO_LAB - null description: AT_HOME for a home test kit, GO_TO_LAB for a walk-in lab visit. created_at: type: string format: date-time description: When the order was placed. since and until filter on this. total_cents: type: integer description: The order total in the currency's minor unit. minimum: -2147483648 maximum: 2147483647 currency: type: - string - 'null' description: ISO 4217 code. null when the order has no recorded total. recipient: description: null when the order has no recipient on record. anyOf: - $ref: '#/components/schemas/VantageOrderRecipient' - type: 'null' items: type: array items: $ref: '#/components/schemas/VantageOrderItem' required: - order_id - client_order_reference_id - status - collection_type - created_at - total_cents - currency - recipient - items VantageOrderDetail: type: object description: 'One Vantage order with everything about it: recipient, addresses, lab, shipping, items and the order''s status history.' properties: order_id: type: string client_order_reference_id: type: - string - 'null' description: Your reference for the order, as set when it was created. null when there is none. status: description: 'The order''s own status: payment, fulfilment and completion. Each item''s results have their own status.' $ref: '#/components/schemas/VantageOrderStatus' collection_type: type: - string - 'null' enum: - AT_HOME - GO_TO_LAB - null description: AT_HOME for a home test kit, GO_TO_LAB for a walk-in lab visit. created_at: type: string format: date-time description: When the order was placed. since and until filter on this. total_cents: type: integer description: The order total in the currency's minor unit. minimum: -2147483648 maximum: 2147483647 currency: type: - string - 'null' description: ISO 4217 code. null when the order has no recorded total. recipient: anyOf: - $ref: '#/components/schemas/VantagePerson' - type: 'null' shipping_address: anyOf: - $ref: '#/components/schemas/VantageAddress' - type: 'null' requested_lab: anyOf: - $ref: '#/components/schemas/VantageRequestedLab' - type: 'null' confirmed_lab: anyOf: - $ref: '#/components/schemas/VantageConfirmedLab' - type: 'null' shipping_carrier: type: - string - 'null' tracking_number: type: - string - 'null' tracking_url: type: - string - 'null' estimated_delivery_date: type: - string - 'null' format: date-time items: type: array items: $ref: '#/components/schemas/VantageOrderItemDetail' status_history: type: array description: The order's own status changes, newest first. Each result has its own history. items: $ref: '#/components/schemas/VantageOrderStatusChange' required: - order_id - client_order_reference_id - status - collection_type - created_at - total_cents - currency - recipient - shipping_address - requested_lab - confirmed_lab - shipping_carrier - tracking_number - tracking_url - estimated_delivery_date - items - status_history VantageOrderStatus: type: string enum: - order.payment_processing - order.payment_complete - order.payment_failed - order.processing - order.delayed - order.delivery_fulfilled - order.completed - order.cancelled description: A Vantage order's status, as its webhooks and Vantage's API spell it, in lifecycle order. VantageResult: type: object description: 'One Vantage result: an order item''s lab work. There is one per order item. Production and sandbox are separate Vantage deployments with their own results.' properties: order_item_id: type: string order_id: type: string client_order_reference_id: type: - string - 'null' description: The order's reference, as set when it was created. null when there is none. variant_id: type: string product_name: type: - string - 'null' description: The product's name. null when the catalogue no longer has it. status: $ref: '#/components/schemas/VantageResultStatus' created_at: type: string format: date-time description: When the order item was created. Results sort on this. updated_at: type: string format: date-time description: When the results status last changed. since and until filter on this. acknowledged_at: type: - string - 'null' format: date-time description: When you first acknowledged the result. null until then. test_taker_id: type: - string - 'null' description: null until the kit is activated. required: - order_item_id - order_id - client_order_reference_id - variant_id - product_name - status - created_at - updated_at - acknowledged_at - test_taker_id VantageResultDetail: type: object description: One Vantage result with its test taker, kit and results status history. properties: order_item_id: type: string order_id: type: string client_order_reference_id: type: - string - 'null' description: The order's reference, as set when it was created. null when there is none. variant_id: type: string product_name: type: - string - 'null' description: The product's name. null when the catalogue no longer has it. status: $ref: '#/components/schemas/VantageResultStatus' created_at: type: string format: date-time description: When the order item was created. Results sort on this. updated_at: type: string format: date-time description: When the results status last changed. since and until filter on this. acknowledged_at: type: - string - 'null' format: date-time description: When you first acknowledged the result. null until then. test_taker_id: type: - string - 'null' description: null until the kit is activated. test_taker: description: null until the kit is activated. anyOf: - $ref: '#/components/schemas/VantagePerson' - type: 'null' result_type: type: string enum: - fhir_bundle - dna_result description: The payload's format. result_version: type: - integer - 'null' description: The stored result's version, which rises when the lab amends it. null until a result is stored. minimum: -2147483648 maximum: 2147483647 ready_at: type: - string - 'null' format: date-time description: When the result first became ready, partially or fully. null until then. shipping_status: type: - string - 'null' enum: - pending_shipment - in_transit - delivery_attempted - delivered - null kit_id: type: - string - 'null' description: The supplier's id for the kit or item. lab_tracking_number: type: - string - 'null' collection_visit: anyOf: - $ref: '#/components/schemas/VantageCollectionVisit' - type: 'null' status_history: type: array description: Newest first. items: $ref: '#/components/schemas/VantageResultStatusChange' required: - order_item_id - order_id - client_order_reference_id - variant_id - product_name - status - created_at - updated_at - acknowledged_at - test_taker_id - test_taker - result_type - result_version - ready_at - shipping_status - kit_id - lab_tracking_number - collection_visit - status_history VantageResultStatus: type: string enum: - results.awaiting_sample - results.kit_activated - results.sample_processing_in_lab - results.genome_processing - results.partial_results_ready - results.results_ready - results.sample_reanalysis - results.reanalysed - results.sample_rejected - results.lab_processing_error - results.escalation_raised - results.not_applicable description: |- A Vantage result's status: its latest stored results status, as Vantage's API and its status history spell it. Acknowledgement is not a status; see acknowledged_at. genome_processing, sample_reanalysis and reanalysed are DNA only; not_applicable is an item that never produces a result. SetVantageApiVersionRequest: type: object properties: version: type: string description: The version to pin, one of the versions GET lists. Takes effect on the environment's next request. required: - version additionalProperties: false WidgetConfig: type: object description: 'Widget branding + config for a dev-id. The configuration is the inlined widget_config document; widget_config_url is retired: no longer returned, and rejected with 400 on PUT.' properties: widget_config_url: type: - string - 'null' description: 'Retired: no longer returned, and rejected with 400 on PUT. Send widget_config instead.' widget_config: type: - object - 'null' description: The widget configuration document, served inline. additionalProperties: true widget_name: type: - string - 'null' description: Name shown to end users in the widget. null clears it. app_logo: type: - string - 'null' description: Logo shown to end users in the widget, as a URL. null clears it. WorkoutMetadata: type: object properties: workout_id: type: string created_at: type: string format: date-time pace_units: type: - object - 'null' additionalProperties: true CreateSyntheticUserRequest: type: object properties: description: type: string description: Plain-language description of the person to simulate, translated into a persona. Required unless persona is given; at most 2000 characters. maxLength: 2000 persona: description: A structured persona to use as given instead of translating a description. $ref: '#/components/schemas/SyntheticPersona' duration_hours: type: number enum: - 24 - 48 - 72 - 168 description: How long the first run generates data for. reference_id: type: string description: Your own identifier for the user, returned on its webhooks. maxLength: 128 provider: type: string description: A real provider whose data shape to simulate, e.g. GARMIN. Data types it does not support are left out. backfill_days: type: integer description: Days of past data to add when the user is created, up to 90. minimum: 0 maximum: 90 default: 0 required: - duration_hours anyOf: - required: - description - required: - persona StartSyntheticUserRequest: type: object properties: duration_hours: type: number enum: - 24 - 48 - 72 - 168 description: How long the new run generates data for. Defaults to the latest run's duration; required for a user that has never run. description: type: string description: A new plain-language description to generate from instead of the latest run's persona; at most 2000 characters. A user that has never run needs this or persona. maxLength: 2000 persona: description: A structured persona to generate from instead of the latest run's. $ref: '#/components/schemas/SyntheticPersona' SyntheticPersona: type: object description: The structured persona a synthetic user generates data for. A description is translated into this; passing it directly skips the translation. properties: data_types: type: object description: 'How often each data type (daily, sleep, activity, body, nutrition, menstruation) arrives: normal, sparse or missing.' unevaluatedProperties: type: string enum: - normal - sparse - missing biases: $ref: '#/components/schemas/SyntheticPersonaBiases' SyntheticPersonaBiases: type: object description: Biases applied to a synthetic user's generated values. Each is low, normal or high; blood_pressure is normal, elevated or high. properties: sleep_duration: type: string enum: - low - normal - high sleep_quality: type: string enum: - low - normal - high recovery: type: string enum: - low - normal - high stress: type: string enum: - low - normal - high resting_heart_rate: type: string enum: - low - normal - high activity_volume: type: string enum: - low - normal - high blood_pressure: type: string enum: - normal - elevated - high blood_pressure_anomaly_rate: type: number description: Share of blood-pressure readings that are anomalous, from 0 to 1. minimum: 0 maximum: 1 blood_glucose: type: string enum: - low - normal - high SyntheticUser: type: object description: 'A synthetic user: a connection that receives generated data shaped by a persona, in time-boxed runs.' properties: user_id: type: string description: The user's id, the same one data reads and webhooks carry. reference_id: type: - string - 'null' description: Your own identifier for the user, given when it was created; null when none was. description: type: - string - 'null' description: The description its latest run was created from; null when a persona was passed directly. persona: anyOf: - $ref: '#/components/schemas/SyntheticPersona' - type: 'null' provider: type: - string - 'null' description: The real provider whose data shape generation follows; null for the default shape. status: type: string enum: - generating - stopped sample: type: boolean description: 'True for one of the environment''s sample users: fixed personas with shared history that cannot be started or uploaded to.' created_at: type: string format: date-time latest_run: description: The latest generation run; null for a user that has never run. anyOf: - $ref: '#/components/schemas/SyntheticUserRun' - type: 'null' required: - user_id - reference_id - description - persona - provider - status - sample - created_at - latest_run SyntheticUserRun: type: object description: One time-boxed generation run of a synthetic user. properties: run_id: type: string status: type: string enum: - active - completed - cancelled description: active while generating, completed once it reached expires_at, cancelled when stopped. duration_hours: type: number enum: - 24 - 48 - 72 - 168 cadence_seconds: type: integer description: Seconds between generated payloads. minimum: -2147483648 maximum: 2147483647 payloads_sent: type: integer minimum: -2147483648 maximum: 2147483647 started_at: type: string format: date-time expires_at: type: string format: date-time next_run_at: type: - string - 'null' format: date-time description: When the next payload is due; null once the run has ended. last_run_at: type: - string - 'null' format: date-time required: - run_id - status - duration_hours - cadence_seconds - payloads_sent - started_at - expires_at - next_run_at - last_run_at SampleUser: type: object description: One of the environment's sample users, with the shared history window it can be read over. properties: user_id: type: string description: The synthetic user's id in this environment, usable wherever a user id is accepted. reference_id: type: string description: Fixed reference id, the same in every environment (terra-sample-runner, terra-sample-short-sleeper, ...). name: type: string description: Short human name for the persona. description: type: string description: One line on what the persona's data looks like. days_written: type: integer description: How many days of history this call generated; zero when the history was already there. minimum: -2147483648 maximum: 2147483647 history_from: type: string format: date-time description: Start of the covered history window (UTC midnight). history_to: type: string format: date-time description: Most recent moment the history reaches. required: - user_id - reference_id - name - description - days_written - history_from - history_to EnsureSampleUsersRequest: type: object properties: days: type: integer description: How many days of history, ending now, every sample user must have. Days already present are not rewritten. minimum: 1 maximum: 90 default: 90 AccountBilling: type: object properties: linked: type: boolean description: true when a Stripe customer is linked to the account. Billing reads on an unlinked account answer 404. required: - linked SubscriptionPauseSummary: type: object properties: behavior: type: string resumes_at: type: - string - 'null' format: date-time description: RFC3339 timestamp, or null for an indefinite collection pause. required: - behavior - resumes_at SubscriptionRecurringSummary: type: object properties: interval: type: string interval_count: type: integer format: int64 usage_type: type: string required: - interval - interval_count - usage_type SubscriptionItemSummary: type: object properties: name: type: - string - 'null' description: Stripe Product name; null for deleted products or unavailable names. Never inferred from plan labels. currency: type: string billing_scheme: type: string unit_amount: type: - integer - 'null' format: int64 description: 'Integer unit amount in the currency''s minor unit. Null for fractional, tiered, custom or unavailable prices. Not an invoice total: discounts, tax, quantity transforms and usage are not applied.' quantity: type: - integer - 'null' format: int64 description: Licensed quantity only; null for metered or unavailable recurrence. recurring: anyOf: - $ref: '#/components/schemas/SubscriptionRecurringSummary' - type: 'null' current_period_start: type: - string - 'null' format: date-time description: RFC3339 timestamp, or null when unavailable. Mixed-interval subscriptions retain each item's period. current_period_end: type: - string - 'null' format: date-time required: - name - currency - billing_scheme - unit_amount - quantity - recurring - current_period_start - current_period_end InvoiceLineSummary: type: object properties: subscription_id: type: string description: Subscription that owns this line, when supplied by the billing provider; never inferred from the invoice or price. id: type: string description: type: string amount: type: integer format: int64 currency: type: string quantity: type: - integer - 'null' format: int64 period_start: type: - string - 'null' format: date-time period_end: type: - string - 'null' format: date-time price_id: type: string product_id: type: string meter_id: type: string description: Meter for this historical price, including prices no longer subscribed. Omitted for non-metered lines. required: - id - description - amount - currency - quantity - period_start - period_end UsageMeter: type: object properties: event_name: type: string display_name: type: string required: - event_name - display_name UsageDay: type: object properties: t: type: integer format: int64 description: UTC midnight Unix seconds; the bucket ends at t + 86400. value: type: number required: - t - value UsagePriceTier: type: object properties: up_to: type: - integer - 'null' format: int64 description: null denotes the unlimited terminal tier. unit_amount_decimal: type: - string - 'null' description: Exact native decimal component; null when the provider has no per-unit component. flat_amount_decimal: type: - string - 'null' description: Exact native decimal component; null when the provider has no flat component. required: - up_to - unit_amount_decimal - flat_amount_decimal UsagePricing: type: object properties: billing_scheme: type: string unit_amount_decimal: type: - string - 'null' description: Exact provider decimal string in currency minor units; null when not a flat per-unit price. tiers_mode: type: - string - 'null' tiers: type: array items: $ref: '#/components/schemas/UsagePriceTier' divide_by: type: - integer - 'null' format: int64 round: type: - string - 'null' required: - billing_scheme - unit_amount_decimal - tiers_mode - tiers - divide_by - round CurrentUsageRow: type: object properties: subscription_id: type: string item_id: type: string scope: type: string description: Compatibility label; unknown when the product is not in the configured catalogue. product_id: type: string product_name: type: string price_id: type: string meter_id: type: string currency: type: string description: Native Stripe currency. All pricing amounts are decimal strings in this currency's minor unit, never major units. event_name: type: string display_name: type: string formula: type: string period_start: type: integer format: int64 description: Native subscription item period, inclusive start in Unix seconds. period_end: type: integer format: int64 description: Native subscription item period, exclusive end in Unix seconds. usage_window_start: type: integer format: int64 description: Inclusive start of the provider-supported minute-aligned measurement window. usage_window_end: type: integer format: int64 description: Exclusive end of the measured minute window. Can extend less than a minute beyond the native period. period_alignment: type: string enum: - exact - minute_envelope amount: type: number description: Eventually consistent measurement for usage_window_start/end, not an invoice amount or exact billed-period quantity when alignment is minute_envelope. included: type: - integer - 'null' format: int64 description: First finite tier with explicit zero per-unit pricing; null when unknown or absent. daily: type: array description: UTC daily windows enclosing the native period. Edge days can extend beyond it. items: $ref: '#/components/schemas/UsageDay' pricing: description: Exact native monetary facts. null when the provider pricing representation is unavailable or unsupported. anyOf: - $ref: '#/components/schemas/UsagePricing' - type: 'null' pause_collection: description: Collection pause remains visible and does not suppress the usage measurement. anyOf: - $ref: '#/components/schemas/SubscriptionPauseSummary' - type: 'null' required: - subscription_id - item_id - scope - product_id - product_name - price_id - meter_id - currency - event_name - display_name - formula - period_start - period_end - usage_window_start - usage_window_end - period_alignment - amount - included - daily - pricing - pause_collection RecordUsageMeter: type: object unevaluatedProperties: $ref: '#/components/schemas/UsageMeter' DestinationConfigField: type: object properties: name: type: string type: type: string enum: - string - integer - object required: type: boolean description: Needed for the destination to deliver. A draft saved inactive may leave it unset. secret: type: boolean description: 'Write-only: reads return it masked.' enum: type: - array - 'null' description: The values the field accepts, or null when it is free text. items: type: string required: - name - type - required - secret - enum AwsRoleSetup: type: object description: What you need to create the role Terra assumes to deliver to your S3 bucket or SQS queue. The role can only write to the bucket and queue you name. properties: external_id: type: string description: The External ID the role's trust policy must require. It is derived from your account and is the same for every environment. terra_principal_arn: type: string description: The Terra principal the role must trust. template_url: type: string description: The CloudFormation template that creates the role. quick_create_url: type: string description: A CloudFormation console link that creates the stack with these values filled in. Add param_BucketName and param_QueueArn to fill in the bucket and queue too. required: - external_id - terra_principal_arn - template_url - quick_create_url AwsSecretRefConfigView: type: object properties: role_arn: type: string description: The IAM role Terra assumes. secret_arn: type: string description: The Secrets Manager secret, SSM parameter or S3 object holding the secret. required: - role_arn - secret_arn GcpSecretRefConfigView: type: object properties: secret_name: type: string description: The Secret Manager secret holding the secret, as projects/{project}/secrets/{secret}, with /versions/{version} when pinned. required: - secret_name SecretRefConfigView: description: Where in the store the secret is, by store type. anyOf: - $ref: '#/components/schemas/AwsSecretRefConfigView' - $ref: '#/components/schemas/GcpSecretRefConfigView' AwsSecretRefConfig: type: object properties: role_arn: type: string description: The IAM role Terra assumes, whose trust policy requires the External ID Terra gives your account. minLength: 1 secret_arn: type: string description: The Secrets Manager secret, SSM parameter or S3 object holding the secret. minLength: 1 required: - role_arn - secret_arn additionalProperties: false GcpSecretRefConfig: type: object properties: secret_name: type: string description: The Secret Manager secret, as projects/{project}/secrets/{secret}. Add /versions/{version} to pin one; otherwise Terra reads the latest. The secret must carry the label your secret store type names, set to your External ID. minLength: 1 required: - secret_name additionalProperties: false SecretRefConfig: description: Where in the store the secret is, by store type. anyOf: - $ref: '#/components/schemas/AwsSecretRefConfig' - $ref: '#/components/schemas/GcpSecretRefConfig' WebhookDestinationConfig: type: object properties: url: type: - string - 'null' description: The http or https endpoint deliveries are posted to. Reading the destination returns it as set, so verify deliveries with the signing secret rather than a token in the URL. delivery: type: - string - 'null' enum: - push - ping - null description: push sends each payload; ping sends a notification to fetch it. Defaults to push. additionalProperties: false S3DestinationConfig: type: object properties: bucket: type: - string - 'null' region: type: - string - 'null' role_arn: type: - string - 'null' description: A role in your AWS account that Terra assumes instead of using an access key, created by the template in the destination type's aws_role_setup. Set it or access_key_id and secret_access_key, not both; send the other pair as null to switch. access_key_id: type: - string - 'null' secret_access_key: type: - string - 'null' description: Write-only. additionalProperties: false SqsDestinationConfig: type: object properties: queue: type: - string - 'null' description: The queue URL, its ARN or account_id/queue_name. region: type: - string - 'null' description: Optional when the queue URL or ARN names it; a region that disagrees with the queue's is a 400. role_arn: type: - string - 'null' description: A role in your AWS account that Terra assumes instead of using an access key, created by the template in the destination type's aws_role_setup. Set it or access_key_id and secret_access_key, not both; send the other pair as null to switch. access_key_id: type: - string - 'null' secret_access_key: type: - string - 'null' description: Write-only. s3_bucket: type: - string - 'null' description: A bucket to stage payloads in; the message then carries an S3 URL. additionalProperties: false GcsDestinationConfig: type: object properties: bucket: type: - string - 'null' service_account_key: type: - object - 'null' description: Write-only. The service account's JSON key file. additionalProperties: true additionalProperties: false FirestoreDestinationConfig: type: object properties: database: type: - string - 'null' description: Defaults to default. service_account_key: type: - object - 'null' description: Write-only. The service account's JSON key file. additionalProperties: true additionalProperties: false SupabaseDestinationConfig: type: object properties: project_url: type: - string - 'null' description: The project's URL, e.g. https://abcd.supabase.co. bucket: type: - string - 'null' api_key: type: - string - 'null' description: Write-only. A service-role key. additionalProperties: false MongodbDestinationConfig: type: object properties: scheme: type: - string - 'null' enum: - mongodb - mongodb+srv - null host: type: - string - 'null' database: type: - string - 'null' username: type: - string - 'null' password: type: - string - 'null' description: Write-only. additionalProperties: false KafkaDestinationConfig: type: object properties: host: type: - string - 'null' port: type: - integer - 'null' minimum: -2147483648 maximum: 2147483647 topic: type: - string - 'null' username: type: - string - 'null' password: type: - string - 'null' description: Write-only. additionalProperties: false SqlDestinationConfig: type: object properties: scheme: type: - string - 'null' enum: - postgres - postgresql - mysql - null host: type: - string - 'null' port: type: - integer - 'null' minimum: -2147483648 maximum: 2147483647 database: type: - string - 'null' username: type: - string - 'null' password: type: - string - 'null' description: Write-only. additionalProperties: false AzureblobDestinationConfig: type: object properties: account_url: type: - string - 'null' description: The storage account's URL, e.g. https://account.blob.core.windows.net. container: type: - string - 'null' sas_token: type: - string - 'null' description: Write-only. The SAS token the destination authenticates with, without its leading ?. additionalProperties: false WebhookDestinationConfigView: type: object properties: url: type: - string - 'null' description: The endpoint deliveries are posted to, as set. delivery: type: string enum: - push - ping required: - url - delivery S3DestinationConfigView: type: object properties: bucket: type: - string - 'null' region: type: - string - 'null' role_arn: type: - string - 'null' access_key_id: type: - string - 'null' secret_access_key_masked: type: - string - 'null' required: - bucket - region - role_arn - access_key_id - secret_access_key_masked SqsDestinationConfigView: type: object properties: queue: type: - string - 'null' description: The queue's AWS URL. region: type: - string - 'null' role_arn: type: - string - 'null' access_key_id: type: - string - 'null' secret_access_key_masked: type: - string - 'null' s3_bucket: type: - string - 'null' required: - queue - region - role_arn - access_key_id - secret_access_key_masked - s3_bucket GcsDestinationConfigView: type: object properties: bucket: type: - string - 'null' has_service_account_key: type: boolean service_account_email: type: - string - 'null' description: The key file's client_email. required: - bucket - has_service_account_key - service_account_email FirestoreDestinationConfigView: type: object properties: database: type: string has_service_account_key: type: boolean service_account_email: type: - string - 'null' description: The key file's client_email. required: - database - has_service_account_key - service_account_email SupabaseDestinationConfigView: type: object properties: project_url: type: - string - 'null' bucket: type: - string - 'null' api_key_masked: type: - string - 'null' provisioned_via: type: string enum: - oauth - api_key description: oauth when the destination was provisioned through the Supabase connection flow, api_key when it was configured with a key. organization_name: type: - string - 'null' project_name: type: - string - 'null' required: - project_url - bucket - api_key_masked - provisioned_via - organization_name - project_name MongodbDestinationConfigView: type: object properties: scheme: type: - string - 'null' host: type: - string - 'null' database: type: - string - 'null' username: type: - string - 'null' password_masked: type: - string - 'null' required: - scheme - host - database - username - password_masked KafkaDestinationConfigView: type: object properties: host: type: - string - 'null' port: type: - integer - 'null' minimum: -2147483648 maximum: 2147483647 topic: type: - string - 'null' username: type: - string - 'null' password_masked: type: - string - 'null' required: - host - port - topic - username - password_masked SqlDestinationConfigView: type: object properties: scheme: type: - string - 'null' host: type: - string - 'null' port: type: - integer - 'null' minimum: -2147483648 maximum: 2147483647 database: type: - string - 'null' username: type: - string - 'null' password_masked: type: - string - 'null' required: - scheme - host - port - database - username - password_masked AzureblobDestinationConfigView: type: object properties: account_url: type: - string - 'null' container: type: - string - 'null' sas_token_masked: type: - string - 'null' required: - account_url - container - sas_token_masked DestinationConfigView: description: A destination's configuration as read back, by type. Every field is present; unset ones are null. anyOf: - $ref: '#/components/schemas/WebhookDestinationConfigView' - $ref: '#/components/schemas/S3DestinationConfigView' - $ref: '#/components/schemas/SqsDestinationConfigView' - $ref: '#/components/schemas/GcsDestinationConfigView' - $ref: '#/components/schemas/FirestoreDestinationConfigView' - $ref: '#/components/schemas/SupabaseDestinationConfigView' - $ref: '#/components/schemas/MongodbDestinationConfigView' - $ref: '#/components/schemas/KafkaDestinationConfigView' - $ref: '#/components/schemas/SqlDestinationConfigView' - $ref: '#/components/schemas/AzureblobDestinationConfigView' DestinationSecretValues: type: object description: 'The secret configuration fields of the destination''s type, each null when unset. Only the type''s own fields are present: password (sql, mongodb, kafka), secret_access_key (s3, sqs), service_account_key (gcs, firestore), api_key (supabase), sas_token (azureblob), signing_secret (webhook).' properties: password: type: - string - 'null' secret_access_key: type: - string - 'null' service_account_key: type: - object - 'null' description: The service account's JSON key file. additionalProperties: true api_key: type: - string - 'null' sas_token: type: - string - 'null' signing_secret: type: - string - 'null' RecordInteger: type: object unevaluatedProperties: type: integer VantageRichTextText: type: object description: A run of characters sharing one set of styles. properties: type: type: string enum: - text value: type: string description: The characters. A newline is a soft line break. minLength: 1 bold: type: boolean italic: type: boolean strikethrough: type: boolean code: type: boolean description: Inline code. required: - type - value - bold - italic - strikethrough - code VantageRichTextImage: type: object properties: type: type: string enum: - image url: type: string format: uri description: An https URL. alt: type: string description: Text describing the image; empty for a decorative image. title: type: - string - 'null' required: - type - url - alt - title VantageRichTextLineBreak: type: object description: A hard line break. properties: type: type: string enum: - line_break required: - type VantageRichTextUnknownNode: type: object description: A node type added after this description was written. Skip it, or, if it has a children array, render its children instead. properties: type: type: string required: - type unevaluatedProperties: {} VantageRichTextLinkContent: description: 'An inline node inside a link: anything inline except another link.' anyOf: - $ref: '#/components/schemas/VantageRichTextText' - $ref: '#/components/schemas/VantageRichTextImage' - $ref: '#/components/schemas/VantageRichTextLineBreak' - $ref: '#/components/schemas/VantageRichTextUnknownNode' VantageRichTextLink: type: object properties: type: type: string enum: - link url: type: string format: uri description: An https, http or mailto URL. title: type: - string - 'null' children: type: array description: The linked content. items: $ref: '#/components/schemas/VantageRichTextLinkContent' required: - type - url - title - children VantageRichTextInline: description: 'An inline node: it sits in a paragraph, heading or table cell.' anyOf: - $ref: '#/components/schemas/VantageRichTextText' - $ref: '#/components/schemas/VantageRichTextLink' - $ref: '#/components/schemas/VantageRichTextImage' - $ref: '#/components/schemas/VantageRichTextLineBreak' - $ref: '#/components/schemas/VantageRichTextUnknownNode' VantageRichTextParagraph: type: object properties: type: type: string enum: - paragraph children: type: array description: Empty for an empty paragraph. items: $ref: '#/components/schemas/VantageRichTextInline' required: - type - children VantageRichTextHeading: type: object properties: type: type: string enum: - heading level: type: integer description: '1 is the most prominent, as in Markdown''s # to ######.' minimum: 1 maximum: 6 children: type: array items: $ref: '#/components/schemas/VantageRichTextInline' required: - type - level - children VantageRichTextBlock: description: 'A block-level node: it sits in the document, a blockquote or a list item.' anyOf: - $ref: '#/components/schemas/VantageRichTextParagraph' - $ref: '#/components/schemas/VantageRichTextHeading' - $ref: '#/components/schemas/VantageRichTextBlockquote' - $ref: '#/components/schemas/VantageRichTextList' - $ref: '#/components/schemas/VantageRichTextCodeBlock' - $ref: '#/components/schemas/VantageRichTextThematicBreak' - $ref: '#/components/schemas/VantageRichTextTable' - $ref: '#/components/schemas/VantageRichTextUnknownNode' VantageRichTextBlockquote: type: object properties: type: type: string enum: - blockquote children: type: array items: $ref: '#/components/schemas/VantageRichTextBlock' required: - type - children VantageRichTextListItem: type: object properties: type: type: string enum: - list_item checked: type: - boolean - 'null' description: Whether a task list item is done; null for an item that is not a task. children: type: array description: The item's blocks, including any nested list. items: $ref: '#/components/schemas/VantageRichTextBlock' required: - type - checked - children VantageRichTextList: type: object properties: type: type: string enum: - list list_type: type: string description: ordered or unordered. Treat any other value as unordered. start: type: - integer - 'null' description: The number of an ordered list's first item; null for an unordered list. minimum: 0 maximum: 2147483647 children: type: array items: $ref: '#/components/schemas/VantageRichTextListItem' minItems: 1 required: - type - list_type - start - children VantageRichTextCodeBlock: type: object properties: type: type: string enum: - code_block language: type: - string - 'null' description: The language the code is in, e.g. json; null when none is stated. value: type: string description: The code, verbatim. required: - type - language - value VantageRichTextThematicBreak: type: object description: A horizontal rule between sections. properties: type: type: string enum: - thematic_break required: - type VantageRichTextTableCell: type: object properties: type: type: string enum: - table_cell children: type: array items: $ref: '#/components/schemas/VantageRichTextInline' required: - type - children VantageRichTextTableRow: type: object properties: type: type: string enum: - table_row header: type: boolean description: True on the first row only. children: type: array items: $ref: '#/components/schemas/VantageRichTextTableCell' required: - type - header - children VantageRichTextTable: type: object properties: type: type: string enum: - table align: type: array description: 'One entry per column: left, center, right, or null for the default. Treat any other value as null.' items: type: - string - 'null' minItems: 1 children: type: array description: The rows. The first is the header row, and every row has one cell per column. items: $ref: '#/components/schemas/VantageRichTextTableRow' minItems: 1 required: - type - align - children VantageRichText: type: object description: 'A rich text document, exactly as the Vantage API serves product descriptions: a node for every Markdown construct (CommonMark without raw HTML, plus GitHub Flavored Markdown tables, strikethrough and task lists). Every field listed for a node type is always present; a field with no value is null. New node types, fields and values are added without notice: ignore a field you don''t know, skip a node type you don''t know (or show its children, if it has any), treat an unknown list_type as unordered and use the default alignment for an unknown align.' properties: type: type: string enum: - root children: type: array description: The document's blocks in reading order. Empty when there is no text. items: $ref: '#/components/schemas/VantageRichTextBlock' required: - type - children VantageEventAttempt: type: object description: One attempt to deliver a Vantage webhook event. properties: attempted_at: type: string format: date-time description: When the attempt was made. url: type: string description: The URL the attempt was sent to. status_code: type: - integer - 'null' description: The HTTP status your endpoint returned. null exactly when no_status_reason is set. minimum: -2147483648 maximum: 2147483647 no_status_reason: type: - string - 'null' enum: - invalid_url - host_not_found - connection_failed - null description: 'Why status_code is null: invalid_url (the URL can never be delivered to), host_not_found (no DNS record for the URL''s host) or connection_failed (no HTTP response, for example a refused connection, TLS failure or timeout). null exactly when status_code is set.' duration_ms: type: integer description: How long the attempt took, in milliseconds. minimum: -2147483648 maximum: 2147483647 required: - attempted_at - url - status_code - no_status_reason - duration_ms RecordUnknown: type: object unevaluatedProperties: {} VantageOrderRecipient: type: object description: Who an order is for, as the order list shows them. properties: first_name: type: string last_name: type: string email: type: string required: - first_name - last_name - email VantageOrderItem: type: object description: One line of an order. properties: order_item_id: type: string variant_id: type: string description: The product variant ordered, as the catalogue lists it. product_name: type: - string - 'null' description: The product's name. null when the catalogue no longer has it. quantity: type: integer minimum: -2147483648 maximum: 2147483647 required: - order_item_id - variant_id - product_name - quantity VantagePerson: type: object description: 'A recipient or test taker. Personal data: shown as Vantage holds it.' properties: first_name: type: string last_name: type: string email: type: - string - 'null' phone_number: type: - string - 'null' description: E.164. date_of_birth: type: - string - 'null' description: YYYY-MM-DD. gender_at_birth: type: - string - 'null' enum: - male - female - null required: - first_name - last_name - email - phone_number - date_of_birth - gender_at_birth VantageAddress: type: object properties: country_code: type: string description: ISO 3166-1 alpha-2. address_line_1: type: string address_line_2: type: - string - 'null' city: type: string administrative_area: type: - string - 'null' postal_code: type: string required: - country_code - address_line_1 - address_line_2 - city - administrative_area - postal_code VantageRequestedLab: type: object description: The lab asked for when the order was placed. properties: code: type: - string - 'null' postal_code: type: - string - 'null' address: anyOf: - $ref: '#/components/schemas/VantageAddress' - type: 'null' required: - code - postal_code - address RecordString: type: object unevaluatedProperties: type: string VantageConfirmedLab: type: object description: The lab the supplier confirmed for a walk-in visit. properties: code: type: string name: type: - string - 'null' address: anyOf: - $ref: '#/components/schemas/VantageAddress' - type: 'null' phone: type: - string - 'null' hours: description: Opening hours by day, as the supplier gives them. $ref: '#/components/schemas/RecordString' latitude: type: - number - 'null' longitude: type: - number - 'null' scheduling_open: type: boolean description: Whether the test taker can book an appointment. required: - code - name - address - phone - hours - latitude - longitude - scheduling_open $defs: RecordString: type: object unevaluatedProperties: type: string VantageCollectionVisit: type: object description: A sample-collection visit booked for an item, such as a home phlebotomy or clinic appointment. properties: type: type: string description: home_phlebotomy or clinic. status: type: string scheduling_url: type: - string - 'null' description: Where the test taker books the visit. null once it is booked or when the supplier gives none. required: - type - status - scheduling_url VantageOrderItemDetail: type: object properties: order_item_id: type: string variant_id: type: string description: The product variant ordered, as the catalogue lists it. product_name: type: - string - 'null' description: The product's name. null when the catalogue no longer has it. quantity: type: integer minimum: -2147483648 maximum: 2147483647 price_per_item_cents: type: integer minimum: -2147483648 maximum: 2147483647 shipping_status: type: - string - 'null' enum: - pending_shipment - in_transit - delivery_attempted - delivered - null description: The kit's shipping status. null until it has one. results_status: description: The item's results status. null before it has one. Whether its result is acknowledged is on the result. anyOf: - $ref: '#/components/schemas/VantageResultStatus' - type: 'null' lab_tracking_number: type: - string - 'null' description: The tracking number of the sample's return to the lab. test_taker_id: type: - string - 'null' description: null until the kit is activated. kit_id: type: - string - 'null' description: The supplier's id for the kit or item. collection_visit: anyOf: - $ref: '#/components/schemas/VantageCollectionVisit' - type: 'null' product_type_id: type: string description: The id of the product's type, as the catalogue lists it. GET /environments/{dev_id}/vantage/simulation keys its results transitions on it. required: - order_item_id - variant_id - product_name - quantity - price_per_item_cents - shipping_status - results_status - lab_tracking_number - test_taker_id - kit_id - collection_visit - product_type_id VantageOrderStatusChange: type: object properties: status: $ref: '#/components/schemas/VantageOrderStatus' changed_at: type: string format: date-time event_id: type: - string - 'null' description: The `order.status_changed` webhook event sent for this change; null when the change was recorded before event ids were kept. required: - status - changed_at - event_id RecordArrayString: type: object unevaluatedProperties: type: array items: type: string VantageResultStatusChange: type: object properties: status: description: The results status at that point. Acknowledgement is not a change; see acknowledged_at. $ref: '#/components/schemas/VantageResultStatus' changed_at: type: string format: date-time escalation_level: type: - string - 'null' enum: - very_high - high - medium - low - very_low - not_escalated - null description: How urgent the lab rates an escalation. null on any other change. acknowledgment_due_by: type: - string - 'null' format: date-time description: When an escalated result should be acknowledged by. failure_cause: type: - string - 'null' description: Why the lab could not process the sample, as the supplier gives it. required: - status - changed_at - escalation_level - acknowledgment_due_by - failure_cause