Skip to main content

POST /api/auth/register

Register a new organization with an admin user. This endpoint creates:
  • A new organization
  • An admin user account
  • A default branch (“Sede Principal”)
  • Links the user to the default branch

Request Body

organizationName
string
required
Name of the organization. Must be 2-255 characters.
slug
string
required
Unique URL-friendly identifier for the organization. Must be 2-100 characters, lowercase letters, numbers, and hyphens only.
email
string
required
Admin user’s email address. Must be a valid email format and unique.
password
string
required
Admin user’s password. Minimum 8 characters.
name
string
required
Admin user’s full name. Must be 2-255 characters.

Response

success
boolean
required
Indicates if the request was successful
data
object
user
object
id
string
User’s unique identifier (UUID)
email
string
User’s email address
name
string
User’s full name
role
string
User’s role (always org_admin for registration)
organizationId
string
Organization ID that was created
branches
array
Array containing the default branch ID
accessToken
string
JWT access token for authenticating API requests
refreshToken
string
JWT refresh token for obtaining new access tokens (valid for 7 days)

Error Responses

409 Conflict - Email
Returned when the email address is already registered.
{
  "success": false,
  "error": {
    "code": "CONFLICT",
    "message": "El email ya está registrado"
  }
}
409 Conflict - Slug
Returned when the organization slug already exists.
{
  "success": false,
  "error": {
    "code": "CONFLICT",
    "message": "El slug de organización ya existe"
  }
}

Example Request

curl -X POST https://api.restai.com/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "organizationName": "Mi Restaurante",
    "slug": "mi-restaurante",
    "email": "[email protected]",
    "password": "securepassword123",
    "name": "María García"
  }'

Example Response

{
  "success": true,
  "data": {
    "user": {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "email": "[email protected]",
      "name": "María García",
      "role": "org_admin",
      "organizationId": "123e4567-e89b-12d3-a456-426614174001",
      "branches": ["123e4567-e89b-12d3-a456-426614174002"]
    },
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

Build docs developers (and LLMs) love