The Users API handles every aspect of identity in StockManager: session-based authentication, account registration with admin approval, full CRUD for the user roster, a three-step password recovery flow, vendor autocomplete for sale forms, and self-service profile settings. Most mutating operations require theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/InnoDev69/StockManager/llms.txt
Use this file to discover all available pages before exploring further.
admin or root role. Passwords are stored as Werkzeug pbkdf2:sha256 hashes and are never returned in any response. The three valid roles are admin, vendedor, and root.
Authentication
POST /api/login
Authenticates a user and creates a server-side session. Accepts either a username or e-mail address in theusername field.
Username or e-mail address of the account.
Plain-text password (transmitted over HTTPS, compared against stored hash).
Always
true on a 200 response.Primary key of the authenticated user.
Display name stored in the database.
One of
admin, vendedor, or root.| Status | Meaning |
|---|---|
200 | Login successful; session cookie set. |
400 | username or password field is empty. |
401 | Credentials do not match any account. |
403 | Account is disabled (status = 0) or role is not recognized. |
POST /api/register
Creates a new account withstatus = 0 (inactive) and application = "pending". The account cannot log in until an administrator approves it by setting status = 1. New accounts are always assigned the vendedor role.
Desired username. Maximum 30 characters.
Valid e-mail address. Maximum 100 characters.
Minimum 6 characters.
true on successful registration.Human-readable confirmation, e.g.
"Cuenta creada. Espera la aprobación del administrador.".| Status | Meaning |
|---|---|
201 | Account created and pending approval. |
400 | Missing fields, invalid e-mail, or password shorter than 6 characters. |
409 | Username or e-mail already exists. |
Registered accounts are inactive until an admin changes their
status to 1 via PUT /api/users/:id.User Management
All endpoints in this section require theadmin or root role.
GET /api/users
Returns a paginated, searchable list of all users.Filters by username or e-mail (case-insensitive
LIKE match). Omit to return all users.Page number (1-based). Defaults to
1.Records per page. Defaults to
10; maximum 100.Array of user objects for the current page.
Total number of matching records across all pages.
Current page number.
Total number of pages.
Page size used for this response.
GET /api/users/:id
Returns a single user by their primary key.| Status | Meaning |
|---|---|
200 | User found. |
404 | No user with that ID exists. |
data array above.
POST /api/users
Creates a new user directly without the registration approval flow. The new account is immediately active (status = 1).
Display name for the account.
Must be a valid e-mail and unique in the database.
Plain-text password; stored as a hash.
One of
admin, vendedor, or root.| Status | Meaning |
|---|---|
201 | {"message": "Usuario creado exitosamente"} |
400 | Missing required fields or invalid e-mail format. |
409 | E-mail or username already registered. |
PUT /api/users/:id
Partially updates a user. Only fields present in the request body are evaluated; fields whose values are unchanged are silently ignored — no unnecessary writes occur. On success, a notification is automatically sent to the affected user.New display name.
New e-mail address; must be unique.
New role:
admin, vendedor, or root.1 to activate, 0 to deactivate.If provided (and non-empty), the password is re-hashed and updated.
| Status | Meaning |
|---|---|
200 | Update applied (or no changes detected). |
404 | User not found. |
409 | New e-mail is already taken by another account. |
DELETE /api/users/:id
Performs a soft delete — setsstatus = 0 rather than removing the row. The operation is refused when id matches the currently authenticated user.
| Status | Meaning |
|---|---|
200 | {"message": "Usuario dado de baja"} |
400 | Attempted to deactivate your own account. |
Password Reset Flow
All three steps below are unauthenticated — they are designed to be called from the public-facing login screen. The reset code is a cryptographically random 6-digit string valid for 15 minutes.Request a reset code
POST /api/users/reset-passwordRegistered e-mail address of the account to recover.
200 {"message": "Codigo enviado al correo"} on success, 404 if the e-mail is not registered.Set a new password
POST /api/users/reset-password/change-passwordThe server re-validates the code before applying the change. The code is deleted from the database immediately after a successful reset to prevent reuse.Account e-mail address.
The same 6-digit code from step 1.
The desired new password.
200 {"message": "Contraseña restablecida exitosamente"} on success, 401 if the code is expired or invalid.Vendor Autocomplete
GET /api/suggest/vendors
Returns up to 10 active users with thevendedor or admin role whose username or e-mail matches the search string. Used to populate vendor picker inputs when creating a sale.
Auth: any authenticated session.
Search string matched against both
username and email with a LIKE query. Returns an empty array when q is blank.Matched user suggestions (maximum 10).
Profile Settings
Both endpoints below operate on the currently authenticated user’s own account — no admin role is required.PUT /api/api/settings/profile
Updates the authenticated user’s e-mail address.New e-mail address. Must contain
@ and ..true on a successful update.Confirmation string, e.g.
"Perfil actualizado correctamente".| Status | Meaning |
|---|---|
200 | Profile updated. |
400 | email is missing or malformed. |
PUT /api/api/settings/password
Changes the authenticated user’s password. The current password must be supplied and verified before the new one is stored.The user’s existing password (verified against stored hash).
Desired new password. Minimum 6 characters.
Must match
new_password exactly.true on a successful change.Confirmation string, e.g.
"Contraseña actualizada correctamente".| Status | Meaning |
|---|---|
200 | Password updated. |
400 | Missing fields, passwords do not match, or new password is shorter than 6 characters. |
401 | current_password is incorrect. |