Reten Docs

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"
  }'
const response = await fetch("https://api.reten.ai/api/tenant/setup", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    name: "Acme Corp",
    slug: "acme-corp",
    adminEmail: "admin@acme.com",
    adminPassword: "SecurePass123!",
    adminFirstName: "Acme",
    adminLastName: "Admin",
  }),
});
const tenant = await response.json();
import requests

response = requests.post(
    "https://api.reten.ai/api/tenant/setup",
    headers={"Authorization": "Bearer <token>"},
    json={
        "name": "Acme Corp",
        "slug": "acme-corp",
        "adminEmail": "admin@acme.com",
        "adminPassword": "SecurePass123!",
        "adminFirstName": "Acme",
        "adminLastName": "Admin",
    },
)
tenant = response.json()

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