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
Name of the organization. Must be 2-255 characters.
Unique URL-friendly identifier for the organization. Must be 2-100 characters, lowercase letters, numbers, and hyphens only.
Admin user’s email address. Must be a valid email format and unique.
Admin user’s password. Minimum 8 characters.
Admin user’s full name. Must be 2-255 characters.
Response
Indicates if the request was successful
User’s unique identifier (UUID)
User’s role (always org_admin for registration)
Organization ID that was created
Array containing the default branch ID
JWT access token for authenticating API requests
JWT refresh token for obtaining new access tokens (valid for 7 days)
Error Responses
Returned when the email address is already registered.{
"success": false,
"error": {
"code": "CONFLICT",
"message": "El email ya está registrado"
}
}
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..."
}
}