The Users API provides all post-authentication operations for Gestor Deportivo accounts: editing profile details and avatars, changing passwords while logged in, assigning roles, updating membership and club data, deleting accounts, and listing or searching users. Admin-only operations are clearly marked.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/gestor-backend/llms.txt
Use this file to discover all available pages before exploring further.
Most endpoints on this page require a valid JWT in the Do not use
access-token request header. Obtain a token by calling POST /api/user/login. The header format is:Authorization: Bearer.User Object Reference
The shape below represents the user object returned fromPOST /api/user/login and embedded in various responses across the API.
MongoDB ObjectId string uniquely identifying the user.
User’s first name.
User’s last name.
Email address (stored lowercase).
Array of image URL strings. Empty array when no avatar has been uploaded.
Gender:
"Masculino", "Femenino", or "Otro".Array of team ObjectId strings that the user belongs to.
Associated Player document ID. Empty string when not linked to a player record.
Array of role objects
{ name: string, value: string }. See the Roles table below.Activation state array
{ name: string, value: string }. An active account contains { name: "1", value: "Activo" }.Current membership tier. One of
"Plan Gratis", "Plan Basico", or "Plan Premium". Default: "Plan Gratis".Affiliation type. One of
"Sin academia o club", "Academia", or "Club". Default: "Sin academia o club".Roles
value | name | Description |
|---|---|---|
"1" | "Usuario" | Standard user. Default role assigned at registration. |
"2" | "Admin" | Administrator. Can manage roles, membership data, and view all users. |
POST /api/user/update-user/:userId
Update a user’s first name, last name, and/or avatar image. Only the account owner can edit their own profile. The request must be sent asmultipart/form-data because of the optional file upload.
Requires
access-token header. Only the owner of the account (userId) may call this endpoint.Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT |
The MongoDB ObjectId of the user to update.
New first name.
New last name.
New profile image. Replaces the existing avatar when supplied.
Example
Response
200 — Updatedtrue on success.MongoDB
updateOne result object including modifiedCount and matchedCount.The fields that were written (
firstName, lastName, avatar).| HTTP status | Condition |
|---|---|
403 | The requester’s userId does not match the document’s _id (not the owner). |
404 | No user found for the given userId. |
POST /api/user/update-password/:userId/token
Change a password while already authenticated. Unlike the code-based recovery flow, this endpoint validates identity via theaccess-token header and requires both newPassword and confirmNewPassword to be provided.
Requires
access-token header.Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT |
The MongoDB ObjectId of the user changing their password.
Must match the email address stored on the user document.
The new password.
Confirmation of the new password. Must match
newPassword.Example
Response
200 — UpdatedConfirmation message.
Returns
false as implemented in the current source.| HTTP status | Condition |
|---|---|
403 | The calling user’s ID does not match userId, or the supplied email does not match the stored email. |
404 | No user found for the given userId. |
POST /api/user/update-roles/:userId
Replace theroles array of a target user. The caller must be an admin ({ name: "Admin", value: "2" }) and must pass their own user ID in adminId for server-side validation.
Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT (admin) |
The MongoDB ObjectId of the user whose roles will be updated.
The complete new roles array. Each element must be an object with
name (string) and value (string). Example: [{ "name": "Admin", "value": "2" }].The MongoDB ObjectId of the admin performing the operation. The server looks up this ID and verifies the admin role before applying any changes.
Example
Response
200 — Roles updatedtrue on success.MongoDB
updateOne result with modifiedCount and matchedCount.| HTTP status | Condition |
|---|---|
403 | The adminId was not found, the caller does not have the Admin role, or the target userId was not found. |
POST /api/user/update-data/:userId
Update a user’s membership tier and academy/club affiliation. Admin-only operation.Requires
access-token header. Caller must be an Admin.Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT (admin) |
The MongoDB ObjectId of the user to update.
New membership plan. Must be one of:
"Plan Gratis""Plan Basico""Plan Premium"
New affiliation type. Must be one of:
"Sin academia o club""Academia""Club"
The MongoDB ObjectId of the admin performing the operation. Validated server-side.
Example
Response
200 — Updatedtrue on success.| HTTP status | Condition |
|---|---|
403 | adminId not found, caller lacks Admin role, or target userId not found. |
POST /api/user/delete/:userId
Permanently delete a user account. Only the account owner can delete their own account.Requires
access-token header.Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT |
The MongoDB ObjectId of the account to delete.
Example
Response
200 — Deletedtrue on success.| HTTP status | Condition |
|---|---|
403 | The userId in the path does not match the found document’s _id. |
POST /api/user/list-user/:adminId/:pag?/:perpage?
Retrieve a paginated list of all users in the system. Each record includes only the safe subset of fields:_id, firstName, lastName, email, avatar, roles, and activate.
This is an admin-only endpoint. The
adminId path parameter is validated server-side; the request is rejected if the referenced user does not hold the Admin role.Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT (admin) |
The MongoDB ObjectId of the calling admin. Used for role verification.
Page number (1-based). Defaults to
1 when omitted.Records per page. Defaults to
10 when omitted.Example
Response
200 — OKArray of user objects. Each object contains
_id, firstName, lastName, email, avatar, roles, and activate.Pagination metadata.
| HTTP status | Condition |
|---|---|
403 | The adminId was not found or does not have the Admin role. |
POST /api/user/search/:query/:pag?/:perpage?
Search users by first name using a case-insensitive regular expression. Results are paginated identically tolist-user. Sorted newest-first by _id.
This is an admin-only endpoint. The calling user’s roles are read from the decoded JWT (
req.user.roles). The request is silently ignored (no response sent) if the caller is not an admin.Request
Headers| Header | Value |
|---|---|
access-token | Valid JWT (admin) |
Search string. Matched case-insensitively against
firstName. For example, carlos matches Carlos, CARLOS, carlOS, etc.Page number (1-based). Defaults to
1 when omitted.Records per page. Defaults to
10 when omitted.Example
Response
200 — ResultsArray of matching user objects, sorted by
_id descending (newest first).Same pagination structure as
list-user: pag, perpage, and pags.| Condition | Behaviour |
|---|---|
| Caller is not an Admin | No response is sent (connection hangs). Ensure valid admin token. |
| Query matches zero documents | Returns data: [] with pags: 0. |