Skip to main content
POST
/
api
/
auth
/
login
Login
curl --request POST \
  --url https://api.example.com/api/auth/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "NombreUsuario": "<string>",
  "password": "<string>"
}
'
{
  "Token": "<string>",
  "Flag": true,
  "Message": "<string>"
}

Description

Authenticates a user with username and password credentials. Returns a JWT token valid for 2 hours upon successful authentication.

Authentication

No authentication required (public endpoint).

Request Body

NombreUsuario
string
required
Username for authentication. Maximum length: 100 characters.
password
string
required
User’s password.

Response

Token
string
JWT token for authenticating subsequent requests. Valid for 2 hours.
Flag
boolean
Indicates successful authentication. Returns true on success.
Message
string
Status message. Returns “Login successful” on success or error message on failure.

Examples

Successful Login

curl -X POST https://api.example.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "NombreUsuario": "admin",
    "password": "SecurePassword123"
  }'

Failed Login

curl -X POST https://api.example.com/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "NombreUsuario": "admin",
    "password": "WrongPassword"
  }'

JWT Token Claims

The generated JWT token includes the following claims:
  • Name: User’s username (NombreUsuario)
  • Role: User’s role (Rol)
  • JTI: Unique token identifier (GUID)

Token Configuration

  • Expires: 2 hours from issuance
  • Algorithm: HMAC SHA256
  • Issuer: Configured in JWT:Issuer
  • Audience: Configured in JWT:Audience

Build docs developers (and LLMs) love