POST /auth/login
Authenticates a user and returns a JWT token along with user permissions and access rights.
Request
The username for authentication
Request Example
curl -X POST https://api.example.com/auth/login \
-H "Content-Type: application/json" \
-d '{
"userName": "admin",
"password": "securepassword123"
}'
Response
JWT authentication token for subsequent API requests
The authenticated user’s username
List of access permissions and menu items available to the userDisplay name of the access/menu item
URL path for the access item
Icon identifier for UI display
Display order for menu items
Response Example
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"userName": "admin",
"accesos": [
{
"nombre": "Dashboard",
"url": "/dashboard",
"icono": "dashboard-icon",
"orden": 1
},
{
"nombre": "Ventas",
"url": "/ventas",
"icono": "sales-icon",
"orden": 2
}
]
}
Status Codes
200 OK - Authentication successful
400 Bad Request - Invalid credentials or missing required fields
POST /auth/validate
Validates a JWT token and returns token information if valid.
Request
The JWT token to validate
Request Example
curl -X POST "https://api.example.com/auth/validate?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
Response
Response Example
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Status Codes
200 OK - Token is valid
400 Bad Request - Token is invalid or expired
POST /auth/create
Creates a new authentication user account.
Request
Username for the new account
Password for the new account
Request Example
curl -X POST https://api.example.com/auth/create \
-H "Content-Type: application/json" \
-d '{
"userName": "newuser",
"password": "securepass456"
}'
Response
Unique identifier for the created auth user
The encrypted password (hashed)
Response Example
{
"id": 5,
"userName": "newuser",
"password": "$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy"
}
Status Codes
200 OK - User created successfully
400 Bad Request - Username already exists or validation failed
JWT Token Usage
After successful login, include the JWT token in the Authorization header for protected endpoints:
curl https://api.example.com/protected-endpoint \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."