Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gcapella0/agente-inteligente-expedientes/llms.txt

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

All /usuarios endpoints are restricted to the admin role via the verify_admin dependency. Passwords are stored as bcrypt hashes (via passlib) and the password_hash field is explicitly excluded from every response using a MongoDB projection {"password_hash": 0}. Cleartext passwords are never logged or returned.
The /usuarios router uses a different role set (admin, docente, viewer) from the core UsuarioModel used by the /auth router (admin, usuario, sistema). Accounts created via /usuarios/crear receive one of those three roles. See the role reference at the bottom of this page.

GET /usuarios/

List all user accounts.
PropertyValue
MethodGET
Path/usuarios/
Auth requiredYes — admin role

Response 200 — Success

Returns an array of serialized user documents. The password_hash field is never included.
[
  {
    "id": "507f1f77bcf86cd799439011",
    "email": "admin@uneg.edu.ve",
    "rol": "admin",
    "createdAt": "2024-01-15T10:30:00"
  },
  {
    "id": "507f1f77bcf86cd799439012",
    "email": "docente@uneg.edu.ve",
    "rol": "docente",
    "createdAt": "2024-03-10T08:45:00"
  }
]
Each object is produced by _serializar_usuario, which maps MongoDB’s _id to id (string) and coerces creado_en / createdAt to an ISO 8601 string.

POST /usuarios/crear

Create a new user account.
PropertyValue
MethodPOST
Path/usuarios/crear
Auth requiredYes — admin role
Content-Typeapplication/json
Status201 Created

Request body

email
string
required
Valid email address for the account. Must contain @ and be unique in the usuarios collection.
password
string
required
Plaintext password. Minimum 6 characters. Stored as a bcrypt hash.
rol
string
default:"docente"
Role to assign. Must be one of admin, docente, or viewer.
{
  "email": "viewer@uneg.edu.ve",
  "password": "password123",
  "rol": "viewer"
}

Response 201 — Created

{
  "id": "507f1f77bcf86cd799439013",
  "email": "viewer@uneg.edu.ve",
  "rol": "viewer"
}

Error responses

StatusDetailCause
400Email inválidoEmail string does not contain @
400Password debe tener mínimo 6 caracteresPassword length is fewer than 6 characters
400Rol inválido. Valores permitidos: ['admin', 'docente', 'viewer']rol is not in _ROLES_VALIDOS
400El email ya está registradoA document with that email already exists

cURL example

curl -X POST http://localhost:8000/usuarios/crear \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"email": "viewer@uneg.edu.ve", "password": "password123", "rol": "viewer"}'

PUT /usuarios/{user_id}/rol

Update the role of an existing user.
PropertyValue
MethodPUT
Path/usuarios/{user_id}/rol
Auth requiredYes — admin role
Content-Typeapplication/json

Path parameters

user_id
string
required
MongoDB ObjectId of the target user (24-character hex string, e.g. 507f1f77bcf86cd799439011).

Request body

rol
string
required
New role to assign. Must be one of admin, docente, or viewer.
{
  "rol": "admin"
}

Response 200 — Success

{
  "message": "Rol actualizado"
}

Error responses

StatusDetailCause
400Rol inválido. Valores permitidos: ['admin', 'docente', 'viewer']rol is not in _ROLES_VALIDOS
400ID de usuario inválidouser_id cannot be parsed as a bson.ObjectId
404Usuario no encontradoNo document with that _id exists

DELETE /usuarios/{user_id}

Permanently delete a user account.
PropertyValue
MethodDELETE
Path/usuarios/{user_id}
Auth requiredYes — admin role

Path parameters

user_id
string
required
MongoDB ObjectId of the user to delete (24-character hex string).

Response 200 — Success

{
  "message": "Usuario eliminado"
}

Error responses

StatusDetailCause
400ID de usuario inválidouser_id cannot be parsed as a bson.ObjectId
404Usuario no encontradodelete_one matched zero documents
You cannot delete your own admin account through this API. Doing so would immediately invalidate your token and lock you out of all admin-only endpoints, including user management and audit logs. There is no recovery path short of direct database access.

Roles

The /usuarios router enforces the following valid roles, defined in _ROLES_VALIDOS:
RoleAccess level
adminFull access — user management (/usuarios), audit endpoints (/admin/auditoria), and all other routes
docenteStandard authenticated access. Equivalent to usuario in the core auth model
viewerRead-only access. Cannot create, modify, or delete records
Role docente in the /usuarios router corresponds to usuario in the core UsuarioModel. Accounts created via /auth/crear-usuario use the admin | usuario | sistema set, while accounts created via /usuarios/crear use the admin | docente | viewer set. Both account types share the same MongoDB usuarios collection and the same JWT machinery.

Build docs developers (and LLMs) love