Skip to main content
POST
/
auth
/
register
Register User
curl --request POST \
  --url https://api.example.com/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "nombre": "<string>",
  "email": "<string>",
  "password": "<string>"
}
'
{
  "message": "<string>",
  "usuario": {
    "usuario.id": "<string>",
    "usuario.nombre": "<string>",
    "usuario.email": "<string>",
    "usuario.rol": "<string>"
  },
  "400 Bad Request": {},
  "422 Unprocessable Entity": {}
}
Register a new user with name, email, and password. The user is automatically assigned the “visitante” (visitor) role by default.

Request Body

nombre
string
required
Full name of the user
email
string
required
Valid email address. Must be unique in the system.
password
string
required
User password. Will be securely hashed using bcrypt before storage.

Response

message
string
Confirmation message indicating successful registration
usuario
object
User information object
usuario.id
string
Unique identifier for the created user
usuario.nombre
string
User’s full name
usuario.email
string
User’s email address
usuario.rol
string
User’s role. Default is “visitante”. Possible values: “visitante”, “editor”, “admin”

Example Request

curl -X POST https://api.tesisrutas.com/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "María González",
    "email": "[email protected]",
    "password": "securePassword123"
  }'

Example Response

{
  "message": "Usuario registrado correctamente.",
  "usuario": {
    "id": "507f1f77bcf86cd799439011",
    "nombre": "María González",
    "email": "[email protected]",
    "rol": "visitante"
  }
}

Error Responses

400 Bad Request
error
Returned when validation fails or the email is already registered
{
  "detail": "El email ya está registrado."
}
422 Unprocessable Entity
error
Returned when request body is invalid or missing required fields
{
  "detail": [
    {
      "loc": ["body", "email"],
      "msg": "value is not a valid email address",
      "type": "value_error.email"
    }
  ]
}

Notes

  • Passwords are hashed using bcrypt before being stored in the database
  • All new users receive the “visitante” role by default
  • Email addresses must be unique across the system
  • The user ID is automatically generated upon creation

Build docs developers (and LLMs) love