Endpoint
Get All Categories
Retrieve all product categories ordered by ID (newest first).Response
Response Fields
Unique category identifier
Category name (max 50 characters)
Category description (max 200 characters)
Hex color code for UI display (e.g., “#2e6df6”)
Category status (e.g., “ACTIVO”, “INACTIVO”)
Creation timestamp
Last update timestamp (null if never updated)
Create Category
Create a new product category.Request Parameters
Category name (max 50 characters, must be unique)
Category description (max 200 characters)
Hex color code for UI display
Category status (e.g., “ACTIVO”, “INACTIVO”)
Validation Rules
- nombre: Required, maximum 50 characters, must be unique
- descripcion: Optional, maximum 200 characters
- color: Optional, defaults to
#2e6df6 - estado: Optional, defaults to
ACTIVO
Response
Update Category
Update an existing category’s information.Request Parameters
Category ID to update (must be greater than 0)
New category name (max 50 characters)
New category description (max 200 characters)
New color code
New category status
Validation Rules
- id: Required, must be greater than 0, category must exist
- nombre: Required, max 50 characters, must be unique (excluding current category)
- descripcion: Optional, max 200 characters
- Updates
fecha_actualizaciontimestamp automatically
Response
Delete Category
Delete a category from the system.Request Parameters
Category ID to delete (must be greater than 0)
Validation Rules
- id: Required, must be greater than 0, category must exist
- Cannot delete if category has associated products
- Checks
productostable for foreign key relationships - Supports multiple column name patterns:
categoria_id,id_categoria,categoria,categoriaId
Response
Advanced Foreign Key Detection
The delete operation includes intelligent foreign key column detection:Database Schema
Categories are stored in thecategorias table:
Error Codes
| Error Message | Cause | Solution |
|---|---|---|
Datos inválidos | Invalid JSON | Check JSON syntax |
El nombre es obligatorio | Missing nombre | Include nombre in request |
El nombre no puede superar 50 caracteres | Name too long | Shorten category name |
La descripción no puede superar 200 caracteres | Description too long | Shorten description |
Ya existe una categoría con este nombre | Duplicate name | Use different name |
ID inválido | Invalid ID | Provide valid ID > 0 |
Categoría no encontrada | Category doesn’t exist | Check category ID |
No se puede eliminar. Tiene X producto(s) asociado(s) | Has products | Remove products first |