Skip to content
architecture

Multi-Tenant Architecture for CIAM: Patterns and Trade-offs

Updated 2026-05-06 · 11 min read · By @guptadeepak

Key takeaways

  • Three isolation models dominate B2B SaaS: shared schema with tenant_id, schema-per-tenant, and database-per-tenant. Each trades cost for isolation.
  • Tenant resolution at request time, subdomain, path prefix, header, or claim, determines the auth model.
  • Per-tenant configuration (SSO, MFA, branding, audit retention) belongs to the Organization, not the user.
  • Cross-tenant operations (consultants in multiple Orgs) require careful claim design: which Organization is this token for?
  • Most B2B-mature CIAM ships multi-tenancy as a primitive, Organizations as a first-class object, not a tenant_id claim convention.

What multi-tenancy means in CIAM

The architecture choice cascades into the rest of the CIAM design. A vendor that ships Organizations as a primitive lets the application treat tenant context as part of the auth token. A vendor that doesn't forces the application to maintain its own tenant model on top.

Multi-tenant CIAM architecture. Each Organization is a first-class entity with its own SSO, SCIM, and audit log; users belong to memberships; the app's auth middleware resolves the active Organization and enforces tenant_id at the data layer.
Multi-tenant CIAM architecture. Each Organization is a first-class entity with its own SSO, SCIM, and audit log; users belong to memberships; the app's auth middleware resolves the active Organization and enforces tenant_id at the data layer.

The three isolation models

Shared schema with tenant_id

One database, one schema, every table has a tenant_id column. Every query filters by tenant. The default for cost reasons; works to thousands of tenants per cluster.

Trade-offs: Cheapest by far. Risk of tenant-data leak if a query forgets the tenant_id filter, caught by Postgres Row-Level Security or ORM enforcement. Acceptable for most B2B SaaS; not acceptable for some regulated healthcare and finance workloads.

Schema-per-tenant

One database, many schemas (one per tenant). PostgreSQL supports this natively; queries reference tenant_42.users. Migrations are per-schema.

Trade-offs: Stronger isolation, a query without explicit schema selection fails rather than returning cross-tenant data. Higher operational cost (migration tooling, schema search-path management, larger schema count strains some Postgres internals at thousands of tenants).

Database-per-tenant

Separate database per tenant, often on shared infrastructure. Strongest isolation; suits regulated workloads.

Trade-offs: Highest operational cost (per-DB connection pools, migrations, backups). Compute and storage cost multiplies. Justified for healthcare (HIPAA), banking (PCI), or government workloads where audit explicitly requires it.

Tenant resolution at request time

The application needs to know which tenant a request belongs to. Four common patterns:

  • Subdomain. acme.example.com resolves to tenant acme. Best UX for B2B SaaS; requires per-customer DNS or wildcard SSL.
  • Path prefix. example.com/acme/dashboard. Cheaper to deploy; weaker brand differentiation per customer.
  • Header. X-Tenant: acme set by an upstream router. Common for API products; transparent to the client.
  • Claim. The auth token carries the tenant_id; the application reads it from the JWT. The default for vendors with first-class Organizations.

Most production B2B SaaS uses subdomain or path-prefix resolution at the network edge plus claim-based authorization in the application.

Per-Organization configuration

Configuration that feels global in B2C is Organization-scoped in B2B:

  • SSO connection, each customer's IdP plugs into their Organization.
  • MFA policy, required for admins, optional for members; varies per customer.
  • Allowed email domains, restrict who can join.
  • Branded login, customer's logo, color, copy.
  • Audit retention, 90 days vs 365 days vs 7 years per customer.

The CIAM that ships Organizations as primitives expose all of this per-Org. The CIAM that doesn't forces the application to build a tenant-config layer.

Cross-tenant memberships

A consultant working with three customer organizations has three memberships:

Membership(user: alice, org: acme, role: editor)
Membership(user: alice, org: globex, role: admin)
Membership(user: alice, org: initech, role: viewer)

When Alice authenticates, which Organization is the session for? Two patterns:

  • Per-Org session. The user picks the Org at login (Alice → which workspace? → acme). Token claims include org_id: acme. Switching Orgs requires re-authenticating to the new context.
  • Multi-Org token. The token carries all memberships; the application picks the active Org per-request. More flexible, more complex to authorize correctly.

Most B2B SaaS uses per-Org session, simpler claims model, cleaner audit trail.

When the CIAM doesn't ship multi-tenancy

If the CIAM treats users as global and the application has to invent Organizations on top, the typical cost surfaces include: tenant_id-filtering at every query, building an Org admin UI from scratch, custom claim transformation to inject tenant context, manual SSO connection management per-customer.

The B2B-first CIAM products that avoid this work: WorkOS (Organizations as the design center), Frontegg (embedded Admin Portal), Auth0 Organizations, and OSS Zitadel. For cost-sensitive or specialty deployments, SSOJet, Wristband, and PropelAuth target the same niche.

For self-hosted, Keycloak realms provide a tenancy primitive but at the realm level (heavyweight per-tenant operations); Ory and Authentik handle multi-tenancy through schemas / projects.

Related vendors

FAQ

What's the difference between multi-tenant and B2B?
Multi-tenant is the architectural pattern where one application serves multiple customers (tenants) with logical separation. B2B is the buyer profile, selling to organizations rather than consumers. Most B2B SaaS is multi-tenant; most multi-tenant SaaS is B2B. The two terms are often used interchangeably in CIAM contexts.
Should I use shared schema or database-per-tenant?
Shared schema is the default for cost reasons and works to thousands of tenants. Database-per-tenant suits regulated workloads with strict data isolation requirements (healthcare, finance) but multiplies operational cost. Most B2B SaaS in 2026 uses shared schema with rigorous tenant_id enforcement at every query.
How does a user belong to multiple tenants?
Membership becomes a separate object: Memberships(user_id, organization_id, role). A consultant in three customer orgs has three memberships. The auth token is issued per-org-context, so the application knows which membership the request is acting on.
What if my CIAM doesn't ship multi-tenancy as a primitive?
Build it on top using user metadata and tenant claims, but expect the result to be less ergonomic than a B2B-first CIAM. WorkOS, Frontegg, Auth0 Organizations, and Zitadel all ship Organizations as a first-class concept, which materially simplifies the application code.

Sources

  • Auth0 B2B Organizations documentation
  • WorkOS Directory + Organizations documentation
  • AWS multi-tenancy patterns whitepaper
Last reviewed 2026-05-06.