The user management endpoints let administrators manage system accounts. Each user must be linked to an existing employee record (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/15aozzz/Lab-Nova-Salud/llms.txt
Use this file to discover all available pages before exploring further.
id_empleado). Passwords are hashed with SHA-256 via Node’s built-in crypto module before being passed to the stored procedure — plaintext credentials are never persisted.
All routes require a valid JWT in the
Authorization: Bearer <token> header.GET /api/usuarios
Returns the list of all system users. Callssp_get_todos_usuarios. Accepts an optional search term to filter results.
Query parameters
Optional search term filtered server-side by the stored procedure (matched against username or employee name). Omit or pass an empty string to return all users.
Response
200 OK — returns an array of user records.Internal user ID.
Login username.
ID of the linked employee record.
Full name of the linked employee.
Employee role/position (e.g.,
"Administrador", "Cajero").Whether the account is currently active.
Errors
| Status | Condition | Body |
|---|---|---|
500 | Database or server error | { "error": "<message>" } |
Example
Response
POST /api/usuarios
Creates a new user account. The providedpassword is hashed with SHA-256 before being passed to sp_crear_usuario — the plaintext value is never written to the database. Returns the new user’s ID on success.
Request body
Unique login username. The stored procedure will reject duplicate usernames.
Plaintext password. Hashed server-side with SHA-256 before storage.
ID of the employee this account belongs to. Obtain valid IDs from
GET /api/usuarios/empleados.Response
201 CreatedInternal ID of the newly created user account.
Confirmation message (
"Usuario creado exitosamente").Errors
| Status | Condition | Body |
|---|---|---|
400 | Any of username, password, or id_empleado is missing | { "error": "Username, password y empleado son obligatorios" } |
500 | Database error (e.g., duplicate username, invalid employee ID) | { "error": "<message>" } |
To list available employees before creating a user, call
GET /api/usuarios/empleados. This returns all employee records that can be linked to a new account.Example
Response
GET /api/usuarios/buscar
Searches for a specific user by username. Callssp_buscar_usuario. Returns the user record if found, or { "encontrado": false } otherwise.
Query parameters
Exact username to look up.
Response
200 OK — foundtrue when a user with the given username exists.Internal user ID.
Login username.
false. No other fields returned.Errors
| Status | Condition | Body |
|---|---|---|
400 | username query parameter missing | { "error": "El parámetro \"username\" es requerido" } |
500 | Database error | { "error": "<message>" } |
Example
GET /api/usuarios/empleados
Returns the list of all employees available for user account assignment. Callssp_get_empleados. Use this to obtain valid id_empleado values before calling POST /api/usuarios or PUT /api/usuarios/:id.
Parameters
No parameters required.Response
200 OK — returns an array of employee records.Internal employee ID. Pass this as
id_empleado when creating or updating a user.Employee first name(s).
Employee last name(s).
Position/role name (e.g.,
"Administrador", "Cajero").Example
PUT /api/usuarios/:id
Updates an existing user’s username, password, or linked employee. Callssp_actualizar_usuario. If password is omitted, the stored current hash is preserved.
Path parameters
Internal user ID.
Request body
Updated login username.
Updated employee link. Must reference an existing employee.
New password in plaintext. If omitted, the current password hash is preserved unchanged.
Response
200 OKConfirmation message (
"Usuario actualizado exitosamente").Errors
| Status | Condition | Body |
|---|---|---|
400 | username or id_empleado missing | { "error": "Username y empleado son obligatorios" } |
404 | Password omitted and username not found to retrieve existing hash | { "error": "Usuario no encontrado para obtener hash actual" } |
500 | Database error | { "error": "<message>" } |
Example
DELETE /api/usuarios/:id
Deletes a user account permanently. Callssp_eliminar_usuario.
Path parameters
Internal user ID to delete.
Response
200 OKConfirmation message (
"Usuario eliminado exitosamente").Errors
| Status | Condition | Body |
|---|---|---|
500 | Database error | { "error": "<message>" } |
Example
Response