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
Indicates if the request was successful
Response message: “Unidades listadas con éxito”
Array of unit objects Unique identifier for the unit
Foreign key reference to the parent section
Mathematical area: “Aritmética”, “Álgebra”, “Geometría”, or “Trigonometría”
Description of the unit content (nullable)
Display order of the unit (default: 0)
When the unit was created
When the unit was last updated
{
"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
Indicates if the request was successful
Response message: “Unidad creada con éxito”
The created unit object Unique identifier for the unit
Foreign key reference to the parent section
Description of the unit content
Display order of the unit
When the unit was created
When the unit was last updated
Example Response (201 Created)
{
"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
Indicates if the request was successful
Response message: “Unidad obtenida con éxito”
The unit object Unique identifier for the unit
Foreign key reference to the parent section
Description of the unit content
Display order of the unit
When the unit was created
When the unit was last updated
{
"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
Indicates if the request was successful
Response message: “Unidad actualizada con éxito”
The updated unit object Unique identifier for the unit
Foreign key reference to the parent section
Description of the unit content
Display order of the unit
When the unit was created
When the unit was last updated
{
"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
Indicates if the request was successful
Response message: “Unidad eliminada con éxito”
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