nombre_usuario / contrasena pair and are assigned a role of either admin or cajero. Passwords are hashed with bcrypt (10 rounds) before storage and are never returned in any API response.
Soft delete is used throughout. Deleting a user sets
borrado_en to the current timestamp. The record is never physically removed from the database.POST /api/usuarios
Create a new user.
Authentication: Bearer JWT requiredRequired role:
admin
Request body
Full display name. Between 3 and 60 characters.
Unique login username. Between 3 and 30 characters. Only lowercase letters, digits, and underscores are allowed (
^[a-z0-9_]+$). Must be unique across all active users.Plain-text password. Minimum 6 characters. It is hashed with bcrypt before being stored and is never returned.
Role to assign. Accepted values:
admin, cajero.Response
Returns the created user object (201 Created). The contrasena field is excluded.
Unique identifier with the format
usr_<16-char nanoid> (e.g. usr_abc123def456ghi7).Full display name.
Login username.
Assigned role (
admin or cajero).Creation timestamp.
Last update timestamp.
Error codes
| Status | Meaning |
|---|---|
401 | Missing or invalid JWT |
403 | Caller does not have the admin role |
409 | nombre_usuario is already in use by an active user |
Example
GET /api/usuarios
Return all active users.
Authentication: Bearer JWT requiredRequired role:
admin
Request parameters
No parameters.Response
Returns an array of user objects (200 OK), ordered by creado_en ascending. Only records where borrado_en IS NULL are included. The contrasena field is excluded from every item.
Example
GET /api/usuarios/:id
Return a single active user by ID.
Authentication: Bearer JWT requiredRequired role:
admin
Request parameters
The user ID (format:
usr_<nanoid>).Response
Returns the user object (200 OK) without contrasena, or 404 Not Found if the user does not exist or has been soft-deleted.
Example
PUT /api/usuarios/:id
Fully update a user. All body fields are optional; only the fields you send are changed.
Authentication: Bearer JWT requiredRequired role:
admin
Request parameters
The user ID to update.
New full display name. Between 3 and 60 characters.
New login username. Between 3 and 30 characters. Only lowercase letters, digits, and underscores. Must be unique.
New password. Minimum 6 characters. Hashed with bcrypt before storage.
New role. Accepted values:
admin, cajero.Response
Returns the updated user object (200 OK) without contrasena. actualizado_en is always refreshed.
Error codes
| Status | Meaning |
|---|---|
401 | Missing or invalid JWT |
403 | Caller does not have the admin role |
404 | User not found or already deleted |
409 | nombre_usuario is already in use by another active user |
Example
DELETE /api/usuarios/:id
Soft-delete a user.
Authentication: Bearer JWT requiredRequired role:
admin
Request parameters
The user ID to delete.
Response
Returns204 No Content on success. No body is returned.
Error codes
| Status | Meaning |
|---|---|
401 | Missing or invalid JWT |
403 | Caller does not have the admin role |
404 | User not found or already deleted |