Skip to main content
POST
/
api
/
auth
/
login
Login User
curl --request POST \
  --url https://api.example.com/api/auth/login
{
  "message": "Inicio de sesión exitoso",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Authenticates a user and returns a JWT token for accessing protected endpoints.

Request Body

Response

message
string
Success message confirming login.
token
string
JWT authentication token valid for 1 hour. Include this token in the Authorization header as Bearer <token> for protected endpoints.

Response Examples

{
  "message": "Inicio de sesión exitoso",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Example Request

cURL
curl -X POST https://api.example.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123"
  }'

Notes

  • The JWT token expires after 1 hour
  • The token contains the user’s ID and role
  • An audit log entry is created upon successful login
  • Use the returned token in the Authorization header: Authorization: Bearer <token>

Build docs developers (and LLMs) love