Skip to main content

POST /api/auth/login

Authenticates a user with their username and password. Returns a signed JWT access token and the user’s profile data. Authentication: Not required

Request

Headers

HeaderValueRequired
Content-Typeapplication/jsonYes

Body

nombre_usuario
string
required
The user’s login name. Must be between 3 and 30 characters.
contrasena
string
required
The user’s password. Must be at least 6 characters.

Response

Success (200)

access_token
string
A signed JWT to include in subsequent requests as Bearer <token>.
usuario
object
The authenticated user’s profile.

Error responses

StatusDescription
401Invalid credentials — username not found or password incorrect

Example

curl -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"nombre_usuario": "admin", "contrasena": "Admin123!"}'
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "usuario": {
    "id": "usr_1234567890",
    "nombre": "Administrador",
    "nombre_usuario": "admin",
    "rol": "admin"
  }
}

Build docs developers (and LLMs) love