The Assignments API manages theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Nieto2020/portalhub/llms.txt
Use this file to discover all available pages before exploring further.
cliente_asesor pivot table, which is the authoritative record of which Asesor is responsible for each Cliente at any point in time. Every assignment has an estado of either activo or inactivo. When a client is reassigned, the previous activo row has its estado set to inactivo and a new activo row is inserted — the full history is therefore always preserved and queryable.
Only Admin users may create or change assignments. Asesores may read their own active portfolios and audit history. Clientes have no direct access to these endpoints.
Role IDs: Admin = 1, Asesor = 2, Cliente = 3. All assignment changes automatically trigger a
NotificationService alert to the affected Client.Assignment record fields
The following fields appear across multiple endpoints. They map directly to thecliente_asesor table columns.
| Field | Type | Description |
|---|---|---|
id_asignacion | int | Primary key. Auto-incremented. |
id_cliente | int | FK → usuarios.id_usuario (must have id_rol = 3) |
id_asesor | int | FK → usuarios.id_usuario (must have id_rol = 2) |
id_asignador | int | FK → usuarios.id_usuario — the Admin who created this row |
fecha_asignacion | timestamp | UTC timestamp set automatically on INSERT |
fecha_fin | timestamp | null | Set when the assignment becomes inactivo |
estado | enum | activo or inactivo |
motivo_cambio | text | null | Optional reason for the assignment or reassignment |
GET /backend/modules/asignaciones/listar.php
Returns all currently active assignments (estado = 'activo'). Admins see every active assignment across all advisors; Asesores see only assignments where they are the advisor.
The response joins usuarios and perfiles for both the client and the advisor, so display names and contact details are included inline.
Required role: Admin or Asesor (id_rol = 1 or 2)
Query parameters: None
Primary key of the assignment.
UTC timestamp when this assignment was created.
User ID of the assigned client.
Email address of the client.
Client number (e.g.
CLI-0042), if set.Full name from
perfiles.nombre_completo for the client.Phone number from
perfiles.telefono for the client.User ID of the assigned advisor.
Full name from
perfiles.nombre_completo for the advisor.Response 200
| Code | Message |
|---|---|
403 | Acceso denegado |
500 | Error en el servidor |
POST /backend/modules/asignaciones/asignar.php
Creates a new active assignment between a client and an advisor. If the client already has an active assignment, it is automatically closed (estado = 'inactivo', fecha_fin = CURRENT_TIMESTAMP) before the new row is inserted. The entire operation runs inside a database transaction.
After committing, the server calls NotificationService::notify() to send an "Asignación" notification to the client.
Required role: Admin (id_rol = 1)
User ID of the client to assign. The server validates that this user exists and has
id_rol = 3 (Cliente).User ID of the advisor to assign. The server validates that this user exists and has
id_rol = 2 (Asesor).Human-readable reason for the assignment or reassignment. Defaults to
"Asignación inicial" when omitted.Response 201
| Code | Message |
|---|---|
400 | Faltan campos requeridos (id_cliente, id_asesor) |
400 | El usuario destino no es un Cliente |
400 | El usuario asignado no es un Asesor |
403 | Acceso denegado |
404 | Uno o ambos usuarios no existen |
405 | Método no permitido |
500 | Error en el servidor (with rollback) |
GET /backend/modules/asignaciones/historial.php
Returns the complete assignment history for a given client (and optionally filtered to what the Asesor has access to). Results are ordered byfecha_asignacion DESC so the most recent assignment appears first.
Admins may query history for any client. Asesores may only retrieve history for clients they have a current or past assignment with. Asesores must supply id_cliente.
Required role: Admin or Asesor (id_rol = 1 or 2)
Query parameters
Filter history to a specific client. Required for Asesor callers. Optional for Admins — when omitted by an Admin the full history across all clients is returned.
Primary key of the historical assignment row.
UTC timestamp when this assignment was created.
UTC timestamp when this assignment was closed.
null for the currently active row.activo for the current assignment, inactivo for all prior assignments.Reason recorded at the time of assignment.
Email of the Asesor in this historical row.
Full name from
perfiles.nombre_completo for that Asesor.Email of the Admin who created this assignment row.
- Admin — full history
- Asesor — own clients
An Admin can retrieve the full timeline for any client, or omit
id_cliente to retrieve every assignment row across the entire platform (useful for audit exports).Response 200
| Code | Message |
|---|---|
400 | Debe especificar un id_cliente |
403 | Acceso denegado |
500 | Error en el servidor |