TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt
Use this file to discover all available pages before exploring further.
/usuarios/ endpoints manage CafeteriaPM staff accounts. Every staff member — whether a waiter, kitchen worker, cashier, or administrator — is represented as a user with an assigned role that controls which endpoints they can access. All operations except GET /usuarios/me require the admin role. Passwords are bcrypt-hashed server-side before storage and are never returned in any response payload.
GET /usuarios/roles — List Available Roles
Required role:admin
Returns the complete list of roles configured in the system. Use this endpoint to discover valid id_rol values before creating or updating users.
Response
Unique role identifier. Pass this value as
id_rol when creating or updating a user.Internal role name (e.g.
admin, mesero, cocina, caja).Human-readable description of the role’s permissions and responsibilities. May be
null.Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
403 | Authenticated user is not admin |
GET /usuarios/ — List Users
Required role:admin
Returns a paginated-friendly list of all user accounts. Supports case-insensitive full-text search across the nombre and email fields, and optional filters by role and active status. All three query parameters are independent and can be combined freely.
Query Parameters
Case-insensitive substring match applied to both
nombre and email. Returns users where either field contains the search string.Filter results to users assigned to this role ID. Must correspond to a valid role from
GET /usuarios/roles.Filter by active status. Pass
true to show only active users, false for deactivated accounts. Omit to return all users regardless of status.Response
Returns an array ofUserOut objects. See UserOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
403 | Authenticated user is not admin |
GET /usuarios/me — Get Own Profile
Required role: Any authenticated user Returns the full profile of the currently authenticated user, identified from the JWT token. This is the only users endpoint accessible to non-admin roles and is the standard way for any logged-in user to retrieve their own account details.Response
Returns a singleUserOut object for the caller. See UserOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
GET /usuarios/ — Get Single User
Required role:admin
Retrieves the full profile of any user by their numeric ID.
Path Parameters
The unique ID of the user to retrieve.
Response
Returns a singleUserOut object. See UserOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
404 | "Usuario no encontrado" — no user with the given ID exists |
401 | Token missing or expired |
403 | Authenticated user is not admin |
POST /usuarios/ — Create User
Required role:admin
Creates a new staff account. The supplied plain-text password is bcrypt-hashed before being written to the database — it is never stored or returned in plain text. Returns 201 Created on success.
Request Body
Full display name of the staff member (e.g.
"María García").Valid email address. Must be unique across all user accounts. Used as the login identifier.
Plain-text password. The API hashes this value with bcrypt before storage. Minimum recommended length: 8 characters.
Role to assign to the new user. Must be a valid role ID from
GET /usuarios/roles.Whether the account is active and permitted to log in. Defaults to
true.Response
Returns the newly createdUserOut object with HTTP 201 Created. See UserOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
400 | "El email ya está registrado" — another account already uses this email |
400 | "Rol no encontrado" — the supplied id_rol does not exist |
401 | Token missing or expired |
403 | Authenticated user is not admin |
PATCH /usuarios/ — Update User (Partial)
Required role:admin
Partially updates a user account. Only the fields included in the request body are modified; omitted fields retain their current values. The password field, if supplied, is re-hashed before storage.
Path Parameters
The unique ID of the user to update.
Request Body
All fields are optional. Include only the fields you want to change.New display name for the user.
New email address. Must not be in use by any other user account.
New plain-text password. Will be bcrypt-hashed before storage.
New role assignment. Must be a valid role ID from
GET /usuarios/roles.Set to
false to deactivate the account without deleting it, preventing login.Response
Returns the updatedUserOut object. See UserOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
400 | "El email ya está en uso" — the new email belongs to a different account |
400 | "Rol no encontrado" — the supplied id_rol does not exist |
404 | "Usuario no encontrado" — no user with the given ID exists |
401 | Token missing or expired |
403 | Authenticated user is not admin |
DELETE /usuarios/ — Delete User
Required role:admin
Permanently deletes a user account. Returns HTTP 204 No Content on success. This operation is irreversible.
Two safety guards are enforced:
- An admin cannot delete their own account — this prevents accidental self-lockout.
- A user cannot be deleted if they have associated orders, sales, or expenses — the database enforces referential integrity via an
IntegrityError.
Path Parameters
The unique ID of the user to delete.
Example
204 No Content with an empty body.
Error codes
| Status | Detail |
|---|---|
400 | "No puedes eliminarte a ti mismo" — you cannot delete your own account |
400 | "No se puede eliminar el usuario porque tiene pedidos, ventas o gastos asociados." — database integrity constraint prevents deletion |
404 | "Usuario no encontrado" — no user with the given ID exists |
401 | Token missing or expired |
403 | Authenticated user is not admin |
UserOut Response Shape
All endpoints that return user objects use theUserOut schema. The password_hash field is never included in any response.
Auto-incremented unique identifier for the user.
Full display name of the staff member.
The user’s email address and login identifier.
true if the account is active and permitted to authenticate; false if deactivated.Nested role object containing the full role definition for this user.
ISO 8601 timestamp of when the account was created (e.g.
"2024-01-20T08:00:00").