The Users API gives Administrators full control over the system’s user accounts. Every endpoint underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ytabeloved/ordervista/llms.txt
Use this file to discover all available pages before exploring further.
/api/users is protected by two middleware layers: verifyToken (validates the JWT) and authorizeRoles(1) (restricts access to id_rol: 1 — Administrator). Administrators can create users of any role, including other administrators, operators, and customers. Passwords are always hashed with bcrypt before being stored.
GET /api/users
Returns the complete list of user accounts in the system. Results are fetched via a JOIN between theUSUARIOS and ROLES tables, so each object includes the resolved role name rather than the numeric role identifier.
Auth required: Yes — Administrator (id_rol: 1)
Response 200 OK
An array of user objects.
Auto-incremented primary key.
First name.
Last name.
Unique email address.
Phone number, or
null if not provided.Whether the account is active.
Human-readable role name resolved from the
ROLES table (e.g. "Administrador", "Operador", "Cliente").Error responses
| Status | mensaje | Cause |
|---|---|---|
401 | "Token no proporcionado" / "Token inválido" | Missing or invalid JWT. |
403 | "Acceso denegado" | Authenticated user does not have the Administrator role. |
500 | "Error al obtener usuarios" | Unexpected server-side error. |
GET /api/users/:id
Retrieves a single user account by its primary key. Returns the full row from theUSUARIOS table via SELECT *.
Auth required: Yes — Administrator (id_rol: 1)
Path parameters
The
id_usuario of the user to retrieve.Response 200 OK
A single user object with the raw columns from the USUARIOS table.
Auto-incremented primary key.
First name.
Last name.
Unique email address.
Phone number, or
null if not provided.Numeric role identifier.
1 = Administrator, 2 = Operator, 3 = Customer.ISO 8601 timestamp of when the account was created.
Whether the account is active.
Error responses
| Status | mensaje | Cause |
|---|---|---|
401 | "Token no proporcionado" / "Token inválido" | Missing or invalid JWT. |
403 | "Acceso denegado" | Insufficient role. |
404 | "Usuario no encontrado" | No user exists with the given id. |
500 | "Error al obtener usuario" | Unexpected server-side error. |
POST /api/users
Creates a new user account with an explicitly assigned role. Unlike self-registration via/api/auth/register, this endpoint allows the Administrator to assign any id_rol.
Auth required: Yes — Administrator (id_rol: 1)
Request body
First name of the new user.
Last name of the new user.
Email address. Must be unique.
Plain-text password. Hashed with bcrypt before storage.
Role to assign.
1 = Administrator, 2 = Operator, 3 = Customer.Optional phone number (up to 20 characters).
Response 201 Created
Confirmation message:
"Usuario creado correctamente".The auto-generated primary key of the new user.
Error responses
| Status | mensaje | Cause |
|---|---|---|
400 | "El correo ya existe" | The email is already registered. |
401 | "Token no proporcionado" / "Token inválido" | Missing or invalid JWT. |
403 | "Acceso denegado" | Insufficient role. |
500 | "Error al crear usuario" | Unexpected server-side error. |
PUT /api/users/:id
Updates one or more fields on an existing user account. All fields in the request body are written to the record; omitting a field sets it toundefined in the SQL update, so supply all fields you want to preserve.
Auth required: Yes — Administrator (id_rol: 1)
Path parameters
The
id_usuario of the user to update.Request body
New first name.
New last name.
New email address. Must remain unique.
New plain-text password. Will be hashed before storage.
New phone number.
New role assignment.
Set to
false to deactivate the account without deleting it.Response 200 OK
Confirmation message:
"Usuario actualizado correctamente".Error responses
| Status | mensaje | Cause |
|---|---|---|
401 | "Token no proporcionado" / "Token inválido" | Missing or invalid JWT. |
403 | "Acceso denegado" | Insufficient role. |
500 | "Error al actualizar usuario" | Unexpected server-side error. |
DELETE /api/users/:id
Permanently removes a user account from the system. Auth required: Yes — Administrator (id_rol: 1)
Path parameters
The
id_usuario of the user to delete.Response 200 OK
Confirmation message:
"Usuario eliminado correctamente".Error responses
| Status | mensaje | Cause |
|---|---|---|
401 | "Token no proporcionado" / "Token inválido" | Missing or invalid JWT. |
403 | "Acceso denegado" | Insufficient role. |
500 | "Error al eliminar usuario" | Unexpected server-side error. |