Building a tenant selector for multi-tenant Medplum apps

A tenant selector lets one user account work across several Medplum tenants, but it changes how isolation is enforced. This page compares strict isolation, a selector and a unified view so you can choose before you build.

On this page

When a tenant selector fits a multi-tenant Medplum app

A tenant selector is a pattern where one user signs in once and switches between the clinics, care teams or customer organizations they are allowed to work with, without a separate login for each. In Medplum, it fits when a product team or management services organization (MSO) serves several tenants and needs one account or one workspace for staff who work across them. It is the right model when users legitimately move between tenants during a session and the data behind each tenant still needs to stay separated by the server, not only by the interface.

Two terms carry the design. Allowed tenants are the tenants a user is permitted to access, which the server enforces through access policies and the tenant data labels defined for the deployment. The active tenant is the one the user is currently working in, which the application chooses and displays. The Medplum tenant selector guide compares three models: strict isolation, where each token carries one tenant and API-level isolation is strongest but complexity is highest; a single account with a selector, where allowed tenants are enforced and the UI scopes the active tenant; and a unified view, which gives no isolation beyond the project. Only the middle model depends on the server checking allowed tenants on every request, so the first thing to confirm is whether your access policies enforce the allowed list or only the interface does.

Before choosing, decide how often a user must switch tenants inside one session and whether a switch should require re-authentication. A selector that changes the active tenant without a new token keeps the workflow fast, but a switch that must meet a stricter assurance level will need a fresh sign-in, which adds friction for staff who cover many sites. Ask your team to map which roles cross tenants, which data must never be shown alongside another tenant's data, and how your access policies will be tested before go-live. An illustrative MSO with three clinics and a shared billing team would likely need the selector for billing staff only, with clinicians kept to a single tenant.

Where each tenancy model enforces the boundary in the request flow

The diagram starts at user sign-in and follows the token to the Medplum API in each of the three models. In strict isolation, the token carries one tenant, so the access policy on that project limits every request. In the single account with selector, the token carries the allowed tenants and the UI picks the active one, so the access policy must check the active tenant on each request. In the unified view, the only boundary is the project itself. Check which box holds the policy that stops a cross-tenant read.

Request paths for the three tenancy models, with the enforcement point in each.

Which tenancy model to choose and why

This table compares strict isolation, a single account with a tenant selector, and a unified view across isolation strength, enforcement, re-authentication, build complexity and typical fit. Read each row as a trade-off: the more isolation a model gives, the more build work it usually takes. The main takeaway is that a unified view gives no isolation beyond the project, so it fits only where all users may see the same data.

FactorStrict isolationSingle account with selectorUnified view
Tenant access per tokenOne tenant per tokenSeveral allowed tenants, one active at a timeAll project data visible to the user
Isolation strengthStrongest API-level isolationEnforced by allowed tenants in access policiesNo isolation beyond the project
Who enforces the boundaryThe token and API layerThe access policies and the active tenant the UI sendsNothing beyond the project boundary
Re-authentication when switching tenantsUsually required, since each token maps to one tenantConfirm with Medplum whether switching the active tenant needs a new sign-in in your setupNot applicable
Build complexityHighestModerate, mainly in the selector and policy designLowest
Typical fitClinics or customers that must never share a sessionCare teams or clinics that share staff and need quick switchingInternal tools where all staff may see all data
Main riskToken and session handling errors across tenantsA UI that shows the wrong tenant or policies that allow too muchData from one tenant exposed to users of another

Allowed tenants versus active tenant: where enforcement happens

The server must decide which tenants a user is allowed to use, and the interface only decides which of those allowed tenants the user is working in right now. These are two different controls. The allowed list is an authorization decision, so it has to be enforced where data is read and written. The active tenant is a navigation decision, so the UI can scope screens, searches and forms to it. A tenant selector that treats the active tenant as the security boundary has put the enforcement point in the wrong place.

The risk of letting the UI alone decide scope is simple to describe. Any client that holds a valid session can send a request with a different tenant reference, a different Patient or Encounter search, or a direct resource URL, and a client-side filter will not stop it. The allowed list therefore belongs in the access policy attached to the user or membership, and in the token claims or session data that the server checks on every request. Client state such as local storage, a React context or a query parameter can be edited by the user, so it should carry only the selected tenant, and the server should validate that selection against the allowed list each time. Confirm in the Medplum tenant selector guide how the selector pattern expects the allowed and active tenants to be represented, and test a request for a tenant outside the allowed list with a token from a real test user before go-live.

How to build the selector in sequence

The sequence turns a tenant model into a working selector in which the server, not the interface, decides which tenant data a user can reach. Each step ends with a check so the team knows it can move on.

  1. Define the tenant resource model

    Decide how a tenant is represented in Medplum before any user or screen depends on it. Most teams use a dedicated tenant resource (or an equivalent organization record) and tag clinical data with the tenant it belongs to, so that access policies can match on that tag. A platform engineer or solution architect typically owns this step with input from the clinical operations lead. It is done when every resource type in scope has a documented tenant reference or tag, and the team can name the field a policy will check. Confirm the exact resource and field pattern against the current Medplum tenant selector guide before you build on it.

  2. Map each user to allowed tenants

    Record which tenants each user may access, along with any role that applies inside each tenant. Keep this mapping in one place the server controls, such as membership records or access policy assignments, and not in client-side settings. The identity or security lead should review the list with the operations owner, since a wrong mapping here is the most common cause of cross-tenant exposure. It is done when a sample of users shows the expected allowed tenants and a user with no membership sees none.

  3. Issue tokens that carry the allowed list

    Decide how the allowed tenant list reaches the application, either inside the token claims or in server-side session state keyed to the user. Whichever you choose, the server must recheck the list on every request rather than trusting a value the browser sends back. The identity engineer sets this up with the sign-in configuration in Medplum authentication. It is done when a token or session for a test user contains exactly the allowed tenants, and a token for one user cannot be used to request another user's list.

  4. Build the selector interface

    Build the control that lets a user choose the active tenant from the allowed list. The selector should only offer allowed tenants, and changing the active tenant should update the context used for queries and writes in the interface. The front-end developer owns this work, and the UX lead should confirm that users always see which tenant they are working in. It is done when the selector shows only allowed tenants, the active tenant label is visible on every screen, and switching tenants refreshes the data the screen displays.

  5. Enforce access policies on the server

    Write access policies so the server rejects requests for resources outside the user's allowed tenants, regardless of what the client asks for. Check each resource type in scope, including search, read, update and any Bot or client application that touches the same data. The security engineer and platform team own this step, and it is best tested against the policies documented in the access policy design guidance before go-live. It is done when policy evaluation returns the expected results for every resource type and role in the matrix.

  6. Test cross-tenant reads from the client

    Test that a user cannot read another tenant's data by changing the active tenant or editing requests in the browser. Use a test user with access to one tenant and attempt reads and searches against records in another tenant, both through the interface and with direct API calls that set a different tenant value. The QA or security tester runs these cases and keeps the results as evidence. It is done when every attempt returns no data or an authorization error, and the results are recorded for each resource type in scope.

Re-authentication trade-offs when users switch tenants

Switching tenants can mean a new token, a scope change on the existing session, or a fresh sign-in with prompts from the identity provider. Each choice changes how often users re-authenticate and how much friction your tenant selector adds. The cards below cover the decisions to make and the behaviors to confirm in your Medplum version before you commit to a design.

Token change or scope change

Decide whether selecting another tenant issues a new access token or only narrows the active tenant inside the existing session. A new token keeps each request bound to one tenant and is easier to audit, but it adds a token exchange on every switch. A scope or context change is faster for users, yet your API layer must then enforce the active tenant on every call. Confirm how your Medplum version handles token issuance for a switch before you write the UI flow.

Tenant selector guide

Session lifetime across tenants

Clarify whether a session started for one tenant remains valid when a user moves to another, and how long it lasts. Long-lived sessions reduce prompts but widen the window in which a stolen token can reach several tenants. Shorter sessions force more sign-ins for multi-clinic staff. Ask your team to document the token lifetimes configured for your project and to test expiry during a switch, not only at initial sign-in.

MFA prompts on each switch

Find out whether a tenant switch triggers a new multi-factor challenge. If Medplum treats the switch as a new authentication event, users who manage several clinics may face repeated prompts during one shift. If it does not, your security policy must state what a switch proves about the user. Agree on this rule with your compliance and clinical leads, and test it with the MFA methods your staff actually use.

Medplum authentication docs

Medplum as identity provider

When users sign in directly with Medplum, the switch flow stays inside Medplum's own authentication. You control the user records, password policy and MFA settings in one place, which keeps the switch behavior easier to reason about. The trade-off is that you own more of the account lifecycle, including resets and offboarding across every tenant a user belongs to. Confirm which sign-in events Medplum records for each tenant before relying on them in an audit.

External identity provider sign-in

With an external identity provider such as Google, Auth0 or AWS Cognito, a tenant switch may send users back through the provider's sign-in page. Some providers reuse an active browser session and some prompt again, which changes perceived speed and MFA frequency. Test each provider with your tenant selector, because the answer depends on the provider's session settings as well as Medplum's configuration.

Domain-level corporate identity providers

Domain-level corporate identity providers can route staff from one organization domain to a single sign-on flow. For a multi-tenant app, confirm whether that flow lets a user pick another tenant without re-entering corporate credentials, and whether tenant membership is still checked at each switch. Multiple external identity providers for SSO are listed by Medplum as an enterprise feature, so confirm your plan covers the providers you need before you design around them.

Medplum pricing

What drives implementation complexity and effort

The largest effort driver is how many tenants and roles the app must separate. Each additional tenant adds membership records, a selector entry and a set of access checks that must be tested, and each additional role multiplies the combinations a tester has to cover. Strict isolation multiplies this work fastest, because each tenant gets its own token path and its own permission set. Before scoping, list every tenant type, every role that can switch between tenants, and every screen where the active tenant must be visible. Ask any partner to price the work against those counts rather than against a general estimate.

Whether tenants share resources also changes the work. If clinics share a formulary, code systems or a directory, the team must decide how that shared data is exposed without leaking tenant-specific records, which usually means shared projects or carefully scoped access policies. The identity provider is a separate driver: if users sign in through an external provider that maps groups to tenants, the group mapping, claim handling and sign-out behavior all need testing. Confirm with your identity team which provider you will use and whether tenant membership will live in Medplum or upstream. Your own environment, not a general rule, sets this cost.

Test coverage of access policies is often the most underestimated item. Tests should prove that a user with a tenant selected cannot read, search or write another tenant's resources through the API, GraphQL or Bots, and that switching tenants does not leave stale data on screen. Ask whether your team already writes and runs Medplum access policy tests. Teams with that practice can absorb the selector work into an existing test suite, while teams without it will need that tooling built first. DeployOpen does not publish a price list. Effort follows from the written scope, so the scope should list tenant and role counts, shared resources, the identity setup and the test plan before a quote is requested.

Limits to confirm in your environment

A tenant selector depends on how your Medplum version issues and checks tenant claims, what your plan allows for identity, and how your data is separated. Confirm each item below with Medplum or in your own test environment before you commit to a design.

Tenant claim handling by version

Confirm how your Medplum version carries tenant or project information in tokens and how the access policy checks it. Medplum ships minor versions two to three times a year and patch versions weekly, so behavior can change between releases. Ask Medplum to confirm the behavior of your target version, then prove it with a token issued for one tenant and a request that tries to read another. Do not assume a claim is enforced because the UI hides it.

Tenant selector guide

Identity provider features by plan

Multiple external identity providers for SSO, such as Okta, Azure and Auth0, are listed as an enterprise feature on Medplum's pricing page. If your design needs one user to sign in through several corporate identity providers mapped to different tenants, confirm that your plan includes it. Also confirm how domain-level identity providers map users to projects. Get this in writing before the architecture is fixed.

Medplum pricing

Project versus tenant separation

Decide whether tenants are separated by Medplum projects, by a tenant resource inside one project, or both. Separate projects give stronger isolation but add per-project users, settings and secrets to manage. A shared project relies on access policies and data labeling to keep tenants apart. Test that a tenant's Bots, subscriptions and search results cannot reach another tenant's records.

Shared project and compliance review

A single project holding several tenants may draw more questions in a compliance review than separate projects. Medplum's compliance documentation states that compliance is a shared responsibility between Medplum and its customers. Ask your compliance team which isolation evidence they need, such as access policy tests, audit logs and documented tenant assignment, and confirm that the design produces it.

Medplum compliance docs

Re-authentication and session behavior

Switching tenants may or may not require a new token, depending on the design. Confirm whether a switch forces a fresh sign-in, how long tokens remain valid, and whether a revoked tenant assignment takes effect immediately or at token expiry. Measure these in your own test environment, since the answer determines how the selector behaves for users with access to many tenants.

Medplum authentication docs

Upgrade impact on tenant logic

Tenant logic built on access policies and custom selectors must survive upgrades. Medplum requires self-hosted deployments to move through each minor version in sequence, so plan a regression test of tenant isolation at every step. Confirm with Medplum which parts of your tenant configuration are affected by a given release.

Upgrading the server guide

Questions buyers ask before building a tenant selector

What does it cost to build a tenant selector for Medplum?

The cost depends on how much of the tenant model already exists and how much new work the selector adds on top of it. The main components are discovery, design of the tenant model and access policies, changes to the front end so the active tenant is always visible and switchable, changes to token handling so each request is checked against the user's allowed tenants, and testing that proves one tenant cannot read another's records. Most of the one-time cost sits in design and testing, not in the UI control itself. Recurring cost comes from maintaining policies as tenants are added and from re-running access tests after each Medplum upgrade. Ask any partner to split the quote into these components, state who does each piece, and say which items are one-time and which recur.

How long does a tenant selector take to build?

Duration depends on scope, and the biggest variables are the number of tenants, the number of user roles that cross tenants, and whether identity is already set up for multiple organizations. A selector that only switches between two tenants for a small set of staff is far smaller than one serving many clinics with different clinicians, admins and external partners. Work usually runs in sequence: agree the isolation model, build and test access policies, then add the selector and token behavior, then verify with real test users. Ask for a timeline tied to a written scope, and check whether it includes the audit and retest work needed before go-live. No duration is given here because the scope has not been set.

What does the client team need to provide for a tenant selector project?

The work needs three kinds of input from the client. Identity owners must confirm how users sign in, whether tenant membership comes from an external identity provider or from Medplum itself, and how multi-factor authentication applies to each tenant. Product owners must define which tenants exist, which users belong to each, which actions the selector should expose and what the default tenant should be after sign-in. Compliance and security leads must state which isolation level their review expects and which evidence they need, such as access test results and change records. Without these decisions made early, the build tends to stall while teams argue about the model rather than writing it.

Can an in-house team build a tenant selector on Medplum?

An in-house team can build one if it has engineers who know Medplum's access policies, FHIR resource labeling and OAuth flows, and if someone owns the testing. The hard parts are rarely the selector interface. They are making sure every API path respects the active tenant, handling tokens and sessions correctly when users switch, and proving isolation with tests that a reviewer will accept. Teams should check whether they have that depth, whether they can staff the work and keep it current through Medplum upgrades, and whether an independent test of the result is part of their plan. DeployOpen can plan, implement and test this work in infrastructure the client controls, under a fixed scope agreed in writing.

When is strict isolation a better choice than a tenant selector?

Strict isolation is usually the better choice when a single user should never be able to hold access to more than one tenant at a time, or when tenants belong to different legal entities that have separate audit and data-handling obligations. Medplum's tenant selector guide describes it as one tenant per token, which gives the strongest API-level isolation and the highest complexity. A single account with a selector is easier for users who genuinely work across several tenants, but it requires careful enforcement of allowed tenants on every request. A unified view offers no isolation beyond the project and suits only cases where that is acceptable. Choose the model that matches the most sensitive tenant boundary, not the one that is easiest to demonstrate.

Is a tenant selector enough to pass a regulated security review?

A selector on its own is rarely enough. It is one control in a larger set that reviewers examine, including access policies, identity and multi-factor authentication settings, audit logging, and evidence that tenant boundaries hold under test. Medplum's compliance documentation states that compliance is a shared responsibility between Medplum and its customers, so the organization must document how its own configuration meets each requirement. Reviewers will usually ask for a written isolation model, test results that show cross-tenant access is denied, and records of changes. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. Independent auditors and certification bodies make those determinations.

Where the Medplum documentation stops

The Medplum tenant selector guide answers the design question: which of the three patterns fits your application, strict isolation, a single account with a selector, or a unified view. It explains that strict isolation issues one tenant per token and gives the strongest API-level separation at the highest complexity, that a single account with a selector enforces the allowed tenants while the user interface scopes the active tenant, and that a unified view adds no isolation beyond the project. Read the Medplum tenant selector guide first, because every later decision in this topic depends on the model you pick. The guide does not tell you how your own tenants, roles and data labels should be modeled, and it does not replace testing against your deployment.

Several questions remain open for your environment. Confirm the Medplum version you run, since the pillar's release history shows frequent patch releases and the upgrade rules differ by version, and check the upgrade notes before you copy any pattern from a newer example. Confirm how your identity provider passes tenant claims into the token, because a single account with a selector depends on that configuration and on whether your provider supports the external identity setup you plan to use. Then write access policy tests for each tenant pair: a user assigned to tenant A should be denied every read and write that belongs to tenant B, including searches, GraphQL queries and Binary files. Those tests, run against your own project, are the evidence a security reviewer will ask for, and no documentation page can produce them for you.

How DeployOpen scopes and delivers a tenant selector

DeployOpen approaches a tenant selector for Medplum as a written, fixed-scope piece of work: first agreeing which isolation model fits your tenants and users, then building, testing, documenting and handing over the selector inside infrastructure you control. Ongoing support is available as a retainer once the work is live.

How we scope

  • Confirm which isolation model applies: strict isolation, a single account with a selector, or a unified view.
  • Map which tenants each user group may reach and which tenant is active by default.
  • Agree in writing the re-authentication behavior, the access policy pattern and the test cases before work starts.

How we build

  • Implement the tenant selector against your Medplum project, with allowed tenants enforced on the server and the active tenant scoped in the interface.
  • Build and test access policies so that a user cannot read another tenant's data by switching the selector.
  • Verify the design with negative tests from each tenant context, covering search, GraphQL and Bot calls.

How we hand over

  • Deliver the selector code, access policy configuration and test suite in a form your engineers can review and run.
  • Document the isolation decisions, token and session behavior, and the steps to add or remove a tenant.
  • Walk your security and engineering teams through the design so they can review and operate it without us.

How we support

  • Offer ongoing support, upgrades and continuous testing for the selector as Medplum releases change.
  • Retest access controls after Medplum upgrades or changes to tenant, user or policy configuration.
  • Confirm support terms, response expectations and retainer scope with your written agreement before work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.