Skip to main content

Overview

The Users API allows you to manage all types of users in the system, including students (estudiantes), teachers (docentes), and administrators. Users are associated with institutions and have different roles.

Endpoints

MethodEndpointDescription
GET/api/usersList all users
POST/api/usersCreate a new user
GET/api/users/{id}Get a specific user
PUT/api/users/{id}Update a user
DELETE/api/users/{id}Delete a user

List All Users

curl -X GET "https://api.example.com/api/users" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Response message in Spanish
data
array
required
Array of user objects
{
  "success": true,
  "message": "Usuarios listados con éxito",
  "data": [
    {
      "id": 1,
      "institutions_id": 1,
      "rol": "estudiante",
      "nombre": "Juan",
      "apellido": "Pérez García",
      "email": "[email protected]",
      "documento_identidad": "72345678",
      "fecha_nacimiento": "2010-05-15",
      "telefono": "+51 987 654 321",
      "activo": true,
      "created_at": "2026-03-05T10:30:00.000000Z",
      "updated_at": "2026-03-05T10:30:00.000000Z"
    },
    {
      "id": 2,
      "institutions_id": 1,
      "rol": "docente",
      "nombre": "María",
      "apellido": "Rodriguez Santos",
      "email": "[email protected]",
      "documento_identidad": "45678901",
      "fecha_nacimiento": "1985-08-20",
      "telefono": "+51 987 123 456",
      "activo": true,
      "created_at": "2026-03-05T11:00:00.000000Z",
      "updated_at": "2026-03-05T11:00:00.000000Z"
    }
  ]
}
The password field is hidden in API responses for security purposes.

Create User

curl -X POST "https://api.example.com/api/users" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "institutions_id": 1,
    "rol": "estudiante",
    "nombre": "Carlos",
    "apellido": "Mendoza Lima",
    "email": "[email protected]",
    "password": "SecurePass123!",
    "documento_identidad": "76543210",
    "fecha_nacimiento": "2011-03-22",
    "telefono": "+51 912 345 678",
    "activo": true
  }'

Request Parameters

institutions_id
integer
required
ID of the institution this user belongs to. Must reference a valid institution.
rol
string
required
User role in the system. Common values: “estudiante” (student), “docente” (teacher), “administrador” (administrator)
nombre
string
required
User’s first name
apellido
string
required
User’s last name
email
string
required
User’s email address. Must be unique across all users.
password
string
required
User’s password. Will be automatically hashed before storage.
documento_identidad
string
National identity document number (DNI, passport, etc.). Can be null.
fecha_nacimiento
date
Date of birth in YYYY-MM-DD format. Can be null.
telefono
string
Contact phone number. Can be null.
activo
boolean
Whether the user account is active. Defaults to true.

Response

{
  "success": true,
  "message": "Usuario creado con éxito",
  "data": {
    "id": 3,
    "institutions_id": 1,
    "rol": "estudiante",
    "nombre": "Carlos",
    "apellido": "Mendoza Lima",
    "email": "[email protected]",
    "documento_identidad": "76543210",
    "fecha_nacimiento": "2011-03-22",
    "telefono": "+51 912 345 678",
    "activo": true,
    "created_at": "2026-03-05T12:30:00.000000Z",
    "updated_at": "2026-03-05T12:30:00.000000Z"
  }
}

Get User

curl -X GET "https://api.example.com/api/users/1" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

id
integer
required
The unique identifier of the user

Response

{
  "success": true,
  "message": "Usuario obtenido con éxito",
  "data": {
    "id": 1,
    "institutions_id": 1,
    "rol": "estudiante",
    "nombre": "Juan",
    "apellido": "Pérez García",
    "email": "[email protected]",
    "documento_identidad": "72345678",
    "fecha_nacimiento": "2010-05-15",
    "telefono": "+51 987 654 321",
    "activo": true,
    "created_at": "2026-03-05T10:30:00.000000Z",
    "updated_at": "2026-03-05T10:30:00.000000Z"
  }
}

Update User

curl -X PUT "https://api.example.com/api/users/1" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "institutions_id": 1,
    "rol": "estudiante",
    "nombre": "Juan Carlos",
    "apellido": "Pérez García",
    "email": "[email protected]",
    "password": "NewSecurePass456!",
    "documento_identidad": "72345678",
    "fecha_nacimiento": "2010-05-15",
    "telefono": "+51 987 654 322",
    "activo": true
  }'

Path Parameters

id
integer
required
The unique identifier of the user to update

Request Parameters

All parameters from the Create endpoint apply. You can send partial updates.
institutions_id
integer
required
ID of the institution this user belongs to
rol
string
required
User role in the system
nombre
string
required
User’s first name
apellido
string
required
User’s last name
email
string
required
User’s email address (must be unique)
password
string
New password (only include if changing password)
documento_identidad
string
National identity document number
fecha_nacimiento
date
Date of birth (YYYY-MM-DD)
telefono
string
Contact phone number
activo
boolean
Account active status

Response

{
  "success": true,
  "message": "Usuario actualizado con éxito",
  "data": {
    "id": 1,
    "institutions_id": 1,
    "rol": "estudiante",
    "nombre": "Juan Carlos",
    "apellido": "Pérez García",
    "email": "[email protected]",
    "documento_identidad": "72345678",
    "fecha_nacimiento": "2010-05-15",
    "telefono": "+51 987 654 322",
    "activo": true,
    "created_at": "2026-03-05T10:30:00.000000Z",
    "updated_at": "2026-03-05T14:45:00.000000Z"
  }
}

Delete User

curl -X DELETE "https://api.example.com/api/users/1" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"

Path Parameters

id
integer
required
The unique identifier of the user to delete

Response

{
  "success": true,
  "message": "Usuario eliminado con éxito",
  "data": null
}
Deleting a user will cascade delete all associated registrations where this user is either a student (estudiante_id) or teacher (docente_id).

User Roles

The system supports different user roles:
  • estudiante: Student users who can be enrolled in courses
  • docente: Teacher users who can teach sections and grade students
  • administrador: Administrative users with full system access
The rol field should contain one of these values when creating or updating users.

Build docs developers (and LLMs) love