POST /api/auth/register
Registers a new user in the system and returns a JWT authentication token.Endpoint
Request Body
User’s full name
- Minimum length: 2 characters
- Will be trimmed of whitespace
User’s email address
- Must be a valid email format
- Must be unique (not already registered)
- Will be normalized to lowercase
User’s password
- Minimum length: 6 characters
- Will be hashed before storage using bcrypt
Response Fields
Indicates if the registration was successful
Success message: “Usuario registrado exitosamente”
Registration result data
Response Examples
Example Request
Error Codes
| Code | Message | Cause |
|---|---|---|
400 | El email ya está registrado | The email is already in use |
400 | Errores de validación | Required fields missing or invalid format |
500 | Error interno del servidor | Database error or other unexpected error |
POST /api/auth/login
Authenticates an existing user and returns a JWT token.Endpoint
Request Body
User’s email address
- Must be a valid email format
- Will be normalized to lowercase
User’s password
- Must match the password set during registration
Response Fields
Indicates if the login was successful
Success message: “Login exitoso”
Login result data
Response Examples
Example Request
Error Codes
| Code | Message | Cause |
|---|---|---|
401 | Credenciales inválidas | Email not found or incorrect password |
400 | Errores de validación | Required fields missing or invalid format |
500 | Error interno del servidor | Database error or other unexpected error |
Using the Token
After successful registration or login, use the returned token in the Authorization header for protected endpoints:JWT_EXPIRES_IN environment variable).