Overview
The User Management API provides endpoints for administrators to manage user accounts, assign roles, and control access. Most endpoints require Admin role, with some accessible to Managers.Get All Users
Retrieve all users with pagination and filtering. Access: Private (Admin only)Query Parameters
Page number for pagination
Number of users per page
Filter by role:
Admin, Manager, or WorkerFilter by active status (
true or false)Search by name or email
Response
Get User by ID
Get a single user by ID. Access: Private (Admin only)Response
Create User
Create a new user account. Access: Private (Admin only)Request Body
User’s full name
User’s email address (must be unique)
User’s password
User role:
Admin, Manager, or WorkerExample Request
Example Response
Update User
Update a user’s information. Access: Private (Admin only)Request Body
All fields are optional. Only provided fields will be updated.Updated name
Updated email (must be unique)
Updated role:
Admin, Manager, or WorkerAccount status (true = active, false = deactivated)
Example Request
Example Response
Deactivated users (isActive: false) cannot log in to the system.
Delete User
Delete a user account. Access: Private (Admin only)Response
Get Workers
Get all active workers (for task assignment). Access: Private (Manager/Admin only)Response
Number of active workers
Example Response
This endpoint only returns users with the “Worker” role who have isActive set to true. It’s commonly used to populate task assignment dropdowns.
Get User Statistics
Get user statistics for admin dashboard. Access: Private (Admin only)Response
Example Response
User Roles
| Role | Description | Capabilities |
|---|---|---|
| Admin | Full system access | All operations including user management |
| Manager | Operational management | Inventory management, task management, analytics, view workers |
| Worker | Task execution | View own tasks, update task status, view inventory |
Role-Based Access
| Endpoint | Worker | Manager | Admin |
|---|---|---|---|
| GET /users | ❌ | ❌ | ✅ |
| GET /users/:id | ❌ | ❌ | ✅ |
| POST /users | ❌ | ❌ | ✅ |
| PUT /users/:id | ❌ | ❌ | ✅ |
| DELETE /users/:id | ❌ | ❌ | ✅ |
| GET /users/workers | ❌ | ✅ | ✅ |
| GET /users/stats | ❌ | ❌ | ✅ |