Multi-tenancy

Multi-tenant from the first request

AALY is the platform for building a multi-tenant SaaS with your AI coding agent. Each customer (called a tenant) gets a private space, and AALY keeps their data apart on every request, below the API. There is no row-level security policy to write and no isolation rule for a person or an agent to forget on a new screen.

Why this fails quietly

On a conventional backend, isolation is something you remember to do. A filter in a query, a policy on a table, a check before a write. Each one is correct until the day one of them is missing, and a missing one does not fail loudly. The table works, the app works, the tests pass. The only signal is a customer reading another customer's data.

✕Tenant filter dropped from /orders during a refactor
✕Auth middleware skipped on 2 of 6 new routes
✕No ownership check before PATCH /invoices/:id
✕RLS enabled on the table, but no policy written against it
✕A policy that matches every row, which looks exactly like one that works

That is survivable when a human adds a table every few weeks and reviews the migration. It is much less survivable when an agent adds one on request, several times a day. Creating the table is one call. Enabling isolation and writing a correct rule against the right claim is a second thing that has to not be skipped, and skipping it looks exactly like success.

What AALY does instead

Tenancy is a property of the project rather than a rule attached to each table. Scoping itself needs no configuration at all. The only setting is who may sign up, and for a self-serve product where every customer gets their own space, this is the whole of it:

{ "project": "helpdesk", "multiTenant": true, "publicSignup": true }

From there, every record belongs to a tenant and every request is answered within one. The same request under two customers' logins:

Tenant A's token
GET /orders Found tenant A's orders
GET /orders/ORD-9f21 Found belongs to tenant A
Tenant B's token
GET /orders Found tenant B's orders
GET /orders/ORD-9f21 Not found same as an id that never existed

Tenant B doesn't get “forbidden”. It gets the same answer as for an id that never existed, so it can't even learn the record is there. There is no query you can write that returns another tenant's row, because you do not write the query. AALY serves the API from your definition, so the isolation lives in the layer answering the request, not in code you own and have to keep correct.

Two tenants before you start

Every new project is created with two tenants. The test tenant is closed to sign-up and starts with one user, test@example.com; it is where your agent seeds sample data and checks each rule against that data. The live tenant is named after the project and its first user is you, the person who created it. Sample data never goes near it. The test tenant is free and doesn't count toward your plan's tenants; the live tenant counts like any other.

Both sit in the same project, so they share the data model, the Functions and the frontend. Your agent proves each change with sample data in the test tenant, and your real customers' data is never used for checks.

Who can join which tenant

Your agent asks about this in plain words during discovery, because the tenancy model is one of the decisions that is hard to change later. The rules:

Invite only (the default)

Sign-up is off. Nobody can register themselves; you or your staff add people from inside the app, and they set a password with "Forgot password".

One business, open sign-up

With sign-up turned on for a single-tenant project and its live tenant open, everyone who signs up joins that business, for as long as it stays open.

Several businesses you run

Your agent creates a live tenant for each, with its own first user. To let people join one, that tenant is opened and its members get a sign-up link that names it.

A product others sign up for

With the project set to multi-tenant and sign-up on, every sign-up gets a brand-new tenant of its own, closed to everyone else.

The test tenant

Never joinable by sign-up, under any setting.

Tenants are platform records, managed through your agent's MCP tools. A project's own API has no route for creating or listing them, so an app user can't make one by calling it. Tenants and sign-up in the docs →

Staff, members and other roles

Inside a tenant, your agent adds the roles your app needs. Each user gets a role field, and a rule like “only staff can add classes” becomes a short Function that runs on the server before the request. The build method makes this routine: your agent checks each rule against sample data, and the results go into the test report.

Why there is no policy to get wrong

AALY generates no backend code. Your agent writes a definition: entities, fields, relationships, rules. AALY serves the API from it. There is no controller to review, no auth middleware to audit, and no tenant filter that a model may or may not have remembered on this particular run.

This is also why a schema change stays cheap. Add a field and the contract updates; every client keeps working, because there is no generated backend in anyone's repository to fall out of sync with it. The cost of the tenth change looks like the cost of the first.

Check the backend you have now

If you are on Postgres or Supabase today, isolation depends on row-level security being switched on for each table and a policy being written against it. Both steps are per table, and a table that missed them answers to anyone holding the anon key.

Paste your schema and see which tables are exposed → It runs entirely in your browser. Nothing is uploaded.

The full Supabase comparison →

Questions people ask

How do I build a multi-tenant SaaS with an AI coding agent?
Connect Claude Code, Cursor, Codex or another MCP client to AALY and describe your product. Your agent sets the project to multi-tenant with sign-up on, so every customer who signs up gets a private tenant of their own, then builds the screens, checks each rule against sample data and publishes the app at name.aaly.cloud.
Do I need to write row-level security policies on AALY?
No. AALY scopes every read and write to the caller's tenant in the layer that answers the request. There are no per-table policies to write, so a new table or screen is isolated from the moment it exists.
Can one tenant see another tenant's data?
No. A login belongs to one tenant, and a request for another tenant's record comes back as not found, the same answer as for an id that never existed. No query or setting widens the scope.
Can I build a single-business app, not just a SaaS?
Yes. A project can serve one business, with invite-only or open sign-up into its live tenant, or several businesses you run, each with its own live tenant. Multi-tenant sign-up is one option among these, chosen with you during discovery.
Do test tenants count toward my plan?
No. Every project's test tenant is free and never counts toward your plan's tenants. The project's live tenant counts like any other.

Tenant isolation is on in every project, on every plan.

Plans differ in how many customers (tenants) they carry, never in whether isolation applies. Solo: first 3 months free, then $10/mo · 100k requests+events/mo · 2 projects · 10 customers · 4 GB. Test customers are free and never count.

Start building