TENANT ISOLATION

Multi-tenant SaaS

RAIQL 0.17 adds first-class tenant identity and tenant-scoped data access for B2B SaaS applications.

Declare the tenant model

CREATE TENANT ENTITY Tenant;

The compiler creates a tenant identity model with a UUID primary key and unique name.

Scope an entity

CREATE ENTITY Project (
  id UUID PRIMARY,
  name STRING REQUIRED,
  tenantId UUID REQUIRED
);
TENANT Project BY tenantId;

Tenant-scoped generated routes require x-raiql-tenant-id. Reads are filtered, creates assign the tenant server-side, and updates/deletes verify tenant membership before mutation.

API & SDK propagation

Generated OpenAPI operations declare the tenant header and the TypeScript SDK exposes setTenant() so tenant context follows API requests.

CLI template

terminal
raiql init my-saas --template saas

The SaaS template combines PostgreSQL, persisted users, JWT/RBAC, ownership, tenant scoping, OpenAPI, SDK generation and tests.

Continue exploring RAIQLOpen the playground →