The Ecommerce API uses JSON Web Tokens (JWT) as its primary authentication mechanism. A token is issued at login and must accompany every subsequent request to a protected endpoint via theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
token-access header. This page walks through the complete lifecycle — from creating an account to recovering a forgotten password — and explains how role-based access works once you are authenticated.
Registration and login flow
Register a new account
Send a
POST request to /api/user/register with all required user fields. The account is created with an inactive status (Inactivo, value "2") and a 5-digit verification code is dispatched to the provided email address.The user’s first name.
The user’s last name.
Email address — used for verification codes and login.
Plain-text password; the API stores it hashed.
Contact phone number.
Gender identifier. Accepted values:
"Masculino", "Femenino", "Otro".Identity document number.
Type of identity document. Accepted values:
"CC", "CE", "Pasaporte".Date of birth in
YYYY-MM-DD format.Check your email for the verification code
After a successful registration, the API sends a 5-digit numeric code to the email address you provided. Check your inbox (and spam folder) for this code — you will need it in the next step.
The verification code is single-use and tied to the registered email address. It does not expire automatically, but attempting to verify an already-active account will return an error.
Verify the account
Submit the 5-digit code alongside the registered email to
POST /api/user/verify-account. On success, the account’s activate status is updated to Activado (value: "1") and the account is now eligible to log in.The email address used during registration.
The 5-digit verification code received by email.
Log in and receive your JWT
Once the account is active, call
POST /api/user/login with your credentials. The API responds with a signed JWT valid for 365 days.The registered email address.
The account password.
Signed JWT to use in the
token-access header for all protected requests.Full snapshot of the authenticated user, including role and activation status.
Tokens expire after 365 days. There is no refresh-token endpoint; users must log in again once the token expires. The issued token is also stored on the User document in the database and is re-verified by the
Token middleware on every request.Token payload reference
The JWT encodes the following claims at the time of login:| Claim | Type | Description |
|---|---|---|
id | string | MongoDB _id of the user document |
userName | string | Display name |
email | string | Email address |
phone | string | Phone number |
sex | string | Gender field (Masculino, Femenino, Otro) |
document | string | Identity document number |
documentType | string | Type of identity document (CC, CE, Pasaporte) |
birthdate | string | Date of birth |
roles | array | Role objects — see Role-based access |
activate | array | Activation status objects |
Password recovery
If a user forgets their password, the API provides a two-step reset flow that does not require the user to be logged in.Step 1 — Request a reset code
POST /api/user/recovery-password sends a 5-digit code to the account’s registered email.
The email address associated with the account.
Step 2 — Set the new password
POST /api/user/update-password accepts the code from the email together with the new password.
The email address associated with the account.
The 5-digit reset code received by email.
The new password to set for the account.
Role-based access
Every user has aroles array embedded in their token payload. The API currently defines two roles:
Usuario (value: 1)
Standard customer role. Can browse products, manage their own cart, and place orders. Assigned by default to all newly registered accounts.
Admin (value: 2)
Administrator role. Can create, update, and delete products, and retrieve the full list of users. Must be assigned manually in the database.
roles array in the resolved user document contains an entry with value: "2". Standard users attempting to access admin-only endpoints will receive a 403 or 401 response depending on how the route guard is implemented.