---
title: Tenant
description: Tenant protocol schemas
---

{/* ⚠️  AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs go in content/docs/guides/. */}

Tenant Schema (Multi-Tenant Architecture)

Defines the tenant/tenancy model for ObjectStack SaaS deployments.

Supports different levels of data isolation to meet varying security,

performance, and compliance requirements.

Isolation Levels:

- shared_schema: All tenants share the same database and schema (row-level isolation)

- isolated_schema: Tenants have separate schemas within a shared database

- isolated_db: Each tenant has a completely separate database

<Callout type="info">
**Source:** `packages/spec/src/system/tenant.zod.ts`
</Callout>

## TypeScript Usage

```typescript
import { DatabaseLevelIsolationStrategy, DatabaseProvider, LevelIsolationStrategySchema, QuotaEnforcementResult, RowLevelIsolationStrategy, Tenant, TenantConnectionConfig, TenantIsolationConfig, TenantIsolationLevel, TenantQuota, TenantSecurityPolicy, TenantUsage } from '@objectstack/spec/system';
import type { DatabaseLevelIsolationStrategy, DatabaseProvider, LevelIsolationStrategy, QuotaEnforcementResult, RowLevelIsolationStrategy, Tenant, TenantConnectionConfig, TenantIsolationConfig, TenantIsolationLevel, TenantQuota, TenantSecurityPolicy, TenantUsage } from '@objectstack/spec/system';

// Validate data
const result = DatabaseLevelIsolationStrategy.parse(data);
```

---

## DatabaseLevelIsolationStrategy

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **strategy** | `string` | ✅ | Database-level isolation strategy |
| **database** | `Object` | optional | Database configuration |
| **connectionPool** | `Object` | optional | Connection pool configuration |
| **backup** | `Object` | optional | Backup configuration |
| **encryption** | `Object` | optional | Encryption configuration |


---

## DatabaseProvider

Database provider for tenant data

### Allowed Values

* `turso`
* `postgres`
* `memory`


---

## LevelIsolationStrategySchema

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **strategy** | `string` | ✅ | Schema-level isolation strategy |
| **schema** | `Object` | optional | Schema configuration |
| **migrations** | `Object` | optional | Migration configuration |
| **performance** | `Object` | optional | Performance settings |


---

## QuotaEnforcementResult

Quota enforcement check result

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **allowed** | `boolean` | ✅ | Whether the operation is within quota |
| **exceededQuota** | `string` | optional | Name of the exceeded quota |
| **currentUsage** | `number` | optional | Current usage value |
| **limit** | `number` | optional | Quota limit |
| **message** | `string` | optional | Human-readable quota message |


---

## RowLevelIsolationStrategy

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **strategy** | `string` | ✅ | Row-level isolation strategy |
| **database** | `Object` | optional | Database configuration |
| **performance** | `Object` | optional | Performance settings |


---

## Tenant

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **id** | `string` | ✅ | Unique tenant identifier |
| **name** | `string` | ✅ | Tenant display name |
| **isolationLevel** | `Enum<'shared_schema' \| 'isolated_schema' \| 'isolated_db'>` | ✅ |  |
| **databaseProvider** | `Enum<'turso' \| 'postgres' \| 'memory'>` | optional | Database provider |
| **connectionConfig** | `Object` | optional | Database connection config |
| **provisioningStatus** | `Enum<'provisioning' \| 'active' \| 'suspended' \| 'failed' \| 'destroying'>` | optional | Current provisioning lifecycle status |
| **plan** | `Enum<'free' \| 'pro' \| 'enterprise'>` | optional | Subscription plan |
| **customizations** | `Record<string, any>` | optional | Custom configuration values |
| **quotas** | `Object` | optional |  |


---

## TenantConnectionConfig

Tenant database connection configuration

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **url** | `string` | ✅ | Database connection URL |
| **authToken** | `string` | optional | Database auth token (encrypted at rest) |
| **group** | `string` | optional | Turso database group name |


---

## TenantIsolationConfig

### Union Options

This schema accepts one of the following structures:

#### Option 1

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **strategy** | `string` | ✅ | Row-level isolation strategy |
| **database** | `Object` | optional | Database configuration |
| **performance** | `Object` | optional | Performance settings |

---

#### Option 2

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **strategy** | `string` | ✅ | Schema-level isolation strategy |
| **schema** | `Object` | optional | Schema configuration |
| **migrations** | `Object` | optional | Migration configuration |
| **performance** | `Object` | optional | Performance settings |

---

#### Option 3

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **strategy** | `string` | ✅ | Database-level isolation strategy |
| **database** | `Object` | optional | Database configuration |
| **connectionPool** | `Object` | optional | Connection pool configuration |
| **backup** | `Object` | optional | Backup configuration |
| **encryption** | `Object` | optional | Encryption configuration |

---


---

## TenantIsolationLevel

### Allowed Values

* `shared_schema`
* `isolated_schema`
* `isolated_db`


---

## TenantQuota

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **maxUsers** | `integer` | optional | Maximum number of users |
| **maxStorage** | `integer` | optional | Maximum storage in bytes |
| **apiRateLimit** | `integer` | optional | API requests per minute |
| **maxObjects** | `integer` | optional | Maximum number of custom objects |
| **maxRecordsPerObject** | `integer` | optional | Maximum records per object |
| **maxDeploymentsPerDay** | `integer` | optional | Maximum deployments per day |
| **maxStorageBytes** | `integer` | optional | Maximum storage in bytes |


---

## TenantSecurityPolicy

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **encryption** | `Object` | optional | Encryption requirements |
| **accessControl** | `Object` | optional | Access control requirements |
| **compliance** | `Object` | optional | Compliance requirements |


---

## TenantUsage

Current tenant resource usage

### Properties

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **currentObjectCount** | `integer` | ✅ | Current number of custom objects |
| **currentRecordCount** | `integer` | ✅ | Total records across all objects |
| **currentStorageBytes** | `integer` | ✅ | Current storage usage in bytes |
| **deploymentsToday** | `integer` | ✅ | Deployments executed today |
| **currentUsers** | `integer` | ✅ | Current number of active users |
| **apiRequestsThisMinute** | `integer` | ✅ | API requests in the current minute |
| **lastUpdatedAt** | `string` | optional | Last usage update time |


---

