Skip to main content
Recipes enable automatic inventory deductions by linking menu items to their ingredients. When an order is placed, RestAI automatically creates consumption movements for each ingredient.

How It Works

  1. Create a recipe that defines which inventory items a menu item uses
  2. Specify quantities - how much of each ingredient is consumed per menu item
  3. Automatic deduction - when the menu item is ordered, inventory is reduced automatically

Create Recipe

Define or update the ingredient recipe for a menu item.

Endpoint

POST /inventory/recipes

Request Body

menuItemId
string
required
UUID of the menu item
ingredients
array
required
Array of ingredients (minimum 1 item)
inventoryItemId
string
required
UUID of the inventory item
quantityUsed
number
required
Quantity consumed per menu item (must be positive)

Behavior

  • Replaces existing recipe: This endpoint deletes any existing ingredients for the menu item and creates new ones
  • Validates ownership: Ensures menu item and inventory items belong to the same branch

Response

Returns the created recipe ingredients.

Example Request

curl -X POST https://api.restai.app/v1/inventory/recipes \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "menuItemId": "550e8400-e29b-41d4-a716-446655440000",
    "ingredients": [
      {
        "inventoryItemId": "660e8400-e29b-41d4-a716-446655440000",
        "quantityUsed": 0.2
      },
      {
        "inventoryItemId": "770e8400-e29b-41d4-a716-446655440000",
        "quantityUsed": 0.1
      },
      {
        "inventoryItemId": "880e8400-e29b-41d4-a716-446655440000",
        "quantityUsed": 0.05
      }
    ]
  }'

Example Response

{
  "success": true,
  "data": [
    {
      "menu_item_id": "550e8400-e29b-41d4-a716-446655440000",
      "inventory_item_id": "660e8400-e29b-41d4-a716-446655440000",
      "quantity_used": "0.2"
    },
    {
      "menu_item_id": "550e8400-e29b-41d4-a716-446655440000",
      "inventory_item_id": "770e8400-e29b-41d4-a716-446655440000",
      "quantity_used": "0.1"
    },
    {
      "menu_item_id": "550e8400-e29b-41d4-a716-446655440000",
      "inventory_item_id": "880e8400-e29b-41d4-a716-446655440000",
      "quantity_used": "0.05"
    }
  ]
}

Get Recipe

Retrieve the ingredient recipe for a menu item.

Endpoint

GET /inventory/recipes/:menuItemId

Path Parameters

menuItemId
string
required
UUID of the menu item

Response

success
boolean
Request success status
data
array
Array of recipe ingredients
menu_item_id
string
Menu item UUID
inventory_item_id
string
Inventory item UUID
quantity_used
string
Quantity consumed (decimal string)
item_name
string
Inventory item name
item_unit
string
Unit of measurement
current_stock
string
Current stock level of this ingredient

Example Request

curl https://api.restai.app/v1/inventory/recipes/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

{
  "success": true,
  "data": [
    {
      "menu_item_id": "550e8400-e29b-41d4-a716-446655440000",
      "inventory_item_id": "660e8400-e29b-41d4-a716-446655440000",
      "quantity_used": "0.2",
      "item_name": "Tomate",
      "item_unit": "kg",
      "current_stock": "45.5"
    },
    {
      "menu_item_id": "550e8400-e29b-41d4-a716-446655440000",
      "inventory_item_id": "770e8400-e29b-41d4-a716-446655440000",
      "quantity_used": "0.1",
      "item_name": "Lechuga",
      "item_unit": "kg",
      "current_stock": "12.0"
    }
  ]
}

Recipe Example

Here’s a complete example of setting up automatic deductions for a “Hamburguesa Clásica”:
# 1. Create inventory items
curl -X POST https://api.restai.app/v1/inventory/items \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Carne molida", "unit": "kg", "currentStock": 50, "minStock": 10}'

curl -X POST https://api.restai.app/v1/inventory/items \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Pan para hamburguesa", "unit": "unidades", "currentStock": 200, "minStock": 50}'

curl -X POST https://api.restai.app/v1/inventory/items \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Queso cheddar", "unit": "kg", "currentStock": 10, "minStock": 2}'

# 2. Create recipe linking menu item to ingredients
curl -X POST https://api.restai.app/v1/inventory/recipes \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "menuItemId": "<HAMBURGUESA_ID>",
    "ingredients": [
      {"inventoryItemId": "<CARNE_ID>", "quantityUsed": 0.15},
      {"inventoryItemId": "<PAN_ID>", "quantityUsed": 1},
      {"inventoryItemId": "<QUESO_ID>", "quantityUsed": 0.03}
    ]
  }'
Now when a customer orders the “Hamburguesa Clásica”:
  • 0.15 kg of carne molida is deducted
  • 1 unit of pan is deducted
  • 0.03 kg of queso is deducted

Important Notes

  • Recipes are branch-specific - menu items and inventory items must belong to the same branch
  • Creating a recipe replaces any existing recipe for that menu item
  • Automatic deductions create consumption type movements
  • Stock can go negative if not enough inventory is available

Build docs developers (and LLMs) love