Get All Users
Retrieve a list of users with pagination, filtering, and sorting.Authentication Required: YesRoles: admin, manager, cashier
Query Parameters
Search by username or email
Filter by user role: admin, manager, or cashier
Filter by account status: active, deleted, or all
Sort by column: created_at or username
Sort direction: asc or desc
Response
Example
curl -X GET "https://localhost:8080/api/v1/users?page=1&limit=10&role=cashier" \
-H "Cookie: access_token=YOUR_TOKEN"
{
"message": "Users retrieved successfully",
"data": {
"users": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "cashier1",
"email": "[email protected]",
"role": "cashier",
"is_active": true,
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"current_page": 1,
"per_page": 10,
"total_data": 1,
"total_page": 1
}
}
}
Get User by ID
Retrieve detailed profile for a specific user by their ID.Authentication Required: YesRoles: admin, manager
Path Parameters
Response
Example
curl -X GET https://localhost:8080/api/v1/users/550e8400-e29b-41d4-a716-446655440000 \
-H "Cookie: access_token=YOUR_TOKEN"
Create User
Create a new user account.Authentication Required: YesRoles: admin
Request Body
Username (3-50 characters)
Email address (max 100 characters)
Password (6-100 characters)
User role: admin, manager, or cashier
Account active status (default: true)
Response
Created user profile information
Example
curl -X POST https://localhost:8080/api/v1/users \
-H "Content-Type: application/json" \
-H "Cookie: access_token=YOUR_TOKEN" \
-d '{
"username": "newcashier",
"email": "[email protected]",
"password": "securepass123",
"role": "cashier",
"is_active": true
}'
{
"message": "User created successfully",
"data": {
"id": "650e8400-e29b-41d4-a716-446655440001",
"username": "newcashier",
"email": "[email protected]",
"role": "cashier",
"is_active": true,
"created_at": "2024-03-03T12:00:00Z"
}
}
Update User
Update details of an existing user account.Authentication Required: YesRoles: admin
Path Parameters
Request Body
Username (3-50 characters)
Email address (max 100 characters)
User role: admin, manager, or cashier
Response
Updated user profile information
Example
curl -X PUT https://localhost:8080/api/v1/users/650e8400-e29b-41d4-a716-446655440001 \
-H "Content-Type: application/json" \
-H "Cookie: access_token=YOUR_TOKEN" \
-d '{
"email": "[email protected]",
"is_active": false
}'
Toggle User Status
Toggle the is_active status of a user.Authentication Required: YesRoles: admin
Path Parameters
Response
Example
curl -X POST https://localhost:8080/api/v1/users/650e8400-e29b-41d4-a716-446655440001/toggle-status \
-H "Cookie: access_token=YOUR_TOKEN"
{
"message": "User status toggled successfully"
}
Delete User
Hard delete a user from the system by their ID.Authentication Required: YesRoles: admin
Path Parameters
Response
Example
curl -X DELETE https://localhost:8080/api/v1/users/650e8400-e29b-41d4-a716-446655440001 \
-H "Cookie: access_token=YOUR_TOKEN"
{
"message": "User deleted successfully"
}