HAPI FHIR partitioning and multitenancy

Partitioning lets one HAPI FHIR JPA server hold data for several organizations or sources. This page covers when it fits, how tenant routing and partition interceptors work, and which search and history limits to confirm before go-live.

On this page

HAPI FHIR partitioning and multitenancy: when one server can serve several organizations

Partitioning is the right tool when one HAPI FHIR JPA server must hold data for several organizations, business units or data sources, and each group's data must stay logically separate. HAPI FHIR places each resource in a partition, and that partition can be used for multitenancy, for separating data sources or for grouping data by region. It fits best when the groups share one operating team, one release cycle and one database, and when the separation can be expressed as a partition assignment on every resource. If a group needs its own database, its own upgrade schedule or its own network boundary, a separate server deployment is usually the simpler answer, and that choice should be made before any data is loaded.

Partitioning is not a complete security layer. HAPI FHIR states that it does not provide a single security layer that fits every deployment. It offers building blocks instead, including authentication interceptors, the AuthorizationInterceptor, consent and search narrowing interceptors, CORS support and BALP audit logging. A partition assignment tells the server where a resource is stored, but it does not decide which user or application may read or write it. Each tenant boundary therefore needs an access model that maps identities to partitions and is enforced on reads, searches, history and writes. Design that model with your security team before go-live, and test it with requests that deliberately try to cross partitions.

This page covers the partitioning options, how to set them up, the security controls to place around them, the documented limits on search and history, and the cost drivers for the team that will run the server. Limits deserve early attention because a query that spans partitions can behave differently from one scoped to a single organization, and those differences change what each tenant can see and how long queries take. Confirm the exact limits and the setup steps for your HAPI FHIR version in the HAPI FHIR JPA partitioning documentation before you commit to a design. Cost comes from the database, from the engineering time to design the access model, and from the testing that shows isolation holds.

Which partition use case fits your situation

This table compares the three partition use cases HAPI FHIR supports, plus the default partition used for shared resources. Read each row for the usual reason to choose it, what the tenant or client must be able to see, and what to confirm about cross-partition search and reporting before you commit. The main takeaway is that the choice sets how much data a single search or report can cross, so settle that question before you design partition IDs.

Use caseTypical reason to choose itWhat the client must be able to seeConfirm about cross-partition search and reporting
Multitenancy for separate organizationsOne server hosts several organizations whose records must stay apart, such as separate customers of a hosted FHIR service.Only its own resources, reached through its tenant identifier in the URL.Whether any search or history request can span partitions, who may run it, and how the interceptor enforces the boundary on each path.
Separating data sourcesRecords arrive from distinct source systems, such as separate EHRs or labs, and each feed needs its own load, retention or lineage.Typically its own source's data, unless the consuming application merges several feeds.Whether reports must combine sources, how duplicate patients across sources will be matched, and whether MDM linking works across partitions in your version.
Grouping data by regionData must stay in a region for residency or policy reasons, and regional teams work mainly with their own patients.Its regional records only, plus any national view that the policy explicitly allows.Whether national reports need all regions at once, how cross-region searches are authorized and logged, and whether backups stay in-region.
Shared resources in the default partitionShared resources the server stores in the default partition, outside any tenant's partition, must be visible to all partitions.Whatever the server exposes from the default partition, which may differ from tenant-scoped results.Which resource types the default partition forces, whether tenants can write to it, and how it appears in searches and history.

How tenant identification and partition interceptors route requests

A request is tied to a partition through the tenant identifier the client sends in the URL. The partition interceptors read that identifier and decide which partition each read and write is assigned to. HAPI FHIR places each resource in a partition, which can serve multitenancy, separation of data sources or grouping by region, so the routing choice you make here shapes every later access decision. The exact URL format, configuration keys and interceptor classes differ by version, so check them against the HAPI FHIR partitioning documentation for the release you run before you write any client code. Partitioning routes requests but does not authenticate callers, so your authorization layer still has to confirm who may use each tenant.

Any resource that no interceptor assigns to a named partition falls into the default partition. Some resources may be forced there regardless of the tenant in the request, so list which resource types land in the default partition for your version and decide whether that placement is acceptable for each one. This matters for visibility: a resource in the default partition can be returned to requests that were never meant to see it, so treat the default partition as shared space unless the documentation and your own tests show otherwise. Ask your platform owner or the vendor to confirm how reads against the default partition are scoped before you load production data.

Test the routing before go-live. Create resources under two tenant identifiers, then confirm that search, read, history and includes under one identifier never return the other tenant's data, and that resources without an assigned partition appear where you expect. Keep the interceptor order, the default partition rules and the test results in your design record, and repeat the same tests after each upgrade, because interceptor classes and configuration keys can change between versions. A small set of fixed test cases gives your security team evidence they can review without reading the server code.

How a tenant request reaches its partition

This illustrative flow follows one request from a client application through the reverse proxy at the edge to the HAPI FHIR JPA server, where the AuthorizationInterceptor must approve tenant access before the partition interceptor resolves the tenant from the URL. Resources the partition interceptor does not assign to a tenant are forced into the default partition, a branch that needs its own access review. Every request should also produce a BALP audit event inside the application server boundary. Check that clients cannot reach the server without passing the proxy, and that both branches end in the same database with access rules and audit logs in place.

Illustrative flow: authorization and audit sit inside the application server boundary.

Setting up HAPI FHIR partitioning in the JPA server

This sequence takes a HAPI FHIR JPA server from version selection to a tested partitioned deployment. Each step ends with a check your team can run and record, so tenant boundaries are proven before any production data is loaded. Work through the steps in order, because later checks depend on the configuration and partition map set up earlier.

  1. Confirm the target version and JDK

    The platform team picks the HAPI FHIR release it will run and confirms its Java requirement on the official versions page before any images are built. HAPI FHIR 8.2.0 requires JDK 17, so a team on an older runtime must upgrade the JDK or choose a different release. Record the release, JDK version and starter build in the deployment record. Check: a clean build succeeds on the target JDK, and the running server reports the expected version in its FHIR capability statement at the metadata endpoint.

  2. Choose PostgreSQL or SQL Server

    The JPA server starter defaults to an embedded H2 database, which suits trial work but not production. Production needs PostgreSQL or Microsoft SQL Server, and MySQL is not supported by the starter. Choose between the two based on the database skills, backup tooling and hosting your organization already operates, then confirm the engine against the documentation for your release. Check: a fresh server starts on the chosen database, creates its schema, and a test resource written through the API is still readable after a restart.

  3. Enable partitioning per the official guide

    Follow the official HAPI FHIR partitioning guide for your release and apply its configuration keys exactly, including the mode that matches your data model. Partitioning places each resource in a partition, which can serve multitenancy, separate data sources or group data by region, so decide the purpose before enabling it. Keep the settings in version-controlled configuration so changes go through the same review as code. Check: the server starts with partitioning enabled, and a request without a tenant identifier behaves exactly as the guide describes.

  4. Define the partition map and tenant identifiers

    Write a partition register listing each partition, its tenant identifier as it appears in the request URL, and the organization, data source or region it represents. Agree naming rules with the teams that call the API, because a changed identifier affects every client and stored reference. Name the people who may create partitions and who administers them. Check: the register is approved, and creating a test partition produces the identifier listed in the register when you query the server.

  5. Write and test partition interceptors

    Write the interceptors that decide which partition each request reads from and writes to, based on the tenant identifier and the caller's authorization. HAPI FHIR supplies building blocks such as the AuthorizationInterceptor but no finished tenant policy, so this logic is your control and should fail closed when a tenant is missing or unknown. Cover it with unit tests, then run it against a server with at least two tenants. Check: the suite passes in CI, and a recorded run shows every cross-tenant request returning an error with no resource content.

  6. Verify default partition behavior

    Confirm where resources land when they arrive without a partition the interceptor recognizes. Some resource types are forced into the default partition, so the team must know which types end up there and who can read them. Write a test for every resource type in your data set and record its storage partition. Check: a report lists each resource type and its partition, and every type that lands in the default partition has a named owner and a documented access rule.

  7. Test cross-tenant reads and writes

    Build a negative test matrix in which each tenant credential attempts to create, read, update and delete resources in every other tenant. Add reads that follow references across partitions, and include batch and transaction requests, since one call can carry several targets. Check: every attempt that should fail returns the expected error, and the matrix is attached to the release record and rerun after each interceptor change.

  8. Test search and history per partition

    Run each search parameter your clients use and each history request against every partition, and compare the results with the limits documented for partitioned servers. Record any search that returns resources from another partition or misses expected results. Confirm the limits with the official guide and your own test data rather than assumptions. Check: a signed-off table lists each search and history case per partition with its documented limits marked, and the team has agreed how client developers will be told about them.

Keeping tenants apart: security controls around partitions

HAPI FHIR partitions decide where each resource is stored and which tenant a request names. They do not decide who may read or write that data. HAPI FHIR supplies building blocks, so the operator must add authentication, authorization, consent, CORS, audit logging and write review, then confirm each one against the HAPI FHIR security documentation.

Authenticate every caller first

HAPI FHIR does not provide one login system for the whole server, so the operator must place an authentication step in front of it. That can be an interceptor that validates tokens from your identity provider, or a gateway that does this before requests reach the server. Every request needs a verified identity before any partition logic runs. List which endpoints answer without a token, such as the capability statement, and test each one. Confirm the token validation settings in the HAPI FHIR security documentation before go-live.

HAPI FHIR security docs

Restrict access with AuthorizationInterceptor

The AuthorizationInterceptor turns an authenticated identity into a set of allowed operations. Its rules decide which resource types, compartments and operations a caller may read or write, and the server enforces them on every request. On a partitioned server, the rules must stop a caller with access to one tenant from reaching another tenant's data through a search, a history call or a write that names a different partition. Test each rule with a second tenant's credentials before go-live. Confirm how the interceptor handles requests that do not name a partition at all.

Narrow searches and apply consent

Consent and search narrowing interceptors add limits inside a request that is already allowed. A consent interceptor can check patient-level permissions before data is returned. A search narrowing interceptor adds conditions so a caller only sees the records it is entitled to. Both matter on a shared server because a broad search can return records from data a user should not see, even when the user holds a valid tenant token. Decide which resource types need these checks, write the test cases first, and confirm the exact configuration in the HAPI FHIR security documentation.

Set CORS to named origins

Cross-origin resource sharing controls which browser applications may call the server from another origin. A wildcard origin lets any website a user visits ask the API for data, and the risk grows if your front ends rely on browser-held session cookies. Allow only the front-end origins your tenants use, and set the list separately for each environment. Avoid copying a wildcard from a test configuration into production. If a gateway also sets CORS headers, check that the two layers agree, and confirm the property names in the HAPI FHIR security documentation.

Record access with BALP audit logging

BALP audit logging is the audit approach HAPI FHIR provides for recording who accessed which resources and when. On a partitioned server, the audit trail must let reviewers answer questions about one organization without reading every tenant's data, so confirm that each record identifies the partition the request touched. Confirm which events the logging captures, where the records are stored and who can read them. Keep the records in storage that tenant administrators cannot change, and test that a read from one partition appears with the caller's identity.

Review who writes to the default partition

Resources that are not assigned to a tenant partition are stored in the default partition, so anything written there is readable by whoever the access rules allow and may be shared across tenants. Keep a short list of the accounts and systems allowed to write to it, and remove the rest. Review that list on a schedule and after every new integration, because a loader script or an old client account can write there without anyone noticing. Confirm in the partitioning documentation which resource types are forced into the default partition in your version.

HAPI FHIR partitioning docs

What each team owns in a shared partitioned server

The platform team keeps the shared server running for every tenant at once. Its decisions affect all partitions, so one tenant's outage, failed upgrade or restore affects everyone on the server. Whoever holds this work should be able to show how the server is deployed, how the database is sized and backed up, and how upgrades are tested before they reach shared data.

  • Deployment model: Choose the starter deployment path that fits your hosting, such as the Docker image, Docker Compose, Kubernetes with the Helm chart, or a WAR on a supported application server, and record why it fits.
  • Database platform: Select PostgreSQL or Microsoft SQL Server for production, since the starter does not support MySQL, and document connection limits and storage growth as partitions are added.
  • Backups and restore tests: Back up the whole database and test a restore. A restore returns every tenant to the same point in time, so record the recovery order and who can approve it.
  • Upgrades: Plan each move against the release notes for the version in use, confirm the Java requirement (HAPI FHIR 8.2.0 requires JDK 17), and rehearse the upgrade on a copy that holds representative tenant data.

Check that the platform owner can name the database version, the JDK version, the date of the last tested restore and the rollback steps for the running release.

Search and history limits in HAPI FHIR partitioning to confirm

Partitioning gives one HAPI FHIR JPA server several tenant or data-source boundaries, but search and history behavior around those boundaries is where isolation claims most often fail. The five areas below are the ones to test before you promise a tenant that its data is separate. Confirm each one against the documentation for your HAPI FHIR version and against your own data.

Search scope across partitions

Confirm whether a search sent through one tenant's endpoint can return resources from another partition, and how the server decides which partitions a request covers. This determines whether tenant-scoped access can ever see data outside its own boundary. Write searches from each tenant that should return nothing from the others, then run them against the exact HAPI FHIR version you plan to deploy. Keep the results for each search parameter you expose to users.

HAPI FHIR partitioning docs

History across partitions

Check how the history operations return versions at the server, type and instance level when partitions are in use. A history request made in one tenant's context should return no versions written under another tenant. Confirm whether deleted versions and their metadata appear in the response, because a tenant may ask for those records to be removed. Test with a resource that has several versions in each partition, and compare the output with what your retention and erasure process expects.

Default partition resources

Resources placed in the default partition are shared by every request that resolves to it, so their visibility depends on how that partition is configured and read. Confirm which resource types the partition configuration sends there and whether a tenant-scoped request can read them. Decide before loading any patient data whether shared reference content belongs there, and whether tenant records could end up there by mistake. Repeat the check on a fresh database and again after a migration.

Partition-aware search parameters

Partition-aware search parameters can give different results from the same parameter on a standard, unpartitioned server. A query that works in a single-tenant test may behave differently once partitioning is enabled. Compare each parameter your applications use against a standard server, and note which ones resolve within the partition and which span it. Document the result in your test plan so developers know which parameters are suitable for tenant-facing use.

Confirm behavior for your version

Partitioning behavior is tied to the release you run, so read the documentation for that exact version before you trust any limit above. Pick the version from the release list, confirm each item against its matching docs, and record the version in your test report. Build a test set with at least two tenants, default partition resources and multi-version resources, then rerun the same searches and history requests before and after each upgrade.

HAPI FHIR versions

What drives the cost and effort of a partitioned deployment

A partitioned HAPI FHIR server carries one-time work and recurring work, and both need an owner in the written scope. One-time work covers the partition model: which tenants get which partitions, how each tenant is identified in the request URL, which resource types stay in the default partition, and the interceptors that enforce those rules. It also covers onboarding tests that show one tenant cannot read or write another tenant's resources, a security review of authorization and audit logging, and the first data load for each tenant. Recurring work covers onboarding new tenants, retesting partition behavior after each HAPI FHIR upgrade, and running monitoring and backups for the shared server. In a fixed-scope engagement, the partner is paid for design, build and test work, while your team usually keeps the data-owner decisions and final sign-offs.

Four factors move effort most. The first is the number of tenants, because each partition needs its own onboarding tests, load plan and access rules, so effort grows with every addition. The second is cross-partition queries. If any user or analyst needs results that span partitions, that path needs separate design and testing, and you must confirm which search and history limits the documented partitioning behavior places on it. The third is the regulatory review you expect. A review that asks for per-tenant audit trails and access evidence adds test and documentation work. The fourth is the database and hosting choice. The starter supports PostgreSQL and Microsoft SQL Server for production but not MySQL, and the hosting model (Docker, Kubernetes or an application server) changes how secrets, backups and health checks are built.

Ask for a written quote that lists each tenant and its partition name, the search and history behaviors the design accepts or excludes, the isolation test cases and who runs them, the upgrade retest scope for each HAPI FHIR version you plan to run, the database engine with its backup and restore tests, and the evidence package delivered to your auditors. DeployOpen does not publish a price list, so the quote follows from that written scope. Compare quotes against the same list of items, because a lower figure that drops isolation tests or restore tests delivers less. Confirm the partition behavior for your chosen version in the HAPI FHIR partitioning documentation.

Questions buyers ask before partitioning a HAPI FHIR server

How much does outside help for HAPI FHIR partitioning cost?

Cost follows from a written scope, and DeployOpen does not publish a price list. The main drivers are how many organizations or data sources will share the server, how many resource types need partition rules, whether partitioning is planned for a new deployment or added to a server that already holds data, and how much surrounding work is included, such as database setup, deployment, access control and testing. Moving existing data into partitions tends to add effort because each record must be assigned correctly. Design and build work is one-time, while hosting, database operations, upgrades and any support retainer recur. Ask for a quote that lists each deliverable, the assumptions about tenants and data volume, and what your team must supply. DeployOpen provides a quote from the written scope before work starts.

How long does a HAPI FHIR partitioning project take?

The timeline is set by the scope agreed in writing, so no fixed duration applies until that scope exists. The main drivers are the number of tenants and data sources, how many resource types need partition rules, whether each tenant owner must approve the design, whether the server is new or already in use, and how much existing data must be moved. Access control and audit logging add work when each tenant may see only its own data. Client-side dependencies such as database provisioning, network approvals, identity provider configuration and change windows often set the pace more than the build does. Ask for a phased plan with a design review, a build stage and a test stage, plus the client decisions each stage needs. Confirm the HAPI FHIR version and JDK early, since HAPI FHIR 8.2.0 requires JDK 17.

What does our team need to provide for a partitioning project?

Your team provides the decisions, access and environment the work depends on. Name a business owner for each organization or data source that will share the server, and agree the tenant identifiers that appear in the URL. Engineering supplies a target environment in infrastructure you control, with a database the server supports (PostgreSQL or Microsoft SQL Server for production), network paths, certificates and a deployment and rollback method. Security and identity teams supply the identity provider, role definitions and rules for which tenant can see which data. Compliance staff should state which obligations apply so controls can be designed against them. Someone must own the test data and sign off on partition test results. Ask the partner to list these inputs in the written scope with a named contact for each, so delays surface early.

Can an internal team set up HAPI FHIR partitioning without outside help?

Yes, an internal team with Java, FHIR and database experience can set up partitioning alone. HAPI FHIR is licensed under the Apache Software License 2.0, and its partitioning documentation describes the mechanism. The harder part is design: how resources map to partitions, how tenants are identified, which resources stay in the default partition, and which search and history limits your tenants will accept. Those choices shape security, cost and support later, so mistakes are expensive to unwind. Confirm that your team can build and test the partition interceptors, the access control layer, backups, upgrades and on-call operations. HAPI FHIR states that it does not provide a single security layer, so authorization and audit logging must be built deliberately. Many organizations split the work, with internal staff owning operations and a partner reviewing the design or building the riskiest parts.

Does partitioning a HAPI FHIR server meet a compliance requirement?

Partitioning is one technical control, and it does not by itself satisfy a compliance requirement. DeployOpen does not issue audit reports, attestations or certifications. Independent auditors and certification bodies assess controls, including how they operate over time. Partitioning separates tenant data, but an assessment usually also covers access control, consent, audit logging, encryption, backups, change management and who can change the partition configuration. HAPI FHIR offers building blocks such as the AuthorizationInterceptor and BALP audit logging, so each control must be designed and evidenced by your team. DeployOpen prepares systems, controls and evidence for compliance assessments. Start by listing the obligations that apply, mapping each to a control, and asking your assessor which evidence they expect before the build begins.

Who provides commercial support for HAPI FHIR?

The HAPI FHIR README points to Smile CDR for commercial support. HAPI FHIR is open source under the Apache Software License 2.0, so the software itself is available without a commercial agreement, but support is a separate decision. DeployOpen is a Chainscore Labs company that plans, implements, customizes, hardens, backs up, upgrades and supports self-hosted open-source platforms in infrastructure you control. Ongoing support, upgrades and continuous testing are available as retainers. DeployOpen is not an official partner, reseller or certified provider of HAPI FHIR or Smile CDR. Decide which parts you need, such as vendor-backed fixes, implementation help, upgrade planning or day-two operations. Compare what each option covers in writing, including response expectations and the HAPI FHIR versions it applies to, and confirm current terms directly with each provider.

How DeployOpen scopes and delivers partitioned HAPI FHIR deployments

DeployOpen plans and builds partitioned HAPI FHIR JPA servers inside your own infrastructure, so each organization or data source has a defined partition, access rules and documented limits before any data is loaded. We start from the tenant model, then set the partition interceptors, authorization, audit logging and operating procedures around the server. Engagements are fixed-scope, with the written scope agreed before work starts.

How we scope

  • Map each organization, data source or region to a partition and record the tenant identifier format used in URLs.
  • Document which resource types stay in the default partition and which are placed in tenant partitions.
  • The written scope lists partitions, interceptors, access controls, documents and handover items for your deployment.

How we build

  • Deploy the JPA server starter on PostgreSQL or Microsoft SQL Server, the production databases the starter supports.
  • Configure tenant identification in the request URL and wire partition interceptors so requests resolve to the correct partition.
  • Assemble authorization, consent and BALP audit logging from HAPI FHIR's building blocks, which are not a complete security layer.

How we hand over

  • Test partition isolation, so one tenant's requests cannot read or write another tenant's resources.
  • Document the tenant model, partition layout, interceptor configuration and known search and history limits for your teams.
  • Hand over a runbook for adding a tenant partition, including identifier, interceptor and access rule changes.

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after handover.
  • Re-check partition isolation and access rules after each HAPI FHIR upgrade, before the change reaches production.
  • Prepare evidence for your compliance assessment, which an independent auditor or certification body then reviews.

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.