Manage user authentication, token generation, and password reset operations.
/api/auth
The Authentication API handles all user authentication operations including login, logout, token generation, and password recovery. All authentication endpoints return JWT tokens for subsequent API requests.
Gets user access token from Basic Authentication credentials.
| Header | Value | Required |
|---|---|---|
| Authorization | Basic base64(username:password) | Yes |
| Content-Type | application/json | No |
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "refresh_token_here",
"expiresIn": 3600,
"tokenType": "Bearer"
}
Logs out user by invalidating refresh token.
{
"refreshToken": "refresh_token_here"
}
{
"success": true,
"message": "Logged out successfully"
}
Initiates password reset and sends email with reset link.
{
"email": "user@example.com"
}
{
"success": true,
"message": "Password reset link sent to email"
}
Resets user password using reset token received via email.
{
"resetToken": "token_from_email",
"newPassword": "new_secure_password"
}
{
"success": true,
"message": "Password reset successfully"
}
Gets access token for specified user (Admin only).
| Parameter | Type | Description |
|---|---|---|
| userId | integer | User ID |
| username | string | Username |
{
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"userId": 123,
"username": "john_doe",
"expiresIn": 3600
}
Gets access token scoped to specific account.
| Parameter | Type | Description |
|---|---|---|
| accountId | integer | Account ID (optional) |
{
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"accountId": 456,
"accountName": "Acme Corp",
"expiresIn": 3600
}
Obtains new access token using refresh token.
{
"refreshToken": "refresh_token_here"
}
{
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 3600
}
Gets access token from password reset code.
| Parameter | Type | Description |
|---|---|---|
| code | string | Transient token code from email |
{
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
"expiresIn": 1800
}
{
"code": "INVALID_CREDENTIALS",
"message": "Invalid username or password",
"timestamp": "2026-06-02T10:30:00Z"
}
| Code | HTTP Status | Description |
|---|---|---|
| INVALID_CREDENTIALS | 401 | Invalid username or password |
| USER_NOT_FOUND | 404 | User does not exist |
| TOKEN_EXPIRED | 401 | Token has expired |
| INVALID_TOKEN | 401 | Token is invalid or malformed |
| WEAK_PASSWORD | 400 | Password does not meet requirements |