Skip to main content
Bearer authentication is the standard way to call health-api. You obtain an access token for one ONVY project, then send it on protected API requests.

What you need from ONVY

  • A project_id
  • The API base URL: https://api.onvy.health
  • Either:
    • a confidential OAuth client with client_id and client_secret for server-to-server traffic
    • or a public client plus a supported upstream identity token for user authentication flows

Choose the right flow

Server-to-server authentication

Use this flow when your backend calls ONVY directly.
Response:
Use the returned access token on protected routes:

User authentication for mobile or web apps

Use this flow when your app already authenticates the user with your own identity provider. Exchange an upstream identity token:
Refresh an ONVY refresh token:
This endpoint maps the request to the appropriate OAuth grant for the target project and returns the same token envelope as the canonical token endpoint.

Canonical OAuth endpoint

Use POST /oauth/token when you want direct control over the OAuth grant parameters. Example server flow:

Token claims

ONVY access tokens include these core claims:
  • iss
  • aud
  • exp
  • iat
  • nbf
  • jti
  • project_id
  • sub
  • principal_type
  • scope
If principal_type=user, the token must also include user_id.

Scope format

Scopes follow this pattern:
Examples:
  • users:read
  • daily_records:create
  • chat_completions:create
  • admin.oauth_clients:revoke

How the project auth endpoints map to OAuth

  • /v1/projects/{project_id}/auth/server maps to the client_credentials grant for urn:onvy:project:{project_id}
  • /v1/projects/{project_id}/auth/sdk maps to token exchange or refresh, depending on the grant value in the JSON body
  • /oauth/token is the canonical OAuth endpoint when you want to send grant parameters directly