Change a private product
update_foodEdit a Fitatu food product you created: change its nutrients, name, brand, or servings by food_id. Omitted fields stay unchanged, but logged rows may update.
Instructions
Change one of the user's own products (create_food's food_id or a get_my_foods PRODUCT hit's food_id): any value create_food takes but unit; what is not given stays as it is, and servings replaces the list. Any other product is refused before anything is changed (that check reads it). Fitatu usually changes the product in place (replaced_food_id null), and rows already logged with it then show the new values too. It may save the change as a new product instead (seen after a rename or new servings): food_id is then the new id and replaced_food_id the old, retired one, and rows logged before keep the old values. Before changing a product the user has logged, tell them their logged rows may change. Returns measures as create_food does and previous, which update_food takes on food_id to undo the change. data.ok says the server accepted it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | The product's name, e.g. 'Baton owsiany'. | |
| brand | No | Its brand, if the label has one. | |
| fat_g | No | Fat in g in 100 g (100 ml for a drink), as the label gives it. | |
| salt_g | No | Salt in g. | |
| barcode | No | The 8 to 14 digits under the bars. Only the user sees it; find_by_barcode then finds this product. | |
| fiber_g | No | Fibre in g. | |
| food_id | Yes | create_food's food_id, or a get_my_foods PRODUCT hit's food_id. | |
| servings | No | Every serving of it, each name once; replaces the list. | |
| sugars_g | No | Of which sugars, in g; at most carbohydrate_g. | |
| protein_g | No | Protein in g in 100 g (100 ml for a drink), as the label gives it. | |
| energy_kcal | No | Energy in kcal, not kJ, in 100 g (100 ml for a drink), as the label gives it. | |
| carbohydrate_g | No | Carbohydrate in g in 100 g (100 ml for a drink), as the label gives it. | |
| saturated_fat_g | No | Of which saturated fat, in g; at most fat_g. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| data | No | ||
| error | No | describe_error() of what went wrong; docs/AGENTS.md, Results and errors. |