Overview
The User Management API (sgivu-user) provides comprehensive operations for managing users, including CRUD operations, multi-criteria search, status management, and user counts. All endpoints require JWT authentication with specific permissions.
Base URL
https://your-domain.com/v1/users
Create User
Registers a new user in the system with domain validations.
Authentication: Required
Authorization: user:create permission
Request Body
Unique username (no special characters)
Password (must meet strength requirements)
Person information object
National identification number
Array of role IDs to assign
Whether the user account is enabled
{
"username": "jperez",
"password": "SecureP@ss123",
"person": {
"firstName": "Juan",
"lastName": "Pérez",
"nationalId": "1234567890",
"email": "[email protected]",
"phone": "3001234567"
},
"roles": [1],
"enabled": true
}
Response
Response status (success/error)
{
"status": "success",
"message": "Usuario creado exitosamente",
"data": {
"id": 5,
"username": "jperez",
"person": {
"id": 5,
"firstName": "Juan",
"lastName": "Pérez",
"nationalId": "1234567890",
"email": "[email protected]",
"phone": "3001234567"
},
"roles": [
{
"id": 1,
"name": "USER",
"description": "Standard user role"
}
],
"enabled": true,
"createdAt": "2026-03-06T10:30:00",
"updatedAt": "2026-03-06T10:30:00"
}
}
Status Codes
201 Created - User created successfully
400 Bad Request - Invalid input data
401 Unauthorized - Not authenticated
403 Forbidden - Missing user:create permission
Example
curl -X POST https://your-domain.com/v1/users \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"username": "jperez",
"password": "SecureP@ss123",
"person": {
"firstName": "Juan",
"lastName": "Pérez",
"nationalId": "1234567890",
"email": "[email protected]",
"phone": "3001234567"
},
"roles": [1],
"enabled": true
}'
Get User by ID
Retrieves the complete profile of a user.
Authentication: Required
Authorization: user:read permission
Path Parameters
Response
{
"id": 1,
"username": "steven",
"person": {
"id": 1,
"firstName": "Steven",
"lastName": "Rodriguez",
"nationalId": "1234567890",
"email": "[email protected]",
"phone": "3001234567"
},
"roles": [
{
"id": 1,
"name": "ADMIN",
"description": "Administrator role with full permissions"
}
],
"enabled": true,
"createdAt": "2026-01-01T00:00:00",
"updatedAt": "2026-03-01T12:00:00"
}
Status Codes
200 OK - User found
401 Unauthorized - Not authenticated
404 Not Found - User does not exist
Example
curl -X GET https://your-domain.com/v1/users/1 \
-H "Authorization: Bearer YOUR_TOKEN"
List Users (Paginated)
GET /v1/users/page/{page}
Retrieves a paginated list of users (10 per page).
Authentication: Required
Authorization: user:read permission
Path Parameters
Response
{
"content": [
{
"id": 1,
"username": "steven",
"person": {
"firstName": "Steven",
"lastName": "Rodriguez",
"email": "[email protected]"
},
"roles": ["ADMIN"],
"enabled": true
}
],
"pageable": {
"pageNumber": 0,
"pageSize": 10
},
"totalElements": 25,
"totalPages": 3,
"last": false
}
Example
curl -X GET https://your-domain.com/v1/users/page/0 \
-H "Authorization: Bearer YOUR_TOKEN"
Update User
Updates an existing user profile. Users can edit their own profile, or admins can modify any user with user:update permission.
Authentication: Required
Authorization: user:update permission OR own user ID
Path Parameters
Authenticated user ID (injected by Gateway)
Request Body
Person information to update
Array of role IDs (admin only)
Account enabled status (admin only)
{
"person": {
"firstName": "Juan",
"lastName": "Pérez GarcÃa",
"email": "[email protected]",
"phone": "3009876543"
}
}
Response
{
"status": "success",
"message": "Usuario actualizado exitosamente",
"data": {
"id": 5,
"username": "jperez",
"person": {
"firstName": "Juan",
"lastName": "Pérez GarcÃa",
"email": "[email protected]"
},
"updatedAt": "2026-03-06T11:45:00"
}
}
Status Codes
200 OK - User updated successfully
400 Bad Request - Invalid input
401 Unauthorized - Not authenticated
403 Forbidden - Missing permission or not own user
404 Not Found - User does not exist
Example
curl -X PUT https://your-domain.com/v1/users/5 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"person": {
"email": "[email protected]"
}
}'
Delete User
Permanently deletes a user from the system.
Authentication: Required
Authorization: user:delete permission
Path Parameters
Status Codes
204 No Content - User deleted successfully
401 Unauthorized - Not authenticated
403 Forbidden - Missing user:delete permission
404 Not Found - User does not exist
Example
curl -X DELETE https://your-domain.com/v1/users/5 \
-H "Authorization: Bearer YOUR_TOKEN"
Update User Status
PATCH /v1/users/{id}/status
Enables or disables a user account to control access.
Authentication: Required
Authorization: user:update permission
Path Parameters
Request Body
New status (true=enabled, false=disabled)
Response
Example
curl -X PATCH https://your-domain.com/v1/users/5/status \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d 'false'
Get User Counts
Retrieves statistics: total users, active, and inactive.
Authentication: Required
Authorization: user:read permission
Response
{
"total": 25,
"active": 22,
"inactive": 3
}
Example
curl -X GET https://your-domain.com/v1/users/count \
-H "Authorization: Bearer YOUR_TOKEN"
Search Users
Multi-criteria search with optional filters (AND logic).
Authentication: Required
Authorization: user:read permission
Query Parameters
Filter by first or last name (partial match)
Filter by username (partial match)
Response
[
{
"id": 1,
"username": "steven",
"person": {
"firstName": "Steven",
"lastName": "Rodriguez"
},
"roles": ["ADMIN"],
"enabled": true
}
]
Example
curl -X GET "https://your-domain.com/v1/users/search?role=ADMIN&enabled=true" \
-H "Authorization: Bearer YOUR_TOKEN"
Search Users (Paginated)
GET /v1/users/search/page/{page}
Paginated variant of multi-criteria search.
Authentication: Required
Authorization: user:read permission
Path Parameters
Query Parameters
Response
{
"content": [...],
"pageable": {
"pageNumber": 0,
"pageSize": 10
},
"totalElements": 5,
"totalPages": 1
}
Example
curl -X GET "https://your-domain.com/v1/users/search/page/0?size=20&role=USER" \
-H "Authorization: Bearer YOUR_TOKEN"
Internal Endpoints
Get User by Username
GET /v1/users/username/{username}
This endpoint is for internal service-to-service communication only. It requires the X-Internal-Service-Key header and should never be exposed publicly.
Used by the Authorization Server to retrieve user profile (roles/permissions) when issuing JWT tokens.
Authentication: X-Internal-Service-Key header
Path Parameters
Example
curl -X GET https://your-domain.com/v1/users/username/steven \
-H "X-Internal-Service-Key: YOUR_INTERNAL_KEY"