Skip to main content

POST /api/auth/register

Creates a new user account with Supabase Auth and initializes a user profile.

Request body

email
string
required
The user’s email address. Must be a valid, unique email.
password
string
required
The user’s password. Handled by Supabase Auth — minimum length and complexity rules apply.
nombre
string
required
The display name for the user. Cannot be blank, cannot exceed 30 characters, and must be unique (case-insensitive) across all profiles.

Response

200 — Success

message
string
Confirmation string. Value: "Registro exitoso".
user
object
The newly created Supabase Auth user object.

400 — Validation error

Returned when request fields fail validation checks.
error
string
Description of the validation failure. Possible values:
  • "El nombre no puede estar en blanco."nombre is missing or whitespace only.
  • "El nombre no puede exceder los 30 caracteres."nombre exceeds 30 characters.
  • "Ese nombre de usuario ya está en uso. Por favor, elige otro." — the display name is already taken.
  • A Supabase Auth error message — for example, if the email is already registered or the password is too weak.

500 — Server error

error
string
Possible values:
  • "Usuario registrado, pero hubo un error al crear su perfil" — the Auth user was created but writing the profile record failed.
  • "Error interno del servidor" — an unexpected error occurred.
When a 500 with the profile-creation message is returned, the Supabase Auth user has been created but the perfiles record has not. The user will be unable to log in successfully until the profile is created.

Example request

curl --request POST \
  --url https://your-domain.com/api/auth/register \
  --header 'Content-Type: application/json' \
  --data '{
    "email": "[email protected]",
    "password": "contraseña-segura",
    "nombre": "ChefAna"
  }'

Example responses

Success (200)
{
  "message": "Registro exitoso",
  "user": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "email": "[email protected]"
  }
}
Validation error (400)
{
  "error": "Ese nombre de usuario ya está en uso. Por favor, elige otro."
}
Server error (500)
{
  "error": "Error interno del servidor"
}

Build docs developers (and LLMs) love