Reten Docs
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

HeaderRequiredValue
AuthorizationYesBearer <access_token>

Request Body

FieldTypeRequiredDescription
namestringYesTenant name
slugstringYesURL-friendly slug (unique)
adminEmailstringYesEmail for the tenant admin
adminPasswordstringYesPassword for the tenant admin
adminFirstNamestringYesAdmin first name
adminLastNamestringYesAdmin 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

  1. Creates the tenant record in the public schema
  2. Creates (or links) the admin user
  3. Creates PostgreSQL schema tenant_{id}
  4. Runs all tenant migrations on the new schema
  5. Links the admin user to the tenant

Error Responses

StatusDescription
400Validation error
409Slug already exists