TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt
Use this file to discover all available pages before exploring further.
/productos/ router handles the cafeteria menu and ingredient inventory. Products belong to categories and optionally include a recipe — a list of ingredients and quantities consumed per unit sold. When an order is marked as ready (listo), the API automatically calls descontar_ingredientes(), which deducts ingredient stock based on these per-product recipes. This makes ingredient tracking live and automatic without any extra API calls from the client.
Categories
Categories classify both menu products and operational expenses. Thetipo field determines whether a category applies to products, expenses, or both.
GET /productos/categorias — List All Categories
Required role: Any authenticated user Returns all product/expense categories defined in the system. Use the returnedid values as id_categoria when creating products.
Response
Unique category identifier.
Display name of the category (e.g.
"Bebidas", "Comida", "Postres").Category applicability. One of:
"producto"— applies to menu items only"gasto"— applies to expense tracking only"ambos"— applies to both products and expenses
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
POST /productos/categorias — Create Category
Required role:admin
Creates a new category. Category names must be unique. Returns 201 Created on success.
Request Body
Unique display name for the new category.
Applicability type. Must be one of:
"producto", "gasto", "ambos".Response
Returns the newly createdCategoryOut object with HTTP 201 Created.
Example
Error codes
| Status | Detail |
|---|---|
400 | "La categoría ya existe" — a category with this name already exists |
401 | Token missing or expired |
403 | Authenticated user is not admin |
Ingredients
Ingredients represent the raw inventory items consumed when menu products are prepared. Each ingredient tracks current stock, a minimum threshold for low-stock alerts, and a unit cost for expense reporting.GET /productos/ingredientes — List All Ingredients
Required role: Any authenticated user Returns all ingredients ordered by ID ascending.Response
Returns an array ofIngredientOut objects. See IngredientOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
GET /productos/ingredientes/stock-bajo — List Low-Stock Ingredients
Required role: Any authenticated user Returns all ingredients wherestock_actual <= stock_minimo. Use this endpoint to power low-stock alerts and purchasing triggers. Returns an empty array if all ingredients are sufficiently stocked.
Response
Returns an array ofIngredientOut objects with the same shape as GET /productos/ingredientes.
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
GET /productos/ingredientes/ — Get Single Ingredient
Required role: Any authenticated user Retrieves a single ingredient by its numeric ID.Path Parameters
The unique ID of the ingredient to retrieve.
Response
Returns a singleIngredientOut object. See IngredientOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
404 | "Ingrediente no encontrado" — no ingredient with the given ID exists |
401 | Token missing or expired |
POST /productos/ingredientes — Create Ingredient
Required role:admin, cocina
Creates a new ingredient in the inventory. All numeric fields default to 0 if not supplied.
Request Body
Name of the ingredient (e.g.
"Café molido", "Leche entera").Unit of measurement (e.g.
"g", "ml", "piezas", "kg").Current stock level in the specified unit.
Threshold below which the ingredient appears in the low-stock list.
Cost per unit in the local currency, used for expense calculations.
Response
Returns the newly createdIngredientOut object with HTTP 201 Created.
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
403 | User role is not admin or cocina |
PATCH /productos/ingredientes/ — Update Ingredient
Required role:admin, cocina
Partially updates an ingredient’s metadata. Only fields included in the request body are modified; all others retain their current values. This endpoint updates the ingredient record itself — use ajustar-stock to increment or decrement stock by a delta value instead of setting it absolutely.
Path Parameters
The unique ID of the ingredient to update.
Request Body
All fields are optional.New name for the ingredient.
New unit of measurement.
Absolute new stock level (sets value directly — use
ajustar-stock for delta adjustments).New low-stock threshold.
New unit cost.
Response
Returns the updatedIngredientOut object.
Example
Error codes
| Status | Detail |
|---|---|
404 | "Ingrediente no encontrado" |
401 | Token missing or expired |
403 | User role is not admin or cocina |
PATCH /productos/ingredientes//ajustar-stock — Adjust Stock by Delta
Required role:admin, cocina
Adds or subtracts a quantity from the ingredient’s current stock. Positive cantidad values increase stock (e.g. restocking after a purchase); negative values decrease it (e.g. manual waste recording). The API rejects any adjustment that would result in a negative stock level.
Path Parameters
The unique ID of the ingredient to adjust.
Query Parameters
The delta to apply to
stock_actual. Positive values add stock; negative values subtract. The resulting stock_actual must be >= 0.Response
Returns a confirmation object with the updated stock level.Confirmation string:
"Stock actualizado".The new stock level after the adjustment.
Example
Error codes
| Status | Detail |
|---|---|
400 | "El stock no puede ser negativo" — the adjustment would push stock below zero |
404 | "Ingrediente no encontrado" |
401 | Token missing or expired |
403 | User role is not admin or cocina |
DELETE /productos/ingredientes/ — Delete Ingredient
Required role:admin
Permanently deletes an ingredient. The database enforces referential integrity: if the ingredient is referenced by any product recipe (ProductIngredient) or any purchase record, the deletion is blocked with a 400 error. Returns HTTP 204 No Content on success.
Path Parameters
The unique ID of the ingredient to delete.
Example
204 No Content with an empty body.
Error codes
| Status | Detail |
|---|---|
400 | "No se puede eliminar el ingrediente porque está siendo usado en productos o compras." |
404 | "Ingrediente no encontrado" |
401 | Token missing or expired |
403 | Authenticated user is not admin |
IngredientOut Response Shape
Unique ingredient identifier.
Ingredient name.
Unit of measurement (e.g.
"g", "ml", "piezas").Current quantity in stock expressed in
unidad.Low-stock alert threshold. Ingredients with
stock_actual <= stock_minimo appear in the /stock-bajo list.Cost per unit of measurement, used for expense calculations.
Products
Products are the menu items customers can order. Each product belongs to a category and may carry a recipe that links it to one or more ingredients with per-unit quantities.GET /productos/ — List Products
Required role: Any authenticated user Returns all menu products. Optionally filter by availability to show only items currently orderable.Query Parameters
Filter products by availability. Pass
true to list only orderable items; false for unavailable items. Omit to return all products regardless of status.Response
Returns an array ofProductOut objects. See ProductOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
401 | Token missing or expired |
GET /productos/ — Get Product with Recipe
Required role: Any authenticated user Retrieves a single product along with its full ingredient recipe. The response uses the extendedProductDetailOut schema which includes an ingredientes array detailing every ingredient and its per-unit consumption quantity.
Path Parameters
The unique ID of the product to retrieve.
Response
Returns aProductDetailOut object.
Array of recipe entries. Each object describes one ingredient used in this product.
ProductOut. See ProductOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
404 | "Producto no encontrado" |
401 | Token missing or expired |
POST /productos/ — Create Product
Required role:admin, cocina
Creates a new menu product and, optionally, its ingredient recipe in a single atomic operation. Returns 201 Created on success.
The
ingredientes field in the request body is optional — products can exist without a recipe. This is useful for items whose ingredients are not tracked in the inventory system, or for simple products that don’t consume trackable stock.Request Body
Name of the product as it should appear on the menu (e.g.
"Café Americano").Selling price per unit in the local currency.
Optional description shown to customers or staff.
ID of the category this product belongs to. Must be a valid ID from
GET /productos/categorias.Whether this product can currently be ordered. Defaults to
true.Optional URL to a product image for display in the ordering interface.
Recipe entries. Each entry links an ingredient ID to the quantity consumed per unit sold. If omitted or empty, the product is created without stock tracking.
Response
Returns the newly createdProductOut object with HTTP 201 Created. See ProductOut schema below.
Example
Error codes
| Status | Detail |
|---|---|
400 | "Ingrediente {id} no encontrado" — one of the supplied ingredient IDs does not exist |
401 | Token missing or expired |
403 | User role is not admin or cocina |
PATCH /productos/ — Update Product
Required role:admin, cocina
Partially updates a product’s metadata fields. Only the fields included in the request body are modified. This endpoint does not update the ingredient recipe — to modify the recipe, delete and recreate the product.
Path Parameters
The unique ID of the product to update.
Request Body
All fields are optional.New product name.
New description.
New selling price.
New category assignment.
New availability status.
New image URL.
Response
Returns the updatedProductOut object.
Example
Error codes
| Status | Detail |
|---|---|
404 | "Producto no encontrado" |
401 | Token missing or expired |
403 | User role is not admin or cocina |
PATCH /productos//toggle — Toggle Availability
Required role:admin, cocina
Flips the disponible boolean of a product in a single call — no request body required. If the product is currently available (true), it becomes unavailable (false), and vice versa. This is the recommended way to quickly take a product on or off the menu.
Path Parameters
The unique ID of the product to toggle.
Response
Returns the updatedProductOut object with the new disponible value reflected.
Example
Error codes
| Status | Detail |
|---|---|
404 | "Producto no encontrado" |
401 | Token missing or expired |
403 | User role is not admin or cocina |
DELETE /productos/ — Delete Product
Required role:admin
Permanently deletes a product and all its recipe (ProductIngredient) entries. The deletion is blocked if the product has any associated order line items in the database. Returns HTTP 204 No Content on success.
Path Parameters
The unique ID of the product to delete.
Example
204 No Content with an empty body.
Error codes
| Status | Detail |
|---|---|
400 | "No se puede eliminar el producto porque tiene pedidos asociados." — referential integrity block |
404 | "Producto no encontrado" |
401 | Token missing or expired |
403 | Authenticated user is not admin |
ProductOut Response Shape
Unique product identifier.
Product name as shown on the menu.
Optional description.
null if not set.Selling price per unit.
true if the product can currently be ordered; false if it has been taken off the menu.Nested category object.
null if no category has been assigned.ISO 8601 timestamp of when the product was created.