Skip to content

SAUMO API  ·  FOR DEVELOPERS

Read-only FHIR R4 access for partner applications.

The Saumo API gives your application read access to health data that Saumo has mapped to FHIR R4. One access policy decides what each call may see, and every read is logged with who, role, purpose and device. The API never writes back to source systems.

WHAT THE API IS

One read-only door to the data

Saumo reads your organisation’s sources, maps them to FHIR R4 with a person approving the mapping, and keeps the result in repositories. Applications read those repositories through the API, and only through the API.

01  ·  READ ONLY

Nothing is written back

The API has no calls that change health records. The source systems stay untouched.

02  ·  ACCESS POLICY

One policy for every call

A token reads only where its scopes, the application’s registration and the access granted to the person or system overlap. What the policy holds back is counted in withheld, never sent.

03  ·  PURPOSE

Every read says why

Each read sends an X-Saumo-Purpose header. A purpose that the account or application is not allowed is refused with 403.

04  ·  ACCESS LOG

Every read is logged

Who, account role and work role, purpose, repository, device, path, patient ids, counts and status, with a request id. Refusals too. Never the data, never a token.

TWO KINDS OF APPS

People signing in, or a system reading

An application either acts for a person who signs in and approves it, or reads as a system with its own credentials. Both read the same API under the same access policy.

APPS WITH SIGN-IN

SMART on FHIR app launch

  • Authorization code flow with PKCE, method S256 only. The person signs in on Saumo with a password and a second factor, then approves your application on a consent screen.
  • Scopes: openid, offline_access, user/*.read or user/<Type>.read. openid is accepted, but no ID token is issued: the person comes in the token answer as user.
  • The access token lasts 15 minutes. The session ends 10 hours after the person signed in, and no refresh extends it.
  • A refresh token comes only with offline_access. It rotates on every use, so refresh one at a time: a reused refresh token ends the session.
  • Who can connect your application depends on the account roles your organisation’s admin allows for it.

SYSTEM TO SYSTEM

Client credentials

  • POST /oauth/token with grant_type=client_credentials. The client authenticates with HTTP Basic (client_secret_basic).
  • Scopes: system/*.read or system/<Type>.read.
  • The access token lasts 15 minutes. There is no refresh token: ask for a new access token when it ends.
  • Reads only the repositories, the resource types and the one purpose it was registered with. Every read is logged.

For both

Your organisation’s Saumo admin registers the application and decides what it may read.

A client secret is shown once, when it is created. It can be rotated: the old secret keeps working for 24 hours, or stops at once if it may have leaked.

QUICK START

From discovery to the first read

Every call below works against the sandbox. Swap the placeholders for your own values.

Placeholders: <your-saumo> is the address of your organisation’s Saumo, <client_id> and <client_secret> come from the registration.

  1. Find the endpoints

    The SMART configuration is public. Keep issuer: you check it on the redirect.

    Request
    curl https://<your-saumo>/.well-known/smart-configuration
    Answer (excerpt)
    {"issuer": "https://<your-saumo>",
     "authorization_endpoint": "https://<your-saumo>/oauth/authorize",
     "token_endpoint": "https://<your-saumo>/oauth/token",
     "revocation_endpoint": "https://<your-saumo>/oauth/revoke",
     "code_challenge_methods_supported": ["S256"],
     "token_endpoint_auth_methods_supported": ["none", "client_secret_basic"],
     ...}
  2. Send the person to sign in

    Open the authorize address in a browser. redirect_uri must be one of your registered addresses exactly, and aud must be the API base, https://<your-saumo>/api/v1. code_challenge is the base64url SHA-256 of your code_verifier. Saumo redirects back with code, state and iss: check that state is the one you sent and iss equals the issuer, or exchange nothing.

    Authorize address
    https://<your-saumo>/oauth/authorize
      ?response_type=code
      &client_id=<client_id>
      &redirect_uri=<redirect_uri>
      &scope=openid%20offline_access%20user%2F*.read
      &state=<state>
      &code_challenge=<code_challenge>
      &code_challenge_method=S256
      &aud=https%3A%2F%2F<your-saumo>%2Fapi%2Fv1
    Redirect back
    <redirect_uri>?code=<code>&state=<state>&iss=https%3A%2F%2F<your-saumo>
  3. Exchange the code for tokens

    The code works once, within 60 seconds, for the same client, redirect address and verifier. Never retry a failed exchange: start a new sign-in. A confidential client sends its id and secret with HTTP Basic instead of client_id in the body.

    Request
    curl -X POST https://<your-saumo>/oauth/token \
      --data-urlencode grant_type=authorization_code \
      --data-urlencode code=<code> \
      --data-urlencode redirect_uri=<redirect_uri> \
      --data-urlencode client_id=<client_id> \
      --data-urlencode code_verifier=<code_verifier>
    Answer
    {"access_token": "<access_token>", "token_type": "Bearer", "expires_in": 900,
     "refresh_token": "<refresh_token>", "scope": "offline_access user/*.read",
     "session_ends_at": "2026-10-13T19:10:00Z",
     "user": {"id": 7, "name": "Example Reader", "role": "data_reader",
              "work_role": {"code": "tester", "label": "Tester"},
              "purposes": [{"code": "testing", "label": "Testing"}],
              "repositories": [{"short_name": "sandbox", "name": "Sandbox",
                                "resource_types": ["Patient", "MedicationStatement"]}]},
     "device": {"family_id": "<family_id>", "name": "<device_name>"}}
    Refresh (with offline_access)
    curl -X POST https://<your-saumo>/oauth/token \
      --data-urlencode grant_type=refresh_token \
      --data-urlencode refresh_token=<refresh_token> \
      --data-urlencode client_id=<client_id>
  4. Or get a system token

    A system-to-system application asks for its own token with its id and secret.

    Request
    curl -X POST https://<your-saumo>/oauth/token \
      -u '<client_id>:<client_secret>' \
      --data-urlencode grant_type=client_credentials \
      --data-urlencode 'scope=system/*.read'
    Answer
    {"access_token": "<access_token>", "token_type": "Bearer", "expires_in": 900,
     "scope": "system/*.read"}
  5. Read data

    Send the token in the Authorization header and the purpose in X-Saumo-Purpose. Every answer names the repository it read and lists in withheld what the access policy held back.

    Search patients
    curl 'https://<your-saumo>/api/v1/patients?q=<name>&limit=20' \
      -H 'Authorization: Bearer <access_token>' \
      -H 'X-Saumo-Purpose: <purpose_code>' \
      -H 'X-Saumo-Reason: <optional, at most 200 characters>'
    Answer
    {"patients": [{"id": "sbx-1", "name": "Example Person", "birth_date": "1941-03-02",
                   "gender": "female", "identifier_masked": "020341-****",
                   "source": "Organization/<source>"}],
     "repository": "sandbox", "withheld": []}
    One patient
    curl 'https://<your-saumo>/api/v1/patients/<id>' \
      -H 'Authorization: Bearer <access_token>' \
      -H 'X-Saumo-Purpose: <purpose_code>'
    Answer
    {"patient": {"resourceType": "Patient", "id": "<id>", ...},
     "repository": "sandbox", "withheld": []}
    A patient’s resources
    curl 'https://<your-saumo>/api/v1/patients/<id>/resources?types=Condition,MedicationStatement&since=2026-01-01' \
      -H 'Authorization: Bearer <access_token>' \
      -H 'X-Saumo-Purpose: <purpose_code>'
    Answer
    {"patient_id": "<id>", "repository": "sandbox",
     "resources": {"Condition": [...], "MedicationStatement": [...]},
     "withheld": [{"type": "Condition", "count": 2, "reason": "..."}]}

The read calls

GET /api/v1/patients
q a name, identifier an exact identifier, limit default 20 and at most 100, repository. Nobody found and a repository without access give the same empty list.
GET /api/v1/patients/{id}
One FHIR R4 Patient with identity codes masked. 404 when it is outside your access.
GET /api/v1/patients/{id}/resources
types comma separated, since a date yyyy-mm-dd, limit per type default 200 and at most 1,000, repository. Only types within your access are read.

Rules for every call

  • Exactly one Authorization: Bearer header. A token in the address, a form field or a cookie is never read.
  • X-Saumo-Purpose is a purpose code. For a person, one of user.purposes in the token answer (in the sandbox: testing). A system application sends the purpose it was registered with. A purpose query parameter is ignored.
  • X-Saumo-Reason is optional, at most 200 characters, and kept in the access log with identity codes masked.
  • With access to several repositories, add repository=<short_name>; with one, it is optional.
  • Every answer carries x-request-id. Labels and error messages follow Accept-Language (en, fi, sv).

ERRORS AND LIMITS

One error shape, stable codes

Every API error has the same envelope. code is stable, message is one plain sentence in the asked language, and request_id matches x-request-id and the access log.

Error envelope
{"error": {"code": "unauthorized",
           "message": "Sign in again.",
           "request_id": "<request_id>"}}

The token endpoint answers in the OAuth 2 shape instead: invalid_request, invalid_grant, unsupported_grant_type (400) and invalid_client (401).

Token endpoint error
{"error": "invalid_grant",
 "error_description": "The code or refresh token is not valid. Sign in again."}

Limits

  • Data calls are limited per person, and sign-in and token calls per client address. Over a limit, Saumo answers 429 with Retry-After.
  • Use a token until it expires instead of asking for a new one for each call.
  • Give the request_id when you ask for help. No error carries a stack trace or an internal name.
Main error codes
HTTP and code When
400 bad_request The purpose header is missing, repeated or malformed; several repositories and no repository=; a date not yyyy-mm-dd.
401 unauthorized The token is missing, expired or revoked. The message is “Sign in again.”
403 forbidden The account role cannot make this call.
403 purpose_not_allowed The purpose is not one the account or application may use. The access log keeps the refused purpose.
404 not_found Not found, or outside your access: the same answer for both.
422 unprocessable X-Saumo-Reason is over 200 characters.
429 rate_limited Too many calls. Wait for the seconds in Retry-After.
502 upstream The record store did not answer. Try again.
503 unavailable The access log row could not be written, so no data is sent.

DATA AND PRIVACY

Build on synthetic data

You never need real patient data to build against Saumo.

SANDBOX

A synthetic sandbox

An admin invites you as a developer. A developer account sees one synthetic repository (short name sandbox, ids start with sbx-), the sandbox applications you register and the test users you create. Only your own test users can connect your sandbox applications.

REQUEST LOG

See your own calls

The developer area shows the access log rows of your own sandbox applications for the last 7 days.

IDENTITY CODES

Masked in every answer

Identity codes are masked in every answer, for example 020341-****. A search by identifier matches the full code but never echoes it.

PEOPLE’S RIGHTS

The log answers people

People have the right to know who has accessed their data. Every call leaves one access log row, so the organisation can answer.

Read: patient rights under the EHDS →

STANDARDS

Open standards, read only

FHIR R4 native, aligned to the HL7 Europe Base and Core profiles STU 2.0, tracking the balloted European Patient Summary guide.

Sign-in follows SMART on FHIR and OAuth 2 with PKCE. Saumo supports read scopes only.

  • FHIR R4
  • HL7 EUROPE BASE STU 2.0
  • HL7 EUROPE CORE STU 2.0
  • SMART ON FHIR
  • OAUTH 2
  • PKCE S256

GET ACCESS

Ask your Saumo admin, or ask us.

Ask your organisation’s Saumo admin to register your application. If your organisation does not use Saumo yet, or you build a product for many organisations, contact us.

The full endpoint reference is inside Saumo at https://<your-saumo>/developer/docs/api, for signed-in developers.