This page documents the endpoints used to manage existing user accounts. Profile updates, authenticated password changes, role assignments, account deletion, and paginated user listing are all covered here. All endpoints that require authentication expect a valid JWT in 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 request header (obtained from POST /api/user/login).
Update User Profile
POST /api/user/update/:userId/user
Updates a user’s personal profile fields. The caller must be authenticated with a valid token, and the userId in the path must match the authenticated user’s own ID. Only the fields listed below are accepted — email, roles, and activation status cannot be changed through this endpoint.
Method: POSTPath:
/api/user/update/:userId/userAuth required: Yes (
token-access header)
Path Parameters
The unique ID of the user whose profile is being updated.
Request Body
The user’s updated first name.
The user’s updated last name.
The user’s updated phone number.
The user’s sex. Must be one of
Masculino, Femenino, or Otro.Response — 200 OK
A human-readable confirmation message.
Always
false on success.The updated user document reflecting the new profile values.
Example Request
Error Responses
| Status Code | Meaning |
|---|---|
403 | The authenticated user’s ID does not match the userId path parameter, or the token is missing. |
404 | No user was found for the provided userId. |
Update Password (Authenticated)
POST /api/user/update-password-token/:userId
Allows an authenticated user to change their own password. Unlike the recovery flow, this endpoint requires a valid JWT token and verifies the request against the account email. Both the new password and a confirmation must be provided.
Method: POSTPath:
/api/user/update-password-token/:userIdAuth required: Yes (
token-access header)
Path Parameters
The unique ID of the user changing their password.
Request Body
The email address associated with the account. Used to verify ownership.
The new password to set. Will be stored as a bcrypt hash.
Must match
newPassword exactly. Used to prevent typos.Response — 200 OK
Returns a success message confirming the password update.Example Request
Error Responses
| Status Code | Meaning |
|---|---|
403 | The token is missing, or the userId does not match the account, or the email does not match. |
404 | No user was found for the provided userId. |
Update User Role
POST /api/user/update/:userId/role/:adminId
Assigns a new role to a target user. This action can only be performed by a user whose own roles include { name: "Admin", value: "2" }. The admin’s identity is validated server-side using adminId.
Method: POSTPath:
/api/user/update/:userId/role/:adminIdAuth required: Yes (
token-access header)
Path Parameters
The unique ID of the user whose role is being updated.
The unique ID of the administrator performing the action. Used to verify admin privileges.
Request Body
An array of role objects to assign to the target user. Each object must contain
Example:
name and value fields.Example:
[{ "name": "Admin", "value": "2" }]Response — 200 OK
A human-readable confirmation message.
Always
true on success.The result of the update operation reflecting the new role assignment.
Example Request
Error Responses
| Status Code | Meaning |
|---|---|
203 | The adminId account does not have the required Admin role. |
404 | No user was found for the provided userId or adminId. |
Delete Account
POST /api/user/account/:userId/delete
Permanently deletes a user account by ID. This action is irreversible. A valid authentication token is required.
Method: POSTPath:
/api/user/account/:userId/deleteAuth required: Yes (
token-access header)
Path Parameters
The unique ID of the user account to delete.
Response — 200 OK
Returns a success message confirming that the account has been deleted.Example Request
Error Responses
| Status Code | Meaning |
|---|---|
203 | The account could not be found or the ID does not match. |
500 | An unexpected server error occurred. |
List All Users (Admin)
POST /api/user/getAll/:adminId/:pag?/:perpage?
Returns a paginated list of all registered users. Only administrators (accounts with role { name: "Admin", value: "2" }) may call this endpoint. Pagination is controlled via URL path parameters and computed by the Paginate middleware before the handler runs.
Method: POSTPath:
/api/user/getAll/:adminId/:pag?/:perpage?Auth required: No (admin identity is verified via
adminId path parameter)
This route uses the
Paginate middleware rather than the Token middleware. Access control is enforced by looking up the adminId in the database and confirming that account holds the Admin role. The pag and perpage path parameters are optional — if omitted, the Paginate middleware defaults perpage to 10 and starts from page 1.Path Parameters
The unique ID of the administrator making the request. Used to verify admin privileges.
The page number to retrieve. Optional — defaults to
1 if not provided.The number of results to return per page. Optional — defaults to
10 if not provided.Response — 200 OK
A human-readable confirmation message.
Always
false on success.An array of user objects for the current page. Each object includes the following fields:
Metadata describing the current pagination state.
Example Request
Example Response
Error Responses
| Status Code | Meaning |
|---|---|
203 | The adminId account does not have the required Admin role, or no matching admin was found. |
500 | An unexpected server error occurred. |