Compute Nutrition Facts
Compute compliant-rounded nutrition facts for a serving.
Applies compliant rounding rules to produce per-serving and optionally per-container nutrition facts.
The top-level version_id identifies the new version created by
this operation. Pass it back as If-Match on the next mutation.
409 scenarios and recovery:
- MISSING_DEPENDENCY: no nutrition -> call computeRecipeNutrition
- STALE_DEPENDENCY: ingredients changed since nutrition was computed -> recompute nutrition
- MISSING_DEPENDENCY: no serving -> call addRecipeServing After fixing, retry this call.
Available only on API versions declaring the recipe_versioning
capability. Older versions fall through to the legacy endpoint at
POST /nutrition-facts (no version_id stamping).
Related endpoints:
- computeRecipeNutrition — compute batch nutrition (prerequisite)
- getRecipePerServingNutritionFacts — retrieve the stored result
Path Parameters
Header Parameters
Optimistic-concurrency token. Pass the version_id returned by the previous mutation (or by GET /recipes/{id}/versions) so the server can reject the request when another writer has advanced the recipe in the meantime. A mismatch surfaces HTTP 412 with the current version_id in the response body so the client can decide whether to retry, merge, or surface the conflict to the user. Only consumed on API versions that declare the recipe_versioning capability — older versions ignore the header.
Response Body
application/json
application/json
curl -X POST "https://loading/studio/recipes/string/servings/string/nutrition-facts/compute"{
"data": {
"recipe_id": "string",
"serving_id": "string",
"per_serving": {
"calculated_at": "string",
"serving_id": "string",
"demographic": "string",
"reference_weight_grams": 0,
"nutrients": [
{
"bmid": "string",
"name": "string",
"amount": 0,
"unit": "string",
"display_text": "string",
"percent_daily_value": 0
}
]
},
"per_container": {
"calculated_at": "string",
"serving_id": "string",
"demographic": "string",
"reference_weight_grams": 0,
"nutrients": [
{
"bmid": "string",
"name": "string",
"amount": 0,
"unit": "string",
"display_text": "string",
"percent_daily_value": 0
}
]
}
},
"meta": {
"version": "string",
"request_id": "string",
"timestamp": "string"
},
"version_id": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string",
"input": null,
"ctx": {}
}
]
}