{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/bettermenu/json-schema/bettermenu-compute-conversions-request-schema.json",
  "title": "ComputeConversionsRequest",
  "description": "Batch conversion request.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/bettermenu-conversions-api-openapi.yml#/components/schemas/ComputeConversionsRequest",
  "properties": {
    "country_code": {
      "type": "string",
      "title": "Country Code",
      "description": "Market code (`US`), the same value `market` and a recipe's `country` take. Selects the ingredient data and conversion rules.",
      "default": "US"
    },
    "items": {
      "items": {
        "$ref": "#/$defs/ConversionRequestItem"
      },
      "type": "array",
      "maxItems": 50,
      "minItems": 1,
      "title": "Items"
    },
    "allow_estimation": {
      "type": "boolean",
      "title": "Allow Estimation",
      "description": "When true, use estimation for items without a deterministic portion match.",
      "default": false
    }
  },
  "type": "object",
  "required": [
    "items"
  ],
  "$defs": {
    "ConversionRequestItem": {
      "properties": {
        "ingredient_id": {
          "type": "string",
          "title": "Ingredient Id",
          "description": "BetterMenu ingredient ID (bmid)"
        },
        "quantity": {
          "type": "string",
          "title": "Quantity",
          "description": "Quantity as decimal string (must be > 0)"
        },
        "unit": {
          "type": "string",
          "title": "Unit",
          "description": "Unit (empty string for count-based)"
        },
        "portion_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Portion Id",
          "description": "A portion's id, from the ingredient's nutrition facts (`portions[].id`), to convert that portion directly instead of matching the unit. The only way to convert a branded product's default serving, which has no unit name: pass its id here instead of a unit."
        }
      },
      "type": "object",
      "required": [
        "ingredient_id",
        "quantity",
        "unit"
      ],
      "title": "ConversionRequestItem",
      "description": "Single item to compute conversion for."
    }
  }
}