
ESR
Why Multi-Tenant API Architecture Is a Must for NHS ESR Data
NHS ESR data powers multiple organisations, teams, and vendors. Without multi-tenant API architecture, integrations become duplicated, insecure, and hard to govern. Here’s why multi-tenancy is essential—and how to implement it safely for ESR-to-API workflows.WeHub
Reading time: ~9–11 minThe reality: ESR data is shared by many consumers
In the NHS, workforce data isn’t consumed by one system. It feeds onboarding and access workflows, rostering and bank staffing, HR reporting and finance alignment, supplier/vendor platforms, and internal dashboards and analytics.And the organisation structure is rarely “one clean boundary.” You may need to support:- multiple trusts
- multiple sites and departments
- partner organisations
- shared services
- vendor access with strict scoping
- and varying policies across groups
What “multi-tenant” means for NHS ESR (practically)
Multi-tenant architecture means one platform instance can securely serve many organisational units (“tenants”) while keeping data and access properly separated.For ESR-to-API, that usually means:- each trust (or organisational entity) is a tenant
- vendors/apps access only the tenant(s) they’re authorised for
- rules can be shared globally but configured per tenant
- audit trails and exceptions are tenant-aware
- onboarding a new tenant is mostly configuration, not a rebuild
Why single-tenant ESR APIs fail at NHS scale
A single-tenant ESR API layer tends to produce one of two bad outcomes:1) Duplicate stacks everywhereEach trust/team spins up their own ingestion + mapping + validation + publishing. This multiplies cost and creates inconsistent rules.2) One shared stack with weak boundaries- vendors can see too much
- audit is messy
- mistakes become incidents
- confidence drops
The 7 must-have benefits of multi-tenant ESR APIs
1) Strong data isolation (by default)Tenants only access their own data. This is the non-negotiable baseline.2) Consistent rules across consumersValidation and integrity rules are applied centrally and uniformly.3) Faster onboarding of new trusts / org unitsOnboarding becomes “configure + deploy,” not “start a new integration project.”4) Safer vendor access- scope access to a tenant
- scope access to endpoints/resources
- enforce least-privilege permissions
Tenant isolation models (and which one to pick)
There are 3 common models:Model A: Database-per-tenant- Pros: strongest isolation, clear blast radius
- Cons: more operational overhead at scale
- Pros: strong isolation with less overhead than DB-per-tenant
- Cons: operational complexity with many tenants
- Pros: simplest operations, scales well
- Cons: isolation must be enforced perfectly (RBAC + row-level security + query discipline)
Security essentials: identity, access, and audit
Multi-tenancy without strong security is just a shared database with extra steps.Minimum security requirements:1) Tenant-aware authenticationUse identity tokens that include tenant context (or map identities to tenants via your auth layer).2) Authorisation that enforces tenancyEvery request must be evaluated against tenant membership, role permissions, and endpoint/resource scope.3) Least-privilege vendor scopesVendors should never have “all tenant” access by default. Use scoped API keys / OAuth clients per tenant + per permission set.4) Tenant-aware audit logs- tenant_id
- actor
- resource
- action
- timestamp
- correlation IDs (trace across workflows)
Data contracts: versioning without chaos
In multi-tenant environments, breaking changes are expensive because many consumers depend on you.Good patterns:- version your APIs (/v1, /v2) or version your schemas explicitly
- introduce changes behind feature flags per tenant
- allow tenant-by-tenant rollout (pilot → expand)
- keep backward compatibility windows
- document contracts clearly
Tenancy-aware workflows: ingestion, validation, publishing
A multi-tenant ESR-to-API workflow should be tenant-aware from the first step:Step 1: Ingest (tenant identified early)- determine tenant from file source, connection, or metadata
- store raw files with tenant context
- track processing state per tenant
- shared baseline validations (global)
- tenant-specific rules/configs (where needed)
- position integrity checks
- quarantine exceptions per tenant (with the right owners notified)
- APIs are scoped by tenant automatically
- events include tenant context
- consumers can only subscribe/access what they’re allowed to
- success/failure rates per tenant
- exception rates per tenant
- performance metrics per tenant
- full lineage: tenant + file + record + output
Common mistakes (and how to avoid them)
Mistake 1: “We’ll add multi-tenancy later”Later becomes never—and by then, tenant boundaries are too expensive to retrofit. Build tenancy into the API contract and data model from day one.Mistake 2: Tenant isolation only at UI levelIf the backend doesn’t enforce tenancy, you don’t have multi-tenancy. Enforce tenancy in auth + data access + audit.Mistake 3: One vendor credential for everythingThis is how accidental data leaks happen. Use per-tenant credentials/scopes and rotate them.Mistake 4: No tenant-aware observabilityYou can’t operate what you can’t see. Track SLA, failures, and exceptions per tenant.A reference blueprint (simple + scalable)
A clean reference setup looks like:- Tenant registry (tenant metadata, configs, feature flags)
- Ingestion service (SFTP/file detection, tenant identification, raw storage)
- Normalisation + rules engine (schemas, validations, integrity checks)
- Publishing layer (REST APIs + event stream)
- Audit + observability (logs, tracing, metrics, dashboards)
- Access control (tenant-aware RBAC/ABAC, vendor scopes)
The bottom line
NHS ESR data naturally serves multiple organisations, teams, and vendors. If your ESR-to-API layer isn’t multi-tenant, you’ll pay in duplicated integrations, inconsistent rules, and growing security risk.Multi-tenant API architecture gives you:- tenant isolation by design
- consistent validation and rules
- safer vendor access
- tenant-by-tenant rollout
- scalable onboarding
- clean auditing and observability
Keywords
ESRNHSMulti-Tenant ArchitectureAPIsData GovernanceSecurityIntegration