Skip to main content
These endpoints let you define and modify the recipe for a dish — the set of ingredients and their required quantities. All endpoints require the dish id as a path parameter. Authentication: Bearer JWT required
If you add an ingredient that was previously removed from the dish, the system restores the soft-deleted record and updates its quantity rather than creating a duplicate entry.

POST /api/platos/:id/ingredientes

Adds an ingredient to a dish’s recipe. Required role: admin

Request

Path parameters

id
string
required
The dish ID (nanoid, 10 characters)

Body

ingrediente_id
string
required
The ID of the ingredient to add (must exist and not be soft-deleted)
cantidad
number
required
Required quantity of this ingredient per serving (min: 0.01)

Response

Success (201)

plato_id
string
Dish ID
ingrediente_id
string
Ingredient ID
cantidad
number
Required quantity per serving
creado_en
string
Creation timestamp (ISO 8601)
actualizado_en
string
Last update timestamp (ISO 8601)
borrado_en
string | null
Soft-delete timestamp — null for active records

Error responses

StatusDescription
400Ingredient is already added to this dish
401Unauthorized
403Forbidden — role is not admin
404Dish or ingredient not found

Example

curl -X POST http://localhost:3000/api/platos/aB3dEfGhIj/ingredientes \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "ingrediente_id": "abc123xyz",
    "cantidad": 2.5
  }'
{
  "plato_id": "aB3dEfGhIj",
  "ingrediente_id": "abc123xyz",
  "cantidad": 2.5,
  "creado_en": "2026-02-04T09:00:00.000Z",
  "actualizado_en": "2026-02-04T09:00:00.000Z",
  "borrado_en": null
}

GET /api/platos/:id/ingredientes

Returns the list of active ingredients in a dish’s recipe, joined with ingredient metadata. Required role: any authenticated user

Request

Path parameters

id
string
required
The dish ID (nanoid, 10 characters)

Response

Success (200)

An array of ingredient entries with joined ingredient data.
[].ingrediente_id
string
Ingredient ID
[].cantidad
number
Required quantity per serving
[].nombre
string
Ingredient name (joined from ingredientes table)
[].unidad
string
Unit of measurement (joined from ingredientes table), e.g. "kg", "lt", "unidad"

Error responses

StatusDescription
401Unauthorized
404Dish not found

Example

curl http://localhost:3000/api/platos/aB3dEfGhIj/ingredientes \
  -H "Authorization: Bearer <token>"
[
  {
    "ingrediente_id": "abc123xyz",
    "cantidad": 2.5,
    "nombre": "Maní tostado",
    "unidad": "kg"
  },
  {
    "ingrediente_id": "def456uvw",
    "cantidad": 1.0,
    "nombre": "Papa",
    "unidad": "kg"
  }
]

PATCH /api/platos/:id/ingredientes/:ingredienteId

Updates the quantity of a specific ingredient in a dish’s recipe. Required role: admin

Request

Path parameters

id
string
required
The dish ID (nanoid, 10 characters)
ingredienteId
string
required
The ingredient ID

Body

cantidad
number
required
New required quantity per serving (min: 0.01)

Response

Success (200)

message
string
Confirmation message: "Cantidad de ingrediente actualizada correctamente"

Error responses

StatusDescription
401Unauthorized
403Forbidden — role is not admin
404Dish not found or ingredient not in dish’s recipe

Example

curl -X PATCH http://localhost:3000/api/platos/aB3dEfGhIj/ingredientes/abc123xyz \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "cantidad": 3.0 }'
{
  "message": "Cantidad de ingrediente actualizada correctamente"
}

DELETE /api/platos/:id/ingredientes/:ingredienteId

Removes an ingredient from a dish’s recipe (soft delete on the plato_ingredientes record). Required role: admin

Request

Path parameters

id
string
required
The dish ID (nanoid, 10 characters)
ingredienteId
string
required
The ingredient ID to remove

Response

Success (200)

message
string
Confirmation message: "Ingrediente removido del plato exitosamente"

Error responses

StatusDescription
401Unauthorized
403Forbidden — role is not admin
404Dish not found or ingredient not in dish’s recipe

Example

curl -X DELETE http://localhost:3000/api/platos/aB3dEfGhIj/ingredientes/abc123xyz \
  -H "Authorization: Bearer <token>"
{
  "message": "Ingrediente removido del plato exitosamente"
}

Build docs developers (and LLMs) love