The company management endpoints let Super Admins control tenant lifecycle (activation, plan assignment, role promotion) and let company Admins manage their own workforce (creating sub-users, toggling account activation, listing active or inactive employees). All endpoints in this section require a valid JWT in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/MultiSas/llms.txt
Use this file to discover all available pages before exploring further.
token-access: Bearer <token> header — see the Auth page for how to obtain a token.
TokenAny resolves the bearer token against both the Company collection and the UserCompany collection, populating req.user with { id, type_dato, role, plan, active }. TokenAuthorize(...roles) then checks whether req.user.role is included in the allowed list before passing control to the handler.PUT /api/user/update-company/:company_id
Update a company’s subscription plan, account status, and billing cycle. This action is restricted to Super Admins only. On success, the company’srole_user is promoted to Admin and active_account is set to Activo.
Auth: TokenAny + TokenAuthorize('Super Admin')
Path Parameters
The MongoDB
_id of the company to update.Subscription plan to assign. One of:
Plan Basico, Plan Profesional, Plan Premium, Plan Personalizado, Sin Plan.Billing cycle type. One of:
Mensual, Anual, Permanente, Vacio. Controls how expired_available_plans is calculated.Number of months for a
Mensual plan (e.g. 3). Ignored when type_available_plans is Anual or Permanente."Datos actualizados correctamente" on success.true on success.The API automatically computes
day_available_plans (today’s date), expired_available_plans (today + billing cycle), and promotes role_user to "Admin" and active_account to [{"name":"Activo","value":"2"}]. You do not need to send those fields in the request body.POST /api/user/create-user-company-by-admin/:company_id
Create a new sub-user (employee/seller) profile under a specific company. Only Admins of the target company and Super Admins may call this endpoint. The newly created account starts withactive: false and must be activated separately.
Auth: TokenAny + TokenAuthorize('Admin', 'Super Admin')
Path Parameters
The MongoDB
_id of the parent company.Full name of the new sub-user.
Email address for the sub-user.
Plain-text password for the sub-user. Stored bcrypt-hashed (salt rounds: 6).
Role to assign. One of:
Vendedor, Consultor, Diseñador, Sin rol.Dynamic success message, e.g.
"Perfil de Vendedor creado exitosamente".true on success.The full persisted
UserCompany document, including _id, company (parent company ID), all submitted fields, and active: false.PUT /api/user/active-account-user-by-company/:user_company_id
Toggle theactive status of a sub-user account. Set active: true to allow the sub-user to log in; set active: false to deactivate them. Only the owning company’s Admin (or a Super Admin) may update a sub-user.
Auth: TokenAny + TokenAuthorize('Admin', 'Super Admin')
Path Parameters
The MongoDB
_id of the UserCompany record to activate or deactivate.true to activate the account; false to deactivate it."Cuenta activada correctamente" on success.true on success.MongoDB
updateOne result object containing matchedCount, modifiedCount, and acknowledged.GET /api/user/list-user-by-company-active/:company_id/:pag?/:perpage?
Return a paginated list of active sub-users (active: true) that belong to the specified company. Results are sorted by _id descending (newest first).
Auth: TokenAny + TokenAuthorize('Admin', 'Super Admin')
Path Parameters
The MongoDB
_id of the company whose active users should be listed.Page number to retrieve (1-based). Defaults to page
1 when omitted.Number of records per page. Defaults to
10 when omitted."Cargando usuarios activados..." on success.true on success.Array of
UserCompany documents matching the filter.Pagination metadata.
GET /api/user/list-user-by-company-not-active/:company_id/:pag?/:perpage?
Return a paginated list of inactive sub-users (active: false) for a company — typically accounts that have been created but not yet activated, or that have been suspended. Results are sorted by _id descending.
Auth: TokenAny + TokenAuthorize('Admin', 'Super Admin')
Path Parameters
The MongoDB
_id of the company.Page number (1-based). Defaults to
1.Items per page. Defaults to
10."Cargando usuarios no activados..." on success.true on success.Array of inactive
UserCompany documents.Same structure as the active-users endpoint:
pag, perpage, pags.GET /api/user/test_plan
Check the plan expiration status for the authenticated company. Thecheck_plan_expiration middleware from Expiration.js runs before the controller handler and may short-circuit the request if the plan has already expired.
Auth: TokenAny + TokenAuthorize('Admin', 'Super Admin') + check_plan_expiration
Response
true if the plan is still valid.The date on which the current plan was activated (
day_available_plans from the company record).MongoDB
_id of the authenticated company.Pagination
Paginated list endpoints use optional URL path segments rather than query parameters. ThePaginate middleware reads :pag and :perpage from req.params and injects skippag and limit into req.body before the handler runs.
| Segment | Description | Default |
|---|---|---|
:pag | Page number (1-based). Page 1 starts at offset 0. | 1 |
:perpage | Number of records returned per page. | 10 |
skippag = (pag - 1) * perpage
Example — page 2 of results, 10 items per page:
pagination object always echoes back the current page (pag), effective page size (perpage), and total page count (pags) so that clients can implement next/previous controls without an additional count request.
Error Responses
All protected endpoints share a common set of error shapes returned by theTokenAny and TokenAuthorize middleware layers.
| HTTP Status | When | Response Body |
|---|---|---|
401 | No token-access header provided | {"msj": "Sin autorizacion", "status": false} |
403 | JWT has expired (365-day TTL elapsed) | {"msj": "Sesion finalizada", "status": false} |
403 | Authenticated user’s role is not in the allowed list | {"msj": "No tienes permisos", "status": false} |
404 | User record not found during token lookup | {"msj": "Usuario no encontrado", "status": false} |