Skip to main content

Get All Users

Retrieve a list of users with pagination, filtering, and sorting.Authentication Required: YesRoles: admin, manager, cashier

Query Parameters

page
integer
default:"1"
Page number
limit
integer
default:"10"
Items per page
Search by username or email
role
string
Filter by user role: admin, manager, or cashier
is_active
boolean
Filter by active status
status
string
Filter by account status: active, deleted, or all
sortBy
string
Sort by column: created_at or username
sortOrder
string
Sort direction: asc or desc

Response

message
string
Success message
data
object
users
array
Array of user objects
pagination
object
current_page
integer
Current page number
per_page
integer
Items per page
total_data
integer
Total number of users
total_page
integer
Total number of pages

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

id
string
required
User ID (UUID format)

Response

message
string
Success message
data
object
User profile information

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
string
required
Username (3-50 characters)
email
string
required
Email address (max 100 characters)
password
string
required
Password (6-100 characters)
role
string
required
User role: admin, manager, or cashier
is_active
boolean
Account active status (default: true)

Response

message
string
Success message
data
object
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

id
string
required
User ID (UUID format)

Request Body

username
string
Username (3-50 characters)
email
string
Email address (max 100 characters)
role
string
User role: admin, manager, or cashier
is_active
boolean
Account active status

Response

message
string
Success message
data
object
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

id
string
required
User ID (UUID format)

Response

message
string
Success message

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

id
string
required
User ID (UUID format)

Response

message
string
Success message

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"
}

Build docs developers (and LLMs) love