When SMART scopes in Medplum decide what a third-party app can read
SMART on FHIR scopes define the categories of data a third-party app may request, and access policies still decide what the signed-in user can actually reach. Medplum Auth implements SMART on FHIR within its OAuth and OpenID Connect components, so a self-hosted deployment needs both layers configured before an app goes live. Teams need SMART scopes when an external app acts on behalf of a person: a patient-facing app where a patient signs in, a provider app launched from inside an EHR, or any app that asks a user to approve access. A plain client credentials setup is enough for a backend service that runs without a person present, such as a nightly job that reads data under its own client identity. That service has no consent screen and no launch context, so its reach comes from its project membership and access policy. Review the Medplum authentication documentation to confirm which flow each app type should use.
The first decision is whose data the app works with. Patient-scoped requests (the patient/ prefix) are limited to the patient in launch context, while user-scoped requests (user/) follow the signed-in practitioner's permissions. Launch context, such as launch/patient when a clinician selects a patient in an EHR, determines which patient the app receives. offline_access determines whether the app can refresh its token after the person leaves the session. Treat each scope as an upper limit on what the app may request, with the access policy narrowing it further, so a user/Observation.read scope still returns nothing the practitioner's policy blocks. Before go-live, confirm in the documentation for your Medplum version which scopes and launch parameters are supported, then test each app with one patient account and one practitioner account that should see different records.
How a SMART launch passes scopes, context and policy checks
The flow starts when the third-party or patient app requests authorization and declares its SMART scopes. The user signs in through Medplum Auth or an external identity provider, and the token returned to the app carries the granted scopes and launch context such as the patient. Each FHIR request then crosses the trust boundary into the Medplum server, where the access policies on the user or client are checked again. Confirm which scopes your Medplum version supports before the app is designed.
A SMART launch in which scopes, launch context and access policies each gate a FHIR request.
Patient scopes versus user scopes: which fits which app
A patient-facing app is used by one person to see their own health information, such as a portal, a booking screen or a symptom tracker. In SMART on FHIR terms, the patient launches the app and the authorization server issues a token tied to one patient. The patient scope pattern limits what the app can read to resources in that patient's compartment, so the app should never be able to ask for another patient's data by changing an ID. The launch context carries the patient identifier forward so the app knows which record to load.
- Token limit: the token is bound to one patient, and reads should be confined to that patient's resources.
- Launch context: confirm how the patient identifier is returned to the app and whether your app depends on it.
- Patient registration: check how patients obtain accounts and whether those accounts are scoped to their own record in your version.
- Refresh behavior: confirm whether patient tokens can be refreshed and for how long.
- Combined rules: confirm how the scope interacts with the patient compartment access policy, since the policy still decides what the account can reach.
Check the scope names, the patient launch flow and the refresh settings against the Medplum authentication documentation for your release before you build the flow.
A provider-facing app is opened by a clinician, staff member or administrator who signs in with their own Medplum user. The token represents that user, so it can reach whatever the user's access policies allow, and the scope narrows that further for the app. This pattern fits charting tools, scheduling screens and care coordination apps. The scope tells the app what kind of access it requested, but it does not expand what the user is permitted to do, so a scope that asks for more than the user holds should produce less access, not more.
- Token limit: the token reflects the signed-in user, so the user's access policies are the ceiling.
- Context launch: confirm whether the app can be launched from an EHR-style context that supplies a patient or encounter, and how that context is passed.
- Resource-level scopes: confirm which resource types and read or write operations your version accepts in scope strings.
- Consent to the app: confirm how users approve the app and whether approvals can be revoked by an administrator.
- Session length: confirm how long the user session and the access token last, since this sets how often clinicians re-authenticate.
Confirm each of these in the Medplum authentication documentation for your version, and test with a low-privilege user before rollout.
A backend service is software that calls Medplum without a person signing in, such as an interface job, a scheduled export or an integration with another system. It does not use the patient or user launch flow. Instead, it authenticates as a client and receives a token that represents that client, not a human. Its reach depends on the access policy attached to the client, so the policy is the main control. Scope design for backend services matters less than defining a narrow policy and a dedicated client for each job.
- Token limit: the token represents a client application, and its access comes from the policy attached to that client.
- Client credentials: confirm that your version supports the client credentials flow for server-to-server access and how the client secret is issued.
- One client per job: avoid sharing a client between unrelated integrations so that audit logs and revocation remain meaningful.
- Scope strings: confirm whether the backend flow accepts SMART system scopes in your release, and which resource types they cover.
- Rotation: confirm how client secrets are rotated and whether rotation interrupts running jobs.
Verify the client setup and any system-level scope syntax against the Medplum authentication documentation, and then test that the client cannot read resources outside its intended scope.
Some products serve more than one audience, for example a clinic tool used by staff and also by patients, or a portal that calls a backend service on the patient's behalf. Mixing patterns in one product needs a clear map of which screen or function uses which token. Treating a patient token as a user token, or a backend client as a user, is the usual source of over-broad access. Separating the flows early keeps each token's limit easy to reason about and easy to test.
- Separate flows: give each audience its own launch path and token rather than reusing one token across audiences.
- Backend calls on behalf of a patient: confirm how the app passes the patient context to a backend job and whether the job should hold patient-level tokens at all.
- Shared components: check that shared front-end code does not cache tokens from one audience and reuse them for another.
- Logging: confirm that audit records show which audience and client made each request.
- Testing matrix: list each audience against each function and verify the denied cases as well as the allowed ones.
Review the mixed design against the Medplum authentication documentation for your version, and keep a written map of token type to function for your security review.
Configuration options and when each fits
This table compares the main SMART scope and token choices for Medplum apps, from patient-context and user-context scopes to offline access, launch type and client credentials. Read each row against the app's sign-in model and who is actually using the data, and confirm exact scope names and token behavior in the Medplum authentication docs for your version.
| Option | What it grants | When it fits | Main risk |
|---|---|---|---|
| Patient-context scopes | Access limited to resources in the patient's compartment, for the patient the app was launched with | Patient-facing portals and apps where a patient signs in and should see only their own records | Access policies or compartment rules that are broader than the patient context, exposing other patients' data |
| User-context scopes | Access that follows the signed-in practitioner or user, bounded by that user's Medplum access policies | Provider-facing apps where clinicians work across patients under their own permissions | Scopes that look narrow but still inherit a broad user access policy, so the app reads more than intended |
| Offline access (refresh tokens) | A refresh token that lets the app obtain new access tokens after the user's session is no longer active | Background sync or long-running workflows that must keep reading data without the user present | A stolen refresh token grants access until it is revoked, so revocation and storage practices matter |
| EHR launch | An app started from inside an EHR or Medplum session, with launch context such as the current patient or encounter passed to the app | Apps embedded in a clinician's workflow where the chart already identifies the patient | Launch context trusted without checking that it matches what the user is allowed to see |
| Standalone launch | An app that starts on its own and asks the user to choose or confirm the patient or context during sign-in | Patient portals, consumer apps and tools used outside an EHR workflow | The user selects a context they should not access, so the server-side policy must still decide what is returned |
| Client credentials | Server-to-server access with no user present, governed by the client's own access policy | Backend jobs, integrations and Bots that read or write data on a schedule | A client with broad access policy and long-lived secrets can read the whole project without any user check |
| Combined scopes with access policies | The intersection of the requested SMART scopes and the access policy attached to the user or client | Most production apps, where scopes limit what the app asks for and policies limit what the server returns | Assuming a requested scope is enough on its own, when the access policy is what actually enforces the boundary |
Why scopes alone do not enforce least privilege
A SMART scope only states what an app asks for. What the app actually receives is decided by the access policy on the user or client profile, so the two have to be designed and tested together. The cards below cover the parts of that combination that most often go wrong.
Scope requests are not grants
A scope such as patient/Observation.rs asks for read and search access to Observation resources, but it does not guarantee them. Medplum returns only what the signed-in user's access policy allows, so an app that requests a broad scope can still receive a narrow result. Check the requested scopes against the policy on the profile the app will use, and record which scopes you expect to be effective for each app.
Policy decides what comes back
The access policy attached to the user or client profile is the enforcement point. If the policy allows every resource type, a narrow scope does not stop reads outside the intended set. Review each policy for resource-type rules and property-level rules, and confirm that the granted resources match what the app's scopes describe.
Criteria-based rules versus compartments
Criteria-based policies match resources by their fields, such as a Patient reference or a tenant tag. Compartment-based policies follow the Patient link from a resource. Patient-facing apps usually depend on compartment rules, while provider apps often need criteria-based rules that limit them to a care team or clinic. Decide which model fits each app, then test it with real data shapes.
Scope and policy mismatches
The most common over-exposure happens when a scope is broader than the policy intends, or when a policy was written for an earlier app and nobody updated the scopes. An app may ask for system-level access while its profile is a patient-level user, or the reverse. Compare each app's requested scopes with the policy line by line before approving it, and repeat the check when either side changes.
Test with a read-only test user
Before go-live, create a test user whose access policy is read-only and assign it the same launch context the app will use. Run the app's common flows and try the requests it should not be able to make, such as reading another patient or writing a resource. A read-only test user shows the real effective access, and it gives you a repeatable check after each policy or app change.
How to set up SMART scopes in a self-hosted Medplum project
This sequence takes a self-hosted Medplum project from a registered client application to a verified SMART launch, with scopes, identity, access policies, offline behavior and audit evidence each checked before the next step begins.
Register the client application
Create the ClientApplication resource in the Medplum project that will own the integration, and record its ID, a clear name and the owner who will approve changes. Keep the app in a non-production project first so that test users and test data stay separate. Done means the client appears in the project's client list with a stable ID that your app configuration can reference, and a named owner is recorded against it.
Define requested scopes and redirect URIs
Decide which SMART scopes the app needs, separating patient-context scopes from user-context scopes and limiting resource types to those the workflow uses. Register each exact redirect URI the app will return to, since mismatched URIs fail at the authorization step. Done means the scope list and redirect URIs are written down, reviewed by the data owner, and match the values stored on the client application.
Configure the identity provider and user roles
Confirm how the users who launch the app will sign in, whether through Medplum as the identity provider or an external provider configured for the project, and assign those users the roles they need. Check that multi-factor authentication settings match your policy for clinical or patient data. Done means a test user from each population (a practitioner and a patient account) can complete sign-in and reaches the consent screen.
Create access policies for the client and linked users
Write access policies that limit what the client application and each linked user can read or write, since SMART scopes request access but the project's access policies enforce it. Attach the policies to the ClientApplication and to the relevant user or profile. Done means a test request for a resource outside the policy returns an access denial, and a request inside it succeeds.
Run standalone and EHR-style launch tests
Run a standalone launch in which the app starts sign-in itself and a patient is selected during authorization, then run an EHR-style launch in which an existing session supplies the patient or encounter context. Compare the launch context and token contents from each path. Done means both flows return a token whose patient context and scopes match what the test plan expects, and any mismatch is logged as a defect before go-live.
Confirm offline access behaves as intended
Request a token with and without the offline access scope, then check whether a refresh token is issued and how long it remains valid under the project's token settings. Revoke a test user's access and confirm the refresh token stops working. Done means the offline behavior matches the written decision for the app, and a revoked session cannot refresh.
Verify returned data in audit logs
Review the audit events created by the test launches and data requests, confirming the requesting client, the user, the resources returned and the time of each access. Compare these against the scope and policy test results from the earlier steps. Done means each test request has a matching audit record, and the team has documented which entries the security or compliance owner will review going forward.
Questions teams ask before building SMART scopes in Medplum
What drives the effort of a SMART scope rollout in Medplum?
The effort is driven less by the scope syntax than by the decisions behind it. Each third-party or patient-facing app needs a defined set of resource types, a launch context that says which patient or encounter it may see, and a matching access policy so the server enforces what the app requests. Effort rises with the number of apps, the number of distinct user types, and how many clinical owners must approve each scope. Ask any partner for a written scope inventory that lists each app, its scopes, its launch flow and its test cases before agreeing a quote, because that inventory is what sets the work.
Can our team configure SMART scopes in Medplum without outside help?
A team with strong FHIR and OAuth experience can configure SMART scopes in-house, especially for a single app with a small set of resource types. The harder parts are usually clinical scope decisions, testing patient-facing flows end to end, and aligning scopes with existing access policies so nothing is exposed by accident. Medplum's authentication documentation at the link below covers the platform's OAuth and SMART-on-FHIR behavior, so your engineers can start there. A fixed-scope engagement makes sense when several apps or identity providers must be rolled out together under a deadline your team cannot absorb.
What does the work need from our side before it starts?
Three inputs matter most. First, an identity provider decision: Medplum can act as the identity provider itself, or work with external providers, and the choice affects sign-in and user provisioning. Second, named clinical owners who approve which data each app may read or write, since scope decisions are clinical and privacy decisions as well as technical ones. Third, test patients and test users in a non-production project that mirror the records and relationships the apps will touch. Without these, testing stalls and scope reviews repeat. Confirm the owners and test data in writing before the timeline is agreed.
How do patient scopes differ from user scopes in practice?
Patient scopes limit an app to records related to a single patient, typically for an app a patient uses to see their own data, while user scopes tie access to the signed-in practitioner or staff member and their permissions. In practice, a patient-facing app needs a launch context that identifies the patient and an access policy that restricts reads to that patient's compartment, so a valid token cannot reach other patients. A provider app acts for a clinician who already has access rights, so the policy must still limit that clinician to their permitted data. Test both paths with a patient who tries to request another patient's record.
Is offline access needed for SMART apps, and what are the risks?
Offline access is needed only when an app must read data while the user is not signed in, such as a background sync or scheduled report. It issues longer-lived access that continues after the session ends, so it widens the window in which a stolen token can be used. Decide whether each app truly needs it, limit the scopes it receives, and confirm the token lifetimes your deployment uses. Medplum's documentation on authentication and token behavior is the starting point for checking how refresh and offline tokens behave in your version, and your security team should review the result before go-live.
What changes between Medplum Cloud and a self-hosted deployment for SMART scopes?
The SMART scope model itself stays the same, but ownership of the surrounding controls changes. On Medplum Cloud, the vendor operates the server, and Medplum's compliance documentation describes compliance as a shared responsibility between Medplum and its customers. On a self-hosted deployment, your team or a partner also owns the identity provider connection, upgrades, token and session configuration, logging, and the evidence that scopes are reviewed. Paid cloud plans include standard BAA and MSA agreements, and multiple external identity providers for SSO are listed as an enterprise feature. For current plan prices and inclusions, check the Medplum pricing page, and request a written quote that names the identity provider features you need.
How do the scopes and access policies work together?
Scopes define what an app asks for, and access policies define what the server actually permits. A scope that is granted but not backed by a policy is a gap, and a broad policy can allow more than the scopes intended. Treat the two as one design: write each app's scopes from the clinical decision, write the matching policy, then test with requests that should fail. Ask any partner to show a test matrix covering allowed reads, denied reads for other patients, and denied writes, and to re-run it after each Medplum upgrade.
Security and operational risks of SMART app access
Every SMART app that reads or writes Medplum data extends the access surface beyond your own users. The cards below cover the risks that recur across patient and provider apps: scope breadth, token lifetime, identity proofing, credential rotation, audit visibility and the split of duties with Medplum.
Over-broad scopes for third-party apps
A SMART scope list is a request, and the app receives whatever the authorization server grants. Review each requested scope against the app's stated purpose, and prefer patient-level or narrower resource scopes over broad read access to every resource type. Check that a scope grant does not bypass the access policies already attached to the project, because the effective access is the intersection of the two. Confirm which scopes your Medplum version supports and how they appear in the consent screen a patient or clinician sees.
Medplum auth docsRefresh tokens under offline access
Requesting offline access lets an app keep reading data after the user has left the session, so a refresh token becomes a long-lived credential. Decide whether the app needs offline access at all, and if it does, confirm how long refresh tokens live and how they are revoked when a patient or clinician leaves the organization. Store refresh tokens in a server-side secret store, never in a browser or mobile app's local storage, and test revocation before go-live.
Patient identity at registration
A patient-facing app is only as safe as the identity behind the patient account. If open registration lets anyone create a login, a SMART patient scope may release one person's record to another. Decide how the app matches a registrant to an existing Patient record, which identifiers or verification steps it uses, and how it handles mismatches. Multi-factor authentication for patient logins is a useful layer, but it does not prove the person is the patient in the record.
Client secret and key rotation
Confidential SMART clients and server-to-server integrations authenticate with secrets or keys that must be rotated without an outage. Keep a written inventory of every client, its secret or key owner and the systems that hold it. Rotate on a schedule and after staff changes, and test that old credentials stop working once replaced. Ask your team how a compromised client is disabled quickly without breaking other apps that share the same project.
Auditing which apps read which resources
Access control only protects what you can later explain. For each SMART app, you need a record of which client made each read, write and search, on whose behalf, and against which Patient. Confirm that Medplum's audit trail identifies the client application and the user or patient context for each request, and that the logs are retained and exported to your monitoring system. Run a periodic review that compares actual access with the scopes each app was approved for.
Shared responsibility with Medplum
Medplum's compliance documentation states that compliance is a shared responsibility between Medplum and its customers. For SMART apps, Medplum provides the authorization server, token issuance and platform controls, while your organization decides which apps to approve, what scopes to grant, how patients are verified and how credentials are handled. Ask Medplum and your compliance team to document which controls sit on each side, especially on a self-hosted deployment where your team runs the infrastructure.
Medplum compliance docsDeciding between user, patient and backend access
The decision starts with one question: is the app acting for a signed-in person or for the system itself? If a person, the next question is whether that person is a patient or a clinician, since patient apps are limited to the patient's own compartment while provider apps work across the records their user can reach. The third question is whether the app must work while the user is offline, which determines whether an offline access scope is requested. Each path ends at a scope pattern and an access policy to check before go-live, because the scope only narrows what a token can request and the Medplum access policy still decides what the user can read.
Decision path from the type of caller to the scope pattern and access policy check.
How DeployOpen scopes and delivers SMART scope access
DeployOpen plans SMART scope work under a fixed-scope written agreement, so the scope, deliverables and timeline are fixed before any app is configured. The first phase reviews each third-party and patient-facing app: which resource types it reads and writes, whether it runs as a patient, a practitioner or a backend client, whether it needs a launch context, and whether it needs refresh tokens for offline access. The output is a written inventory that maps each app to the scopes it requests and to the access policies that should govern the data it can reach. Ask for this inventory as a named deliverable in any quote, because it is the document your security and clinical reviewers will check the rest of the work against.
Next, DeployOpen designs each scope and access policy pair as one unit. A patient/*.read scope granted to a portal app only means something if the Medplum access policy behind the user limits the same patient to their own compartment, and a user/ scope granted to a clinician app only means something if that user's policy matches the role the app serves. DeployOpen implements these pairs, then tests each app's launch end to end, including the EHR launch and standalone launch paths, the scope the app receives in its token, and the resources it can and cannot retrieve. Those tests are repeatable, so they can be rerun after every Medplum upgrade or scope change. Confirm with your own team which launch types and identity providers you need before the design phase starts, because those choices determine how much testing each app requires.
After go-live, DeployOpen runs security testing against the resulting setup, covering authorization bypass attempts, token misuse, scope escalation and cross-patient data exposure, and delivers findings with fixes and a retest. DeployOpen also prepares the evidence your compliance reviewers ask for, such as scope inventories, policy definitions and test results, but it does not issue audit reports, attestations or certifications, and independent auditors and certification bodies make those determinations. Where your app portfolio keeps changing, ongoing support, upgrades and continuous testing are available as retainers, which cover re-reviewing scopes when apps change and retesting after Medplum releases.

