Skip to main content

Overview

Units represent academic units of study within a section. Each unit belongs to a specific section and mathematical area (Aritmética, Álgebra, Geometría, or Trigonometría). Units can contain multiple topics and are organized by a customizable order.

Endpoints

List All Units

curl -X GET "https://api.example.com/api/units" \
  -H "Accept: application/json"

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Unidades listadas con éxito”
data
array
Array of unit objects
{
  "success": true,
  "message": "Unidades listadas con éxito",
  "data": [
    {
      "id": 1,
      "section_id": 1,
      "area": "Aritmética",
      "unidad": "Números Naturales",
      "descripcion": "Introducción a los números naturales y sus propiedades",
      "orden": 1,
      "created_at": "2026-03-05T10:30:00.000000Z",
      "updated_at": "2026-03-05T10:30:00.000000Z"
    },
    {
      "id": 2,
      "section_id": 1,
      "area": "Álgebra",
      "unidad": "Expresiones Algebraicas",
      "descripcion": "Fundamentos de álgebra y manipulación de expresiones",
      "orden": 2,
      "created_at": "2026-03-05T10:31:00.000000Z",
      "updated_at": "2026-03-05T10:31:00.000000Z"
    }
  ]
}

Create a Unit

curl -X POST "https://api.example.com/api/units" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "section_id": 1,
    "area": "Geometría",
    "unidad": "Figuras Planas",
    "descripcion": "Estudio de polígonos y figuras geométricas en el plano",
    "orden": 3
  }'

Request Body

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Unidad creada con éxito”
data
object
The created unit object
{
  "success": true,
  "message": "Unidad creada con éxito",
  "data": {
    "id": 3,
    "section_id": 1,
    "area": "Geometría",
    "unidad": "Figuras Planas",
    "descripcion": "Estudio de polígonos y figuras geométricas en el plano",
    "orden": 3,
    "created_at": "2026-03-05T10:35:00.000000Z",
    "updated_at": "2026-03-05T10:35:00.000000Z"
  }
}

Get a Unit

curl -X GET "https://api.example.com/api/units/1" \
  -H "Accept: application/json"

Path Parameters

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Unidad obtenida con éxito”
data
object
The unit object
{
  "success": true,
  "message": "Unidad obtenida con éxito",
  "data": {
    "id": 1,
    "section_id": 1,
    "area": "Aritmética",
    "unidad": "Números Naturales",
    "descripcion": "Introducción a los números naturales y sus propiedades",
    "orden": 1,
    "created_at": "2026-03-05T10:30:00.000000Z",
    "updated_at": "2026-03-05T10:30:00.000000Z"
  }
}

Update a Unit

curl -X PUT "https://api.example.com/api/units/1" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "section_id": 1,
    "area": "Aritmética",
    "unidad": "Números Naturales y Operaciones",
    "descripcion": "Introducción a los números naturales, sus propiedades y operaciones básicas",
    "orden": 1
  }'

Path Parameters

Request Body

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Unidad actualizada con éxito”
data
object
The updated unit object
{
  "success": true,
  "message": "Unidad actualizada con éxito",
  "data": {
    "id": 1,
    "section_id": 1,
    "area": "Aritmética",
    "unidad": "Números Naturales y Operaciones",
    "descripcion": "Introducción a los números naturales, sus propiedades y operaciones básicas",
    "orden": 1,
    "created_at": "2026-03-05T10:30:00.000000Z",
    "updated_at": "2026-03-05T11:45:00.000000Z"
  }
}

Delete a Unit

curl -X DELETE "https://api.example.com/api/units/1" \
  -H "Accept: application/json"

Path Parameters

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Unidad eliminada con éxito”
data
null
Returns null for successful deletions
{
  "success": true,
  "message": "Unidad eliminada con éxito",
  "data": null
}

Relationships

Section (Parent)

Each unit must belong to a section. The section_id field is a foreign key that references the sections table. When a section is deleted, all its units are automatically deleted (cascade delete).

Topics (Children)

A unit can have many topics. When a unit is deleted, all associated topics are automatically deleted (cascade delete).

Database Schema

The units table includes:
  • id - Primary key (auto-increment)
  • section_id - Foreign key to sections table (cascade delete)
  • area - Enum field: “Aritmética”, “Álgebra”, “Geometría”, “Trigonometría”
  • unidad - String field for unit name
  • descripcion - Text field for description (nullable)
  • orden - Integer field for display order (default: 0)
  • created_at - Timestamp for creation
  • updated_at - Timestamp for last update

Build docs developers (and LLMs) love