Tenants
Setup Tenant
Create a new tenant with its own database schema.
POST /api/tenant/setup
Create a new tenant, provision a dedicated PostgreSQL schema, run tenant migrations, and create an admin user for the tenant.
Auth: Required — CREATE_TENANT permission
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer <access_token> |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Tenant name |
slug | string | Yes | URL-friendly slug (unique) |
adminEmail | string | Yes | Email for the tenant admin |
adminPassword | string | Yes | Password for the tenant admin |
adminFirstName | string | Yes | Admin first name |
adminLastName | string | Yes | Admin last name |
Example
curl -X POST https://api.reten.ai/api/tenant/setup \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"slug": "acme-corp",
"adminEmail": "admin@acme.com",
"adminPassword": "SecurePass123!",
"adminFirstName": "Acme",
"adminLastName": "Admin"
}'import axios from 'axios';
const response = await axios.post(
'https://api.reten.ai/api/tenant/setup',
{
name: 'Acme Corp',
slug: 'acme-corp',
adminEmail: 'admin@acme.com',
adminPassword: 'SecurePass123!',
adminFirstName: 'Acme',
adminLastName: 'Admin',
},
{
headers: {
Authorization: 'Bearer <token>',
},
}
);Response 201 Created
{
"id": "660e8400-e29b-41d4-a716-446655440000",
"name": "Acme Corp",
"slug": "acme-corp"
}What happens on setup
- Creates the tenant record in the public schema
- Creates (or links) the admin user
- Creates PostgreSQL schema
tenant_{id} - Runs all tenant migrations on the new schema
- Links the admin user to the tenant
Error Responses
| Status | Description |
|---|---|
400 | Validation error |
409 | Slug already exists |