A white-label B2B SaaS shows each client, called a tenant, a branded product on its own domain with its own users, roles, data and reports. Four decisions define it: the tenancy model, how every request is resolved to a tenant, how permissions are modeled, and how usage is measured per account. Isolation must be enforced below the application code, in the database, so a forgotten filter cannot leak data. This guide covers each decision and what to ask a firm that says it has shipped one.
Can a multi-client platform, such as fund accounting, isolate workflows, APIs and reports by client?
Yes, if isolation is designed into the data, API and reporting layers instead of added as a filter on the screen. In fund accounting a "client" can be a fund, a fund family or an investor entity. Whatever unit your customers call a client becomes the tenant or a scope beneath it, and that modeling choice comes first.
- Workflows: definitions, queues, schedules and approval states belong to one tenant. A job carries its tenant with it, and fair scheduling stops one client's month-end batch from delaying the rest.
- APIs: each tenant has its own credentials, rate limits, webhook endpoints and signing secrets. A request for a record that belongs to someone else returns "not found", the same answer as for a record that does not exist.
- Reporting: reports and exports read from tenant-scoped views or policy-protected tables, never from a cross-tenant query filtered afterwards. No joins cross tenants, and scheduled reports run in the tenant's context, not as an administrator.
The question for any vendor is therefore not "can you isolate by client?" but "how is it enforced, and how is it tested?".
Shared database, schema per tenant or database per tenant?
Most white-label products start pooled, with one database and a tenant_id on every tenant-owned table, and move the few clients that need more separation to their own schema or database.
| Aspect | Pooled (shared) | Schema per tenant (bridge) | Database per tenant (silo) |
|---|---|---|---|
| Isolation strength | Only as strong as its enforcement: strong with database policies, weak with query filters | Stronger: permissions on each schema | Strongest: separate credentials, keys and regions |
| Cost per tenant | Lowest | Moderate | Highest |
| Operational effort | One schema, one migration | Every migration runs once per schema | Many databases to migrate, patch, monitor and back up |
| Noisy-neighbor risk | Highest | Medium | Lowest |
| Restore or export one tenant | Hardest: restore elsewhere, copy rows out | Easier: dump one schema | Simplest: one database |
| Usually fits | Many small, self-serve clients | A moderate number of clients needing customization | Regulated, large or contractually separated clients |
Hybrid is the usual outcome. Keep a tenant catalog (id, plan, status, where its data lives) from day one, so moving a regulated client out of the pool is a data migration, not a rewrite. Pick the cheapest model that meets the contract of your strictest paying client. The earlier article on multi-tenant architecture for SaaS covers the economics for a product-led business.
How does a request find its tenant, and how does the database enforce it?
Resolve the tenant once, at the edge, from the hostname. Carry it explicitly through the request and set it in the database session, so row-level security enforces it. Never take it from a field the client can edit.
- Hostname to tenant. Look the host up in a domain table, cached briefly. An unknown host gets a 404, never a default tenant.
- Session and membership. Check that the user has a membership in that tenant. Session cookies are scoped to the exact host, so one tenant's session is never sent to another's domain. An API key already belongs to one tenant.
- Permission check. One policy function decides whether this actor may perform this action on this resource.
- Tenant-scoped query. The transaction sets the tenant and the actor as transaction-local values, and database policies compare every row's tenant_id with them.
Row-level security, in plain words
In PostgreSQL you can attach a rule to a table that the database applies to every query, such as "only rows whose tenant_id equals this transaction's tenant". Six details decide whether it actually protects you:
- An ordinary role: the application connects as an ordinary role. Superusers, roles with the bypass attribute and table owners (unless enforcement is forced on them) skip the policies.
- Per transaction, not per connection: pooled connections are reused, and a session-level setting can carry one request's tenant into the next. The article on MCP server permissions with Postgres shows the same pattern for AI tool calls.
- A missing tenant matches nothing: forgetting to set it yields an error or zero rows, never everyone's rows.
- Writes too: a tenant cannot insert or update a row into another tenant.
- Constraints include tenant_id: unique constraints and foreign keys are checked outside the policies, so a global one can reveal that another tenant holds a value.
- Views run as the caller: use the security invoker option (PostgreSQL 15 and later). By default a view runs as its owner and can sidestep the policies.
The same tenant context everywhere else
Carry the tenant explicitly in jobs and queues (the worker sets the database context before touching data), cache keys, a mandatory search filter, file prefixes with short-lived signed links, webhooks signed with that tenant's secret, emails rendered with that tenant's templates and sender, and every log line.
Tests that try to cross tenants
Isolation that is not tested is a hope. Three automated checks earn their place: a suite that, for every endpoint and job, tries to read, change and delete a second tenant's records with the first tenant's credentials; a query with no tenant set that must return nothing; and a schema check that fails the build when a table with a tenant_id column has no enabled policy.
How do custom domains and white-label branding work?
A custom domain is a hostname a tenant has proven it controls, mapped to that tenant in a lookup table, with a certificate the platform issues and renews itself. Onboarding one end to end takes six steps:
- Claim. The tenant admin enters a hostname (a subdomain such as app.client.com is the safe default). The platform stores it as pending and refuses one that another tenant already holds.
- Prove control. The platform shows a TXT record with a random token and a CNAME record to a platform-owned name. A background job polls DNS until both exist, then marks the domain verified.
- Issue the certificate. Only after verification, request a TLS certificate through an automated certificate authority protocol, and renew it well before expiry with an alert on failure. The verified-domain list gates issuance: issuing on demand for any hostname that arrives lets strangers trigger it.
- Map and cache. The edge resolves hostname to tenant from the domain table, with a short cache invalidated on every change.
- Pick a canonical host. Redirect the platform subdomain and the www variants to one address, so cookies, links and search engines see a single one.
- Remove on exit. Delete the mapping and certificate and ask the client to remove the DNS records, so no dangling record is left behind.
- Email sender domains: if the product sends mail as notifications@client.com, the client publishes SPF and DKIM records generated for that domain, and a DMARC policy is advisable. Until they are verified, send from the platform's domain with the tenant's display name and a reply-to address.
- Brand through tokens, not forks: logo, colors, fonts, terminology and email, PDF and report templates live per tenant as validated data and are applied at render time. Let tenants edit placeholders only, never code. A code branch per client turns one product into N products.
- Plans and flags are entitlements: the plan decides which features and limits a tenant has, and the server checks them, not only the interface. Enabling a module for one client is a data change, not a deploy.
How should roles and permissions work when one user belongs to several tenants?
Model the user as one global identity, the tenant as a workspace, and a membership as the record that gives that user a role inside one tenant. Permissions are always evaluated per tenant, so the same person can be an administrator on one client's domain and a read-only viewer on another's.
- Memberships, not user-level roles: one row links user, tenant, role and status. The active tenant comes from the hostname, and the session only proves identity. The custom B2B client portal architecture article shows the same split for roles inside a client organization.
- Permissions in code, roles as bundles: code checks a permission such as report.export, never a role name. Start with fixed roles and add tenant-defined roles when a real client needs them.
- Resource scope: narrow an assignment to a client, portfolio, fund or project. An analyst assigned to one fund sees its ledgers, workflows and reports, not the next fund's.
- One audited decision point: a single function answers "may this actor do this to this resource?" for every endpoint, job and export. It denies by default and logs exports, role changes and key creation.
- Platform roles and impersonation: operator roles live apart, on their own host with strong authentication, and a tenant role never implies platform authority. Support impersonation is time-limited, requires a reason, is visible to the tenant, records both the operator and the user, and is read-only by default.
- API keys: a key belongs to one tenant (optionally one scope) with a least-privilege role. It is stored hashed, shown once, rotated with an overlap period and expired. The tenant comes from the key, never from a header the caller supplies.
How do you measure usage per account without mixing billing and analytics?
Give every event a tenant, an actor and the plan in force at that moment, and keep two pipelines: exact metering for billing and limits, and looser product analytics for learning.
Exact, idempotent, reconcilable. Written once per event id, reconciled against the source of truth (seats from memberships, storage from stored objects), kept long enough to settle a billing dispute, and enforced on the server as limits.
Directional, pseudonymous, short-lived. May be sampled, uses opaque actor ids, answers which features are used and where users drop off, and is never used to invoice.
Every event carries an event id for de-duplication, a timestamp, the tenant_id (plus a scope id where the product has scopes), the actor id and type (user, API key or background job), the plan in force, a name from a closed list, a quantity and a few non-personal properties. The plan is stored on the event because plans change and a past invoice must be reproducible.
Typical meters are seats, API calls, storage, reports and AI usage. Check limits on the server before the action and warn before a hard stop. Client admins see their own tenant's usage from tenant-scoped aggregates. Cross-tenant views are for platform operators only, show aggregates rather than content or identities, and every access is audited. Keep personal data and document content out of event properties, and decide in the client contract whose analytics these are.
How do you keep one tenant from slowing the others, and what must operations cover?
Cap every tenant at each shared resource, lead every index with tenant_id, and make per-tenant export and suspension routine operations rather than emergencies.
- Limits and fairness: rate limits and quotas per tenant and per API key at the gateway, and per-tenant concurrency caps or weighted round-robin in queues.
- Heavy reports kept apart: their own worker pool or read replica, with statement timeouts and a concurrency cap.
- Indexes that start with tenant_id: nearly every query and every policy filters by tenant. Add partitioning only for the few tables that grow without bound, once measurements show it is needed.
- Per-tenant backup, restore and export: in a pooled database, restoring one tenant means restoring a backup into a side database and copying rows back. Build a tenant export tool early: it also serves offboarding, data portability and support.
Operations checklist before the first client goes live
- Secrets: per-tenant credentials in a secrets store or encrypted under a key hierarchy, never in logs, with separate encryption keys where a client requires them.
- Audit log: an append-only record of who did what in which tenant, including impersonation, exports, and role and key changes.
- Tenant-aware observability: tenant_id on every log line, trace and metric, and no personal data in logs.
- Incident isolation: a switch that suspends one tenant, revokes its keys and pauses its queues without touching the rest.
- Onboarding: tenant creation as one repeatable, idempotent routine: record, default roles, first admin invitation, domain and plan.
- Offboarding and deletion: export, revoke sessions and keys, remove domains, and delete data, files, caches and search indexes as the contract says. Backups age out on their own schedule, so agree that schedule upfront.
How do you evaluate a firm that says it has shipped a white-label B2B SaaS?
Ask it to show, not tell: a live product, and a walkthrough from hostname to database row. A firm that has really built multi-tenancy answers these questions in specifics.
- Tenant resolution: "Walk me from a hostname to the first database query. Where does the tenant come from, and what happens for an unknown host?"
- Enforcement: "Where exactly is isolation enforced, in one sentence, and what happens when a developer forgets a filter: an error or a silent leak?"
- Testing: "Show the cross-tenant tests and the check that every tenant table has a policy."
- Custom domains: "Add a domain live: DNS verification, certificate, email sender domain and canonical redirect."
- Roles: "Show a user with two tenants and two different roles, and a resource-scoped grant."
- Usage: "Show where usage is metered, how duplicates are prevented and where limits are enforced."
- Evidence: "Show a live product, not slides, say which parts you built yourselves and which clients can be called as references, and share your list of known residual risks."
What does DevShift publish openly? There is no white-label client reference on this site, and this article is not one. What is published is work that shows how we think about isolation. The Relay Desk benchmark gave two AI coding models the same brief for a four-role, multi-tenant incident-intake app: tenant isolation, expiring share links for an insurer with no account, and an auditor limited to cross-tenant aggregates. The brief required a spec first, then the build, then a security note, and the results were then attacked with hand-written bypass tests and a static analysis scan.
The app rated higher enforced isolation inside the database engine through scoped views, so a forgotten tenant predicate raised an error instead of returning rows. The other kept isolation as a convention in one data-access layer, and its own security notes admitted that one forgotten predicate would leak silently. The one real leak found sat in that app's cross-tenant auditor view, which is why operator views should show aggregates only. The benchmark used a local SQLite database, so its mechanism differs from Postgres row-level security, but the principle is the same: fail closed. It is one run per model, rated by DevShift's own review, so read it as a worked example of the test, not as a statistical result or a client track record.
When is a white-label multi-tenant build the wrong move, and what should you do first?
Not every product needs a shared platform with custom domains and per-account metering. Three situations call for stopping first:
- A few clients with heavy, different customization: separate deployments of one codebase may be simpler and safer.
- White-label that only means a logo and colors: if a platform you already pay for covers the branding and isolation you need, use it. A subdomain per client is enough at first.
- Demand that is not yet proven: build the first workflow for one or two clients, but put the foundations in from the first week: tenant id, memberships, an audit log and events that carry the tenant.
The foundations are cheap now and expensive later: retrofitting means adding and backfilling a tenant id in every table, rewriting every query, fixing constraints and retesting every path. Multi-tenancy adds noticeable but bounded work to an MVP. A role editor, per-tenant encryption keys, a self-serve domain screen and a separate-database option can wait, if the foundations allow adding them. What drives the cost of a SaaS build is covered in how much it costs to build a SaaS product.
First step: a one-page tenancy spec
Before any code, write one page that settles six things: what a tenant is and which scopes sit beneath it; which model (pooled, schema or database) applies to each client tier; how hostnames resolve to tenants; the role and permission matrix, including platform roles; the event list with tenant, actor and plan; and the isolation decision in one sentence, where it is enforced and why there. With that page an outside team can estimate the work and be tested against it, and outsourcing SaaS development from idea to launch shows how to run that relationship.
If you want a second pair of eyes, a short call with us can help turn that page into a scoped first version. Building web systems and SaaS, including roles, permissions and data separation, is part of product development at DevShift.
Frequently asked questions
Can fund accounting platforms isolate workflows, APIs and reporting by client?
Yes, when isolation is built into the data, API and reporting layers rather than added as a filter on the screen. Each client gets its own workflow definitions and queues, its own API credentials, rate limits and webhooks, and reports generated from tenant-scoped views with no cross-tenant joins. Ask the vendor how the boundary is enforced in the database and how cross-tenant access is tested, and confirm any regulatory requirements with your own advisers.
Should a white-label SaaS use a shared database or one database per tenant?
If you expect many small clients, start with a shared database and a tenant_id on every table, and use a schema or database per tenant for clients that are regulated, very large or contractually required to be separate. Most products end up hybrid, with a tenant catalog that records where each tenant's data lives so a client can leave the shared pool without the application being rewritten.
How do custom domains work in a white-label SaaS?
The client adds a hostname, proves control by publishing a DNS record the platform generates, and points the hostname at the platform with a CNAME. The platform then issues and renews a TLS certificate automatically and maps the hostname to the tenant in a cached lookup. Apex domains need alias-style DNS support, so most products ask for a subdomain and redirect the bare domain to it.
How do you prevent one tenant from seeing another tenant's data?
Enforce the boundary in the database, not only in code. Resolve the tenant from the hostname, set it as a transaction-local value, and use row-level security policies that return nothing when the tenant is missing. Then carry the same tenant through jobs, caches, files and search, and test with automated cross-tenant attempts. A forgotten filter should produce an error or an empty result, never someone else's rows.
How do you meter usage per account in a multi-tenant product?
Record every event with an event id, the tenant, the actor and the plan in force at the time, then count it once by event id so retries cannot double count. Keep exact metering for billing and limits separate from product analytics, which can be sampled and pseudonymous. Show each client its own usage, and let only platform operators see cross-tenant aggregates, under audited access.
What should a dev shop show to prove it has shipped a white-label B2B SaaS?
A live product it built, plus a walkthrough from hostname to database row: how the tenant is resolved, where isolation is enforced, what happens when a developer forgets a filter, how isolation is tested, how a custom domain is onboarded and how roles and usage are modeled. Slides are not evidence. Ask which parts the firm built itself, and for references you can speak to.
How much does multi-tenancy add to an MVP?
It adds noticeable but bounded work, concentrated in a few foundations: tenant identity on every record, host-based tenant resolution, a membership and role model, database-level isolation, an audit log and usage events. These are cheap in the first weeks and expensive to retrofit. Role editors, per-tenant encryption keys, self-serve domain screens and a separate-database option can usually wait.



