An agency signs up for a new SaaS dashboard, uploads its client list and invites two employees. Another agency uses the same application. One API request with a changed record ID must never return the first agency's client list to the second.
This is the central promise of a multi tenant SaaS: customers may share an application, but their data and permissions remain separate. The separation must hold in every route, job and export, including the features the first demo never shows.
Decide where tenant identity comes from
A user's organisation membership should be established through server-side authentication and checked against a permission record. Do not trust a tenantId sent by the browser as proof that the user belongs to that tenant. If a person can switch between two authorised organisations, check the selected organisation against their membership on every request.
Give each customer organisation a stable internal identifier. Link users, projects, invoices, uploaded files and audit records to it where relevant. Define what happens when a user leaves an organisation or an invitation is revoked.
OWASP's Multi Tenant Security Cheat Sheet highlights cross-tenant data leakage, impersonation and broken isolation across application layers. The risk extends beyond one database query.
Enforce the boundary in queries and APIs
For a project detail endpoint, the server should resolve a project only inside the authenticated organisation's scope. Looking up a record globally and filtering it out after loading is fragile. Apply the same rule to updates, deletes, search, pagination, exports and administrative actions.
Review nested resources too. A task may have an authorised project ID but reference a file from another organisation if the file ownership is never checked. An admin role inside one customer organisation is not automatically a platform-wide administrator.
Database row level controls can add another layer where the chosen database supports them, but they need careful configuration and testing. Whether using shared tables, separate schemas or separate databases, write down who sets the tenant context and how it is reset between requests.
Include files, caches and background jobs
An invoice PDF stored outside the main database still needs access control. A long public URL is not an authorisation policy. Cache keys that omit the tenant can serve one organisation's summary to another. Background jobs must carry the correct tenant context and verify it before writing a report or sending a notification.
Test account deletion, ownership transfers and support access. If internal staff need access for troubleshooting, grant it through a narrow, logged process. Avoid a permanent hidden bypass in normal customer routes.
Test with two tenants before onboarding customers
Create two test organisations with similar looking users and records. As a member of tenant A, try to read, edit, list, export and download tenant B's data by changing IDs, query parameters and file paths. Include asynchronous exports and search results. Confirm the API denies access and that error responses do not leak details.
The first release does not need an elaborate microservice architecture. It does need a clear boundary that survives new features. At adityazen, I can review a SaaS data model and its access paths before customer data is added, then turn the findings into a practical build checklist.





