Skip to content
Skip to Content
Docs
Studio

Suggest Added Sugars Answers

Suggests an answer for each requested open Added Sugars row of the recipe and saves the suggestions on the report in ONE new version, for a person to accept, edit or override. A suggestion is a proposal: it appears on the row as suggested and counts in the report's readiness.suggested_rows, and no row is answered until a person accepts it (accept_suggestion). Rows a person has already answered are never changed. A row that already carries a current suggestion is returned as it is (already_suggested_row_ids) and not run, saved or charged again, so asking twice costs once; send refresh: true to replace it. The response is the updated report in the shape of reading it, with suggested_row_ids, left_open and config_version in data.

Rows beyond the request's allowance, rows whose food record could not be found and rows no suggestion settled get no suggestion and are returned in left_open for the person to answer. When no row gets a suggestion nothing is saved and version_id is the current version.

Every row is named by its ingredient row id (irow_...), the id of one ingredient row of this recipe and the id used to answer that row.

Send the recipe's current version_id in the If-Match header. A stale token is refused before any suggestion is made or charged.

The operation is served only while suggestions are switched on; otherwise it answers 403 suggester_not_enabled.

You are charged one credit per row that returns a confident or unsure suggestion that was saved. Rows left open, and rows that need a value from the supplier, are not charged.

POST
/studio/recipes/{recipe_id}/added-sugars-report/suggestions

Path Parameters

recipe_id*Recipe Id

Header Parameters

If-Match*string

The recipe's current version_id: the one the last change to this recipe returned, or the one reading the recipe returns (get_recipe). A stale value is refused with the current version_id; read the recipe again and retry.

Request Body

application/json
  1. body

The open rows a person wants suggestions for.

ingredient_row_ids*array<string>

Ingredient row ids (irow_...) of the recipe's open Added Sugars rows, each at most once. Ids that are not open rows of this recipe are ignored: they come back neither as a suggestion nor in left_open. An ingredient row id (irow_...) is the id of one ingredient row of this recipe, the same id used to answer that row. It is not a food-database ingredient id: two rows of one food have two row ids.

Itemsitems <= 15
refresh?Refresh

By default a row that already carries a current suggestion is returned as it is, in already_suggested_row_ids: it is not run again, not charged and not saved, so asking twice costs once. Send true to run those rows again, replace their suggestion and charge for them as new. A suggestion is current until the row's ingredient changes.

Defaultfalse

Response Body

Successful Response

application/json
  1. response

The shared report envelope, with the outcome of the request in data.

version_id is the version carrying the saved suggestions: pass it as If-Match on the next change. When no suggestion was saved it is the version that was current.

data*

The updated report, plus how this request went.

report, report_hash and confirmation are those of the report read, so the suggestions appear on the rows as suggested and the readiness counts them. A suggestion is a proposal: no row is answered until a person accepts, edits or overrides it.

meta*

Response metadata.

version_id?|

The version the report was saved at (or read at, when nothing was saved); pass it as If-Match on the next change to this report.

Example Request
curl -X POST 'https://api.bettermenu.live/studio/recipes/string/added-sugars-report/suggestions' \  -H 'If-Match: string' \  -H 'Content-Type: application/json' \  -d '{  "ingredient_row_ids": [    "string"  ]}'
Example Response
{  "data": {    "report": {      "market": "US",      "engine": {        "regulatory_package_version": "string",        "suggester_allowed": true,        "suggester_used": true,        "suggester_prompt_version": "string"      },      "determination": {        "basis": "batch",        "reference_weight_grams": "string",        "rows": [          {            "ingredient_row_id": "stringstringstringstringst",            "ingredient": {              "ingredient_id": "string",              "custom_ingredient_id": "stringstringstringstringst",              "custom_ingredient_version_id": "string",              "name": "string",              "quantity_grams": "string",              "total_sugars_per_100g": "string",              "total_sugars_grams": "string"            },            "derived": {              "resolution": "settled",              "path": [                {                  "question": "string",                  "answer": "yes",                  "docs_url": "string"                }              ],              "contributes": true,              "factor": "string",              "added_sugars_grams": "string",              "settled_by": "data_check",              "open_reasons": [                "sugars_missing"              ],              "citation": {                "authority": "regulation",                "cite": "string",                "quote": "string"              },              "added_sugars_per_100g": "string"            },            "suggested": {              "by": "suggester",              "confidence": "confident",              "added_sugars_grams": "string",              "quantity_grams_when_entered": "string",              "reason": "string",              "citation": {                "authority": "regulation",                "cite": "string",                "quote": "string"              },              "provenance": {                "model": "string",                "fallback_model_used": true,                "prompt_version": "string",                "config_version": 0,                "settled_by_stage": "string"              },              "question": "string",              "added_sugars_per_100g": "string"            },            "caller": {              "action": "accept_suggestion",              "added_sugars_grams": "string",              "quantity_grams_when_entered": "string",              "entered_added_sugars_per_100g": "string",              "reason": "string",              "supplier_reference": "string",              "actor": {                "type": "member",                "id": "string"              },              "channel": "studio",              "at": "2019-08-24T14:15:22Z"            },            "effective": {              "added_sugars_grams": "string",              "source": "data_check",              "added_sugars_per_100g": "string"            },            "checks": [              {                "id": "sugar_data",                "status": "ok",                "summary": "string",                "why_it_matters": "string",                "citation": {                  "authority": "regulation",                  "cite": "string",                  "quote": "string"                },                "docs_url": "string"              }            ]          }        ],        "totals": {          "added_sugars_grams": "string",          "total_sugars_grams": "string"        },        "declarations": [          {            "serving_id": "stringstringstringstrings",            "serving_description": "string",            "servings_per_container": "string",            "added_sugars_grams_per_serving": "string",            "total_sugars_grams_per_serving": "string",            "declared_grams": {              "outcome": "zero",              "value": "string"            },            "total_sugars_declared_grams": {              "outcome": "zero",              "value": "string"            },            "population": "adults_and_children_over_4",            "drv_grams": "string",            "percent_dv": "string",            "dv_basis": "unrounded_amount"          }        ],        "findings": [          {            "code": "row_added_sugar_invalid",            "row_id": "string",            "serving_id": "string"          }        ]      },      "presentation": {        "readiness": {          "total_rows": 0,          "settled_rows": 0,          "suggested_rows": 0,          "open_rows": 0,          "ready_to_confirm": true        },        "unresolved_rows": [          "stringstringstringstringst"        ],        "total_sugars_complete": true,        "rows_without_total_sugars": [          "stringstringstringstringst"        ]      },      "checks": [        {          "id": "sugar_data",          "status": "ok",          "summary": "string",          "why_it_matters": "string",          "citation": {            "authority": "regulation",            "cite": "string",            "quote": "string"          },          "docs_url": "string"        }      ]    },    "report_hash": "string",    "confirmation": "confirmed",    "suggested_row_ids": [      "string"    ],    "already_suggested_row_ids": [      "string"    ],    "left_open": [      "string"    ],    "config_version": 0  },  "meta": {    "version": "string",    "request_id": "string",    "timestamp": "string"  },  "version_id": "string"}

Recipe in, FDA-format Nutrition Facts out, with every version kept.

Start freeNo card needed.