Answer Several Added Sugars Rows
Records your answers for several ingredient rows of the recipe's Added Sugars report in one request and returns the updated report in the same shape as reading it: data holds report, report_hash and confirmation, and version_id is the new version. Use it when a recipe has more than one row to answer: it saves ONE new version for all of them and rebuilds the report once, where answering row by row saves a version per row and needs a fresh If-Match for each.
items holds from 1 to 100 answers, each naming a different row by its ingredient row id (irow_...) and taking the same fields as answering a single row: action (accept_suggestion, set_contribution, add_contribution, remove_contribution or keep), then for set_contribution and add_contribution exactly one of added_sugars_grams (grams in this row at its current quantity) or added_sugars_per_100g, and an optional reason and supplier_reference.
The answers are saved together or not at all. If any row cannot take its answer, the whole request is refused with 422 added_sugars_rows_refused, rows names every such row with its reason, and nothing is saved. If the answers together put a row's, the batch's or a serving's added sugars above its total sugars, the request is refused with 422 added_sugars_exceed_total naming them, and nothing is saved. If both kinds of fault are in one request, the 422 is added_sugars_rows_refused and its rows also lists each row that breaks its own total sugars, with row_code added_sugars_exceed_total, so every bad row is marked in one round. Nothing is ever lowered to fit.
Saving a version ends any earlier confirmation of the report and takes the Added Sugars line off the recipe's nutrition and labels until the new report is confirmed. Send the recipe's current version_id in the If-Match header.
recipe_id*Recipe IdIf-Match*stringThe 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.
application/json- body
Answers for several ingredient rows, saved together as one new version.
items*array<>One answer per row, from 1 to 100 items, each naming a different row. Each item takes the same fields as answering a single row (action, added_sugars_grams or added_sugars_per_100g, reason, supplier_reference). All items are saved together or none are: if any row cannot take its answer, nothing is saved.
1 <= items <= 100Successful Response
application/json- response
GET Added Sugars report response envelope.
This is the shared envelope for reading, patching and confirming the report.
data*The report of one recipe version and its confirmation state.
meta*Response metadata.
version_id?|The version the report was read at; pass it as If-Match on the next change to this report. Null only for a recipe that was never versioned. The ETag is derived from it and does not change when confirmation changes, so do not use the ETag to detect that.
curl -X PATCH 'https://api.bettermenu.live/studio/recipes/string/added-sugars-report/rows' \ -H 'If-Match: string' \ -H 'Content-Type: application/json' \ -d '{ "items": [ { "action": "accept_suggestion", "ingredient_row_id": "stringstringstringstringst" } ]}'{ "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" }, "meta": { "version": "string", "request_id": "string", "timestamp": "string" }, "version_id": "string"}