Overview
Asta uses JWT (JSON Web Token) based authentication. After logging in, include the token in theAuthorization header for subsequent requests.
Authorization Header Format
Login
POST /api/auth/login
Authenticate a user and receive a JWT access token.Request Body
The user’s username or email address
The user’s password
Response
JWT token for authenticating subsequent requests. Include in the
Authorization: Bearer <token> header.User information object
Error Responses
- 401 Unauthorized: Invalid username or password
Register
POST /api/auth/register
Create a new user account with theuser role. Registration is only available when multi-user mode is active.
Request Body
Username for the new account (minimum 2 characters)
Password for the new account (minimum 4 characters)
Response
Newly created user information
Error Responses
- 400 Bad Request: Username too short (< 2 characters) or password too short (< 4 characters)
- 403 Forbidden: Registration is not available (multi-user mode not active)
- 409 Conflict: Username already exists
Get Current User
GET /api/auth/me
Retrieve information about the currently authenticated user.Response
Unique user identifier
The user’s username
User role:
"admin" or "user"Change Password
POST /api/auth/change-password
Change the password for the currently authenticated user.Request Body
The user’s current password for verification
The new password to set
Response
Returns
true if password was changed successfullyError Responses
- 401 Unauthorized: Current password is incorrect
- 404 Not Found: User not found
Admin Endpoints
The following endpoints require admin privileges.List Users
GET /api/auth/users
List all users in the system. Requires admin role.Array of user objects
Create User
POST /api/auth/users
Create a new user with a specified role. Requires admin role.Username for the new account
Password for the new account (minimum 4 characters)
User role:
"admin" or "user"Error Responses
- 400 Bad Request: Invalid role or password too short
- 409 Conflict: Username already exists
Delete User
DELETE /api/auth/users/
Delete a user by ID. Requires admin role. You cannot delete yourself.The ID of the user to delete
Error Responses
- 400 Bad Request: Cannot delete yourself
- 404 Not Found: User not found
Reset User Password
PUT /api/auth/users//reset-password
Reset another user’s password. Requires admin role.The ID of the user whose password to reset
The new password to set (minimum 4 characters)
Error Responses
- 400 Bad Request: Password too short
- 404 Not Found: User not found