Skip to content
merran
GitHubInstall

Merran documentation API & integrations

Apply a replacement to selected planned meals

POST
/api/list/items/{itemId}/substitutions
curl --request POST \
--url http://localhost:3000/api/list/items/0199e8b0-5a10-7a01-8b00-00000000001d/substitutions \
--header 'Content-Type: application/json' \
--data '{ "recipeId": "0199e8b0-5a10-7a01-8b00-000000000006", "ingredientId": "0199e8b0-5a10-7a01-8b00-000000000011", "state": "example-state", "targets": [ { "mealId": "0199e8b0-5a10-7a01-8b00-00000000001b", "revision": "2026-10-15T18:30:00.000Z" } ], "lines": [ "2 tbsp butter" ], "steps": [], "saveToLibrary": false }'

Signed-in household members only. Atomically saves meal-specific recipe snapshots and recalculates changed shopping foods with pantry deductions, preserving purchases and manual remainders. Library changes require saveToLibrary. Returns conditional Undo data.

itemId
required
string

Example

0199e8b0-5a10-7a01-8b00-00000000001d
Media typeapplication/json

Select linked planned meals. Each target may supply its own recipe, ingredient, state, lines and steps to replace a shared food across different recipes atomically. Without replacement, the top-level fields apply. With no targets, replace one manually added item using one ingredient line. Amounts are for each recipe as written. Saving to the library is explicit and restricted to a single recipe context.

object
ingredientId
required
string
lines
required
Array<string>
>= 1 items <= 5 items
steps
Array<object>
<= 20 items
object
stepId
required
string
text
required

The step, rewritten.

string
<= 5000 characters
recipeId
string
state
string
targets
required
Array<object>
<= 100 items
object
mealId
required
string format: uuid
revision
required
string
replacement
object
ingredientId
required
string
lines
required
Array<string>
>= 1 items <= 5 items
steps
Array<object>
<= 20 items
object
stepId
required
string
text
required

The step, rewritten.

string
<= 5000 characters
recipeId
required
string
state
required
string

Example

{
"ingredientId": "0199e8b0-5a10-7a01-8b00-000000000012",
"lines": [
"1 tbsp butter"
],
"steps": []
}
saveToLibrary
boolean

Example

{
"recipeId": "0199e8b0-5a10-7a01-8b00-000000000006",
"ingredientId": "0199e8b0-5a10-7a01-8b00-000000000011",
"state": "example-state",
"targets": [
{
"mealId": "0199e8b0-5a10-7a01-8b00-00000000001b",
"revision": "2026-10-15T18:30:00.000Z"
}
],
"lines": [
"2 tbsp butter"
],
"steps": [],
"saveToLibrary": false
}

Replacement applied.

Media typeapplication/json
object
undo
required
object
listId
string
meals
required
Array<object>
<= 100 items
object
mealId
required
string
expected
required
string
variants
required
Array<object>

Ingredients and instructions saved for one planned meal; the library recipe stays separate. Nutrition must be recalculated for substitutions.

object
recipeId
required
string
name
required
string
<= 500 characters
servings
required
number | null
> 0
basedOn
required
string
needs
required
Array<string>
<= 100 items
ingredients
required
Array
<= 500 items
object
id
required
string
section
required
string | null
text
required

The line as written.

string
quantity
required
number | null
quantityMax
required
number | null
unit
required
string | null
food
required
string | null
note
required
string | null
mark
required

What it is to the dish, as tidy up marked it: needed, swappable or optional. A dislike is left out of lines that aren’t needed. None until marked.

string | null
Allowed values: needed swappable optional
foodKey
string | null
steps
required
Array<object>
<= 500 items
object
id
required
string
section
required
string | null
text
required
string
library
required
object
recipeId
required
string
versionId
required
string
expected
required
string
manual
required
object
snapshot
required

An item as it was, to put it back (Undo).

object
id
required
string
list
required
string
name
required
string
>= 1 characters <= 200 characters
foodKey
required
string | null
<= 200 characters
quantity
required
number | null
unit
required
string | null
<= 40 characters
amountText
required
string | null
<= 60 characters
aisle
required
string | null
checked
required
boolean
source
required

How it got on the list: from the plan, typed in, every week, a usual buy, or the assistant.

string
Allowed values: plan typed every-week usual assistant
forMeals
required
Array<object> | null
<= 100 items
object
meal
required
string
quantity
required
number | null
unit
required
string | null
putAway

What checking it off put in the pantry, so unchecking takes it back out.

object
pantryItem
required

The pantry item it went into; null for household things and staples.

string | null format: uuid
quantity
required
number | null
unit
required
string | null
<= 40 characters
amountText
required
string | null
<= 60 characters
created
required

It made that pantry item, rather than joining one already there.

boolean
filledEmpty

It gave an amount to a pantry item that was there with none, so taking it back leaves that item with none again.

boolean
forMeals
required
Array<object>
<= 100 items
object
meal
required
string
quantity
required
number | null
unit
required
string | null
purchase
required

The purchase it recorded.

string format: uuid
lookedOverAt
required
string | null format: date-time
createdAt
required
string format: date-time
expected
required
string

Example

{
"undo": {
"listId": "0199e8b0-5a10-7a01-8b00-00000000001c",
"meals": [
{
"mealId": "0199e8b0-5a10-7a01-8b00-00000000001b",
"expected": "2026-10-15T18:30:00.000Z",
"variants": []
}
],
"library": null,
"manual": null
}
}

Invalid replacement.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
fields
object
key
additional properties
string

Example

{
"error": {
"code": "not_found",
"message": "There's nothing here.",
"fields": {
"name": "Give it a name."
}
}
}

Not signed in.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
fields
object
key
additional properties
string

Example

{
"error": {
"code": "not_found",
"message": "There's nothing here.",
"fields": {
"name": "Give it a name."
}
}
}

Not allowed.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
fields
object
key
additional properties
string

Example

{
"error": {
"code": "not_found",
"message": "There's nothing here.",
"fields": {
"name": "Give it a name."
}
}
}

Item or meal not found.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
fields
object
key
additional properties
string

Example

{
"error": {
"code": "not_found",
"message": "There's nothing here.",
"fields": {
"name": "Give it a name."
}
}
}

The list, meal or recipe changed; review again.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
fields
object
key
additional properties
string

Example

{
"error": {
"code": "not_found",
"message": "There's nothing here.",
"fields": {
"name": "Give it a name."
}
}
}

© 2026 Kyle Johnson. Documentation: CC BY 4.0. Merran: AGPL-3.0-or-later.