List Users
Get all users with optional role filtering.
curl -X GET "https://your-api.com/api/user/getUsers?role_id=2" \
-H "Authorization: Bearer YOUR_TOKEN"
Query Parameters
Filter users by role ID (optional)
Response
{
"success": true,
"users": [
{
"user_id": 1,
"username": "jperez",
"email": "[email protected]",
"first_name": "Juan",
"last_name": "Pérez",
"department_id": 2,
"mobile_number": "+50212345678",
"is_active": true,
"role_name": "Technician",
"created_at": "2025-01-15T08:30:00Z"
}
]
}
Create User
Create a new user with complete profile information.
Requires authentication and admin role. Only authenticated admins can create users.
curl -X POST https://your-api.com/api/user/createUser \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"username": "jsmith",
"email": "[email protected]",
"password": "SecurePass123!",
"first_name": "John",
"last_name": "Smith",
"mobile_number": "+50298765432",
"department_id": 3,
"role_id": 2,
"document_type_id": 1,
"id_document_number": "001-150290-1234X",
"license_type_id": 2,
"license_number": "LIC-2024-5678",
"license_expiration_date": "2026-12-31"
}'
Request Body
Unique username (will be checked for duplicates)
User’s email address (must be unique)
User’s password (will be hashed before storage)
Date of birth (YYYY-MM-DD format)
Role assignment (defines permissions)
Type of identification document
Identification document number
Tax identification number
Professional license type (for technicians)
Year license was first issued
License expiration date (YYYY-MM-DD)
Response
{
"success": true,
"user": {
"user_id": 15,
"username": "jsmith",
"email": "[email protected]",
"first_name": "John",
"last_name": "Smith",
"is_active": true,
"created_at": "2026-03-03T10:45:00Z"
}
}
Error Responses
{
"success": false,
"error": "Usuario o correo ya existente"
}
Missing Required Fields (400)
{
"success": false,
"error": "username, email y password son obligatorios"
}
Deactivate User
Deactivate a user account (soft delete). User will no longer be able to log in.
Requires authentication. Users cannot deactivate their own account.
curl -X POST https://your-api.com/api/user/deactivate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"user_id": 15,
"reason": "Employee left the company"
}'
Request Body
ID of the user to deactivate
Optional reason for deactivation (for audit purposes)
Response
{
"success": true,
"data": {
"user_id": 15,
"deactivated_at": "2026-03-03T11:00:00Z",
"deactivated_by": 1,
"reason": "Employee left the company"
},
"alreadyInactive": false
}
Error Responses
Self-Deactivation Attempt (400)
{
"success": false,
"error": "No puedes desactivar tu propio usuario"
}
Get User Permissions
Retrieve all module permissions for a specific user.
curl -X POST https://your-api.com/api/user/getUserPermissions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"user_id": 1}'
Request Body
User ID to fetch permissions for
Response
{
"success": true,
"permissions": [
{
"module_id": 1,
"module_name": "Dashboard",
"module_path": "/dashboard",
"can_view": true,
"can_edit": true,
"can_delete": false,
"is_blocked": false
},
{
"module_id": 2,
"module_name": "Service Requests",
"module_path": "/requests",
"can_view": true,
"can_edit": true,
"can_delete": true,
"is_blocked": false
}
]
}
Update User Permissions
Update module permissions for a user.
curl -X POST https://your-api.com/api/user/updateUserPermissions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"user_id": 1,
"permissions": [
{
"module_id": 1,
"can_view": true,
"can_edit": false,
"can_delete": false
},
{
"module_id": 2,
"can_view": true,
"can_edit": true,
"can_delete": false
}
]
}'
Request Body
User ID to update permissions for
Array of permission objects
Response
Update Public Name
Update a user’s public display name (used in quotes and PDFs).
curl -X PUT https://your-api.com/api/user/15/public-name \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"public_name": "Dr. John Smith, PE"}'
Path Parameters
Request Body
Public display name (can be null to clear)
Response
{
"success": true,
"user": {
"user_id": 15,
"public_name": "Dr. John Smith, PE"
}
}
Logout
Mark a user session as logged out.
curl -X POST https://your-api.com/api/user/logout \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"access_id": 12345}'
Request Body
Access log ID from login response
Response