Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TheSerchCp/SEAM-API/llms.txt

Use this file to discover all available pages before exploring further.

The GET /api/v1/users/:id endpoint retrieves a single user record by their numeric primary key. The response includes the user’s role name and role description via a LEFT JOIN with the roles table. The password field is never included in the response. This endpoint requires a valid JWT token and that the caller’s role has the GET /api/v1/users/:id permission registered in the database.

Endpoint

GET /api/v1/users/:id
Base URL: http://localhost:{PORT}/api/v1 Authentication: JWT Bearer token + role permission GET /api/v1/users/:id

Path Parameters

id
string
required
The numeric ID of the user to retrieve. Must match the pattern ^\d+$ (one or more digits, no other characters). This is validated by validate.middleware against getByIdSchema before the controller is reached.

Example Request

curl -X GET http://localhost:3000/api/v1/users/7 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Responses

200 OK

Returned when the token is valid, the role has the required permission, and a user with the given ID exists in the database.
{
  "success": true,
  "message": "Usuario obtenido exitosamente",
  "data": {
    "idUser": 7,
    "full_name": "Jane Doe",
    "email": "jane.doe@example.com",
    "roleId": 2,
    "roleName": "editor",
    "roleDescription": "Can read and edit content"
  }
}
success
boolean
Always true for successful responses.
message
string
Human-readable confirmation: "Usuario obtenido exitosamente".
data
object
The matched user record.

400 Bad Request — Invalid ID Format

Returned when the :id path segment does not match ^\d+$ (e.g., letters, special characters, or a floating-point number are supplied).
{
  "success": false,
  "message": "El campo 'id' no cumple con el patrón requerido",
  "data": null
}

401 Unauthorized

Returned when the Authorization header is missing, the token is malformed, or the token has expired.
{
  "success": false,
  "message": "Token inválido o expirado",
  "data": null
}

403 Forbidden

Returned when the JWT is valid but the caller’s role does not have GET /api/v1/users/:id listed in the permissionXRole table.
{
  "success": false,
  "message": "No tienes permisos para acceder a este recurso",
  "data": null
}

404 Not Found

Returned when no user with the given numeric ID exists in the users table. The service throws a NotFoundError which the global error middleware maps to HTTP 404.
{
  "success": false,
  "message": "Usuario con id 7 no encontrado",
  "data": null
}

Permission Setup

For a role to access this endpoint, a record must exist in the permissions table with nameUri = "GET /api/v1/users/:id" and that permission must be linked to the role in the permissionXRole pivot table. The roles.middleware derives the URI automatically from the Express route pattern:
GET /api/v1/users/:id
Note that /:id is the route pattern, not the resolved value — the literal string :id must be stored as the nameUri in the permissions table.

Build docs developers (and LLMs) love