Skip to main content

List Users

Retrieve a paginated list of all users in the system.

Endpoint

GET /usuarios

Query Parameters

page
integer
default:"0"
Page number (zero-based)
size
integer
default:"50"
Number of records per page

Response

content
array
Array of user basic information (UsuarioBasicoDTO)
totalElements
integer
Total number of users
totalPages
integer
Total number of pages
size
integer
Page size
number
integer
Current page number

Example Request

cURL
curl -X GET "http://localhost:8081/comialex/api/integra/usuarios?page=0&size=20" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example Response

{
  "content": [
    {
      "id": 123,
      "username": "jperez",
      "email": "[email protected]",
      "enabled": true,
      "empleadoId": 456
    }
  ],
  "totalElements": 150,
  "totalPages": 8,
  "size": 20,
  "number": 0
}

Get User by ID

Retrieve detailed information for a specific user.

Endpoint

GET /usuarios/{id}

Path Parameters

id
integer
required
User ID

Response

data
object
message
string
Success message: “Usuario encontrado”

Example Request

cURL
curl -X GET http://localhost:8081/comialex/api/integra/usuarios/123 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example Response

{
  "data": {
    "id": 123,
    "username": "jperez",
    "email": "[email protected]",
    "enabled": true,
    "idEmpleado": 456,
    "roles": [
      {
        "id": 1,
        "nombre": "Administrador"
      }
    ]
  },
  "message": "Usuario encontrado",
  "success": true
}

Create User

Create a new user account.

Endpoint

POST /usuarios

Request Body

username
string
required
Username (3-50 characters)
password
string
required
Password (6-100 characters)
email
string
Valid email address
enabled
boolean
default:"true"
Whether the account is active
idEmpleado
integer
required
Associated employee ID
roles
array
Array of role IDs to assign to the user
permissions
array
Set of permission strings

Response

data
boolean
Returns true on success
message
string
Success message: “Usuario creado exitosamente”

Example Request

cURL
curl -X POST http://localhost:8081/comialex/api/integra/usuarios \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "mgarcia",
    "password": "SecurePass123!",
    "email": "[email protected]",
    "enabled": true,
    "idEmpleado": 789,
    "roles": [1, 2]
  }'

Example Response

{
  "data": true,
  "message": "Usuario creado exitosamente",
  "success": true
}

Update User

Update user account details.

Endpoint

PATCH /usuarios/usuario

Request Body

id
integer
required
User ID to update
username
string
New username
email
string
New email address
password
string
New password (if changing)

Response

data
boolean
Returns true on success
message
string
Success message: “Usuario actualizado exitosamente”

Example Request

cURL
curl -X PATCH http://localhost:8081/comialex/api/integra/usuarios/usuario \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id": 123,
    "email": "[email protected]"
  }'

Get User Permissions

Retrieve the permissions assigned to a specific user.

Endpoint

GET /usuarios/{id}/permisos

Path Parameters

id
integer
required
User ID

Response

data
array
Array of permission strings
message
string
Success message: “Permisos obtenidos”

Example Request

cURL
curl -X GET http://localhost:8081/comialex/api/integra/usuarios/123/permisos \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Example Response

{
  "data": [
    "asistencia.ver",
    "asistencia.registrar",
    "empleados.ver",
    "empleados.editar",
    "reportes.generar"
  ],
  "message": "Permisos obtenidos",
  "success": true
}

Update User Permissions

Update the permissions assigned to a user.

Endpoint

PATCH /usuarios/permisos/actualizar

Request Body

userId
integer
required
User ID
permissions
array
required
Array of permission strings to assign

Response

data
string
Returns “OK” on success
message
string
Success message: “Permisos actualizados”

Example Request

cURL
curl -X PATCH http://localhost:8081/comialex/api/integra/usuarios/permisos/actualizar \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": 123,
    "permissions": [
      "asistencia.ver",
      "asistencia.registrar",
      "reportes.generar"
    ]
  }'

Update User Status

Enable or disable a user account.

Endpoint

PATCH /usuarios/{id}/estatus

Path Parameters

id
integer
required
User ID

Query Parameters

activo
boolean
required
True to enable, false to disable

Response

data
string
Returns “OK” on success
message
string
Success message: “Estatus actualizado”

Example Request

cURL
curl -X PATCH "http://localhost:8081/comialex/api/integra/usuarios/123/estatus?activo=false" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Disabling a user account will prevent login but will not invalidate existing JWT tokens. Consider implementing token version invalidation for immediate effect.

Delete User

Delete a user account.

Endpoint

DELETE /usuarios/{id}

Path Parameters

id
integer
required
User ID to delete

Response

data
null
No data returned on success
message
string
Success message: “Usuario eliminado”

Example Request

cURL
curl -X DELETE http://localhost:8081/comialex/api/integra/usuarios/123 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
Deleting a user is a permanent action. Consider disabling the account instead if you need to preserve audit history.

Build docs developers (and LLMs) love