Skip to content

Recipe API

Recipe storage, the unified library, conditional edits, private Favorites, the Meal Space Tag vocabulary with rename and delete, Recipe-linked Entries, Variations, Notes, Copy and Transfer, and allowance archival, import, images, and public links are implemented. The sync protocol also transports Recipe library data and supported Recipe, Variation, and Note commands. Ordinary Recipe routes accept first-party sessions, API keys, and OAuth access tokens. Public-link management requires a first-party session; importing a public link accepts any credential family. Routes use a user-scoped database client, the standard envelope, and no-store caching. Image reads return JPEG bytes instead of a JSON envelope.

Method and pathScopeBehavior
GET /api/v1/recipesreadBrowse or search active Recipes in every readable Meal Space.
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}readRead one active Recipe.
POST /api/v1/meal-spaces/{groupId}/recipeswriteCreate with a client-generated UUID.
PATCH /api/v1/meal-spaces/{groupId}/recipes/{recipeId}writeApply a conditional edit.
DELETE /api/v1/meal-spaces/{groupId}/recipes/{recipeId}deleteDelete. Owner and Admin only in a shared Meal Space.
PUT /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/favoritewriteSet the caller's private Favorite.
GET /api/v1/meal-spaces/{groupId}/tagsreadRead the Meal Space Tag vocabulary.
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/deletion-previewreadList future planned Entries a deletion would change, and any live recurring meal that would block it. Owner and Admin only.

Content

RecipeContent is the editable base of a Recipe and the unit every command compares. It has title, description, ingredients, instructions, prep_minutes, cook_minutes, total_minutes, yield_quantity, yield_unit, source_url, and tags. Keys are strict.

Save trims outer whitespace, drops blank rows and blank Tags, and dedupes Tags by their trimmed, lowercased key. It never changes internal whitespace, line breaks, capitalization, or punctuation. Limits come from packages/core/src/recipes/limits.ts:

  • Title 1 to 200 characters. Description up to 5,000.
  • Up to 250 Ingredient lines and 200 Instruction steps, 2,000 characters each. Section headings do not count toward those limits. Each list allows 50 headings of up to 100 characters, and every heading needs a content row after it.
  • Minutes are whole numbers from 0 to 525,600, or null.
  • yield_quantity (positive, at most 100,000) and yield_unit (1 to 50 characters) are both present or both null.
  • source_url must be http or https, at most 2,048 characters.
  • Up to 20 Tags of 1 to 50 characters.

An Ingredient row is { "kind": "section", "heading" }, { "kind": "ingredient", "text" }, or a confirmed quantity: { "kind": "ingredient", "text", "quantity_source": "user", "qty", "qty_max"?, "unit"?, "package_quantity"?, "package_unit"? }. The server stores the authored line and nothing the parser guessed (D-177). Clients call resolveIngredient and scaleIngredient from @togethermeals/core to display parsed and scaled quantities. Instruction rows are sections or { "kind": "step", "text" }.

The contract reports the first failing rule by code (orphan_heading, invalid_yield, and so on) in the 422 details. The database repeats every check and is the authoritative gate.

Commands

Every command needs a UUID Idempotency-Key, the caller's current membership_id, and a millisecond client_updated_at with an explicit offset. The database derives the actor, checks the Membership period, and authorizes a fixed action: content.write to create and edit, content.administer to delete. A replay with the same key returns the original result. The same key with a different body returns 409. Receipts and activity (recipe.created, recipe.updated, recipe.deleted) hold only the Recipe ID.

Create also takes id and import_source (manual, url, paste, ai). The result lists up to 20 source_match_ids: other active Recipes in the same Meal Space whose source URL normalizes to the same value. The match is informational and never blocks the save (D-140). A Personal Meal Space without Pro holds at most five active Recipes. The sixth create returns 403 pro_required before anything is written. Shared Meal Spaces and Pro accounts have no cap.

Edit sends opening_revision, the opening content the editor loaded, and the local candidate. The database compares ten units: title, description, prep_minutes, cook_minutes, total_minutes, yield (quantity and unit together), source_url, ingredients, instructions, and tags. A unit the editor did not change keeps the current value. A unit only the editor changed takes the candidate. When both sides changed a unit to different values, the response is 200 with outcome: "conflict", the collisions, a merged candidate, and the current content. A conflict writes nothing, including its receipt, so the client can resolve and retry with the same key or send the resolution against the returned revision (D-178). When opening_revision equals the current revision, the stored Recipe is the opening. A canonical no-op returns unchanged with no revision change or activity.

Delete returns stale without deleting when the Recipe was saved with a later client_updated_at. A live recurring meal (active, paused, or suspended) referencing the Recipe blocks deletion first, with 409 conflict — "A recurring meal still uses this Recipe. Change it to other content or end it first." Only once no live recurring meal references it does the future-Entry check run: future planned Recipe Entries (dated Today or later) block deletion with 409 until the request sets future_entries to convert_to_simple or remove (D-137). Conversion keeps each Entry's date, Slot, title, notes, and position and clears its Recipe fields. Both choices write ordinary Entry activity. Past Entries never block deletion; they keep their saved title and target label. The deletion preview lists the affected future Entries, counts the past ones, and lists any blocking active_recurrences; see Recurring meals.

Favorite is private. Any reader, including a Viewer, may set it. It follows the ordinary preference last-write-wins rule, writes no shared activity, and survives leaving and rejoining.

Library

GET /api/v1/recipes spans every Meal Space the caller can read. Timeline visibility does not narrow it (D-157). Query parameters:

  • q: up to 200 characters. Each run of letters and digits becomes a prefix term, and all terms must match. Punctuation never causes an error. Title matches rank above Tags, and Tags rank above description, Ingredient lines, and source host. Instructions are not searched.
  • meal_space_id and tag: repeatable. Tags use AND and compare by lowercased key.
  • favorites=true: only the caller's Favorites.
  • limit: 1 to 50, default 50.
  • after: the opaque next_after from the previous page.

Active Variation names are searchable, and a Tag filter matches when the base Recipe or one active Variation's effective Tags contain every selected Tag; Tags never combine across versions (D-158). Each item's matched_variation names the Variation that produced the match, or is null.

Without q, results sort by most recent explicit use, then latest update, then title. Each item carries its Meal Space id, name, and color. Allowance-archived Recipes stay out of the library and of GET detail; see allowance archival for their own reads. Recipe detail carries archive, which is null except on those scoped reads.

Variations

A Variation is a named version of its Recipe that stores only what differs (D-130). Each of description, ingredients, instructions, prep_minutes, cook_minutes, total_minutes, and yield is absent (inherit the current Recipe value), { "state": "replace", "value": ... }, or { "state": "clear" }. Lists and the yield pair replace as a whole. tags_override_state is inherit, replace (with tags), or clear. Title and source URL never vary. effectiveRecipe in @togethermeals/core computes what a cook sees; clients never merge Variations by hand.

Method and pathScopeBehavior
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/variations?archived=falsereadActive Variations by name, or the Archived management list with archived=true.
POST /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/variationswriteCreate.
PATCH /api/v1/meal-spaces/{groupId}/variations/{variationId}writeSave name, overrides, and Tags (last write wins, D-167).
POST /api/v1/meal-spaces/{groupId}/variations/{variationId}/duplicatewriteCopy an active Variation under a new name.
POST /api/v1/meal-spaces/{groupId}/variations/{variationId}/removedeleteArchive when Entries or Notes reference it, otherwise delete. Blocked while a live recurring meal uses it.
POST /api/v1/meal-spaces/{groupId}/variations/{variationId}/restorewriteRestore with the same identity.
GET /api/v1/meal-spaces/{groupId}/variations/{variationId}/removal-previewreadSay whether removal archives, deletes, or is blocked, with reference counts.

Names are 1 to 100 characters and unique per Recipe by lowercased name, across active and Archived Variations; a clash returns 409. A Variation must Replace or Clear at least one field (D-166). A Replace equal to the current Recipe value is still a valid override. Editors, Admins, and the Owner manage Variations; Viewers read them. Activity (variation.created, variation.updated, variation.archived, variation.restored, variation.deleted) holds only IDs.

A live recurring meal (active, paused, or suspended) referencing the Variation blocks removal entirely, whether it would otherwise archive or delete — the removal-preview's result is "blocked" and active_recurrences lists the referencing rules. Changing the rule's content or ending it clears the block; see Recurring meals.

An Entry may select one active Variation of its Recipe with variation_id. The Entry saves the Variation name as variation_name_snapshot; renames never rewrite it (D-168). A batch size uses the Variation's effective yield. Archived Variations stay linked to existing Entries but cannot be newly selected, edited, or duplicated until restored.

Notes

A Note is a dated observation about a Recipe, kept outside the Variation overlay (D-129). A Note is general (variation_id: null) or belongs to one active Variation.

Method and pathScopeBehavior
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/notes?variation_id=readGeneral Notes, plus the named Variation's Notes, newest first.
POST /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/noteswriteAdd a Note. Editors, Admins, and the Owner.
PATCH /api/v1/meal-spaces/{groupId}/notes/{noteId}writeEdit the body or scope. The author, an Owner, or an Admin.
DELETE /api/v1/meal-spaces/{groupId}/notes/{noteId}deleteDelete. The author, an Owner, or an Admin.

Bodies are plain text of 1 to 2,000 characters after line endings normalize and surrounding space trims. An edit that changes neither body nor scope returns unchanged and writes no activity. Editors cannot change another member's Note (403). Copied Notes, which arrive with Copy and Transfer, show "Copied note" and only Owners and Admins manage them. A departed author's saved name stays on the Note. Notes of an Archived Variation appear only when that Variation is named. Activity (note.added, note.edited, note.deleted) never keeps a body. A Variation with Notes archives instead of deleting.

Tags

Tags belong to the Meal Space and keep their first display spelling (D-142). Owners and Admins rename or delete a Tag across the Meal Space after checking the preview.

Method and pathScopeBehavior
GET /api/v1/meal-spaces/{groupId}/tags/{tagId}/change-previewreadCount affected Recipes and Variations.
PATCH /api/v1/meal-spaces/{groupId}/tags/{tagId}writeRename. A name that already exists returns 409; Tags never merge.
DELETE /api/v1/meal-spaces/{groupId}/tags/{tagId}deleteDelete the Tag and its links. Content is otherwise untouched.

Both change the affected Recipes' revision and search index. Activity (tag.renamed, tag.deleted) holds only the Tag ID.

Copy, Duplicate, and Transfer

Method and pathScopeBehavior
POST /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/copywriteCopy into a writable Meal Space; the same space is Duplicate, with an optional title.
POST /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/transferdeleteMove to another Meal Space with a new identity. Owner and Admin in a shared space.

A copy is independent (D-117). It takes the current base content, the active Variations, general Notes, and Notes of those Variations. Copied Notes keep their text and date, show "Copied note", and carry no member identity. Tags resolve in the destination's vocabulary, reusing matching names. Archived Variations and their Notes, Favorites, usage, and History stay with the source. Later changes never flow in either direction.

Any reader may copy out; the destination needs write access and capacity. A Free Personal Meal Space at five active Recipes refuses the copy with 403 pro_required, and nothing is created or archived to make room. Transfer is blocked by the same live-recurring-meal check as deletion, using the same deletion preview. Transfer needs future_entries, which resolves future planned Recipe Entries exactly like deletion; block returns 409 when any exist. The copy and the source deletion commit together. Allowance-archived Recipes cannot be copied or transferred.

Nutrition

Nutrition is one shared, saved result per Recipe or Variation (D-219). Any key that can read the Meal Space sees it; changing it needs write scope, content.write and the caller's own Pro.

Method and pathScopeBehavior
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/nutritionreadThe saved nutrition, or null. ?variationId= selects a Variation.
POST /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/nutrition/generatewriteGenerate or regenerate with one metered AI action. Needs an Idempotency-Key, the variation_id (or null), and the expected_input_key and expected_version the client last saw.
PUT /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/nutrition/overrideswriteSet nutrients by hand, or null to clear one. Free of charge; whole-recipe values.
GET /api/v1/me/ai-featuresreadThe AI operations this deployment offers (nutrition only when USDA is configured).

Generate returns { "status": "saved", "nutrition": ... } or { "status": "failed", "reason": "unusable" | "provider_unavailable" }; a failure charges nothing. It answers 409 when the ingredients, or the saved version, no longer match what the client sent or the result is already current, 422 when there are no food lines, and 403 pro_required without Pro. Both lists grow: a later API may list an AI operation or return a failure reason that a client has never seen. enabled_operations holds short identifiers, and a client ignores the ones it does not know; a client treats an unknown reason as a failure that charged nothing. The routes accept write-scope API keys like the import routes and are not MCP tools. Setup: Recipe nutrition.

Allowance archival

Method and pathScopeBehavior
GET /api/v1/me/recipe-allowancereadYour Free limit, active and archived counts, your choice, and the Recipes that stay active if Pro ends now.
PUT /api/v1/me/recipe-allowancewriteReplace your choice of up to five Personal Recipes to keep. Pro accounts only.
GET /api/v1/recipes/archivedreadArchived library mode: locked management rows.
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/archivedreadRead a locked Recipe for export.
GET /api/v1/meal-spaces/{groupId}/entries/{entryId}/recipereadRead the Recipe and Variation an Entry cooks.

A Free Personal Meal Space keeps five active Recipes (D-101). When trial or paid Pro ends, the server keeps five and archives the rest. When Pro returns, it restores all of them (D-138). Your choice comes first, then the library's recent-use order, then the most recently updated. You can choose only while Pro is active; the choice holds up to five active Personal Recipes, and the lapse it decides uses it up. Choosing without Pro returns 409.

Pro ends by time, so no event marks the moment. The server settles the allowance before any command in the Personal Meal Space, whenever an entitlement is written or a trial starts, and every five minutes for accounts whose entitlement started or ended in the past week (D-181). For up to five minutes after a lapse, reads can still show the whole library; the first command settles it. Operators: see the allowance sweep runbook.

Archived Recipes are locked. They leave the library, Favorites, search, and GET detail, and RLS hides their Variations, Notes, and Tag links. Edits, Favorites, every Variation and Note command, new Entry links, Copy, Duplicate, and Transfer return 404. Delete still works. Existing Entries keep their link and stay editable, and Tag renames still reach locked Recipes. Each transition records one recipe.allowance_archived or recipe.allowance_restored activity with a count and no actor. Allowance depends on entitlement alone, so a pending account deletion is not a lapse, and any lapse uses up the keep choice even when nothing needs archiving.

GET /api/v1/recipes/archived takes q, meal_space_id, tag, limit, and after like the library and matches the base Recipe only. Rows carry the id, Meal Space, title, Tags, and archive (reason: "allowance" and archived_at), never cooking content. It has no Favorites filter.

Both scoped reads return the full Recipe read-only with archive set. The management read is for export (D-169). The Entry read returns {recipe, variation} for any Entry linked to a readable Recipe. For a locked Recipe it answers only while the Entry is planned and dated today or later in the Meal Space's timezone. Completing, skipping, or replacing the Entry, or the date passing, closes it. Notes are not included.

Import

Method and pathScopeBehavior
POST /api/v1/recipes/import-urlwriteTurn a Recipe page into an unsaved draft.
POST /api/v1/recipes/import-textwriteTurn pasted text into an unsaved draft with one AI action.
GET /api/v1/meal-spaces/{groupId}/recipe-source-matchesreadBefore saving, find destination Recipes with the same source.
GET /api/v1/me/ai-usagereadYour AI limit, committed actions, and live holds for the current period.

Import never writes a Recipe. The client keeps the draft for up to 24 hours and saves it with the ordinary create command, which checks capacity (D-106). The API sends only URL preparation and image downloads to the deterministic recipe-import fetcher, with the member's user JWT. Explicit assisted URL imports and pasted text execute in the API through provider adapters and server-only credit accounting. Paste import does not require RECIPE_IMPORT_URL. Provider requests carry provider credentials and bounded source text, with no member credential.

A URL import fetches the page itself. It connects only to public addresses, checks every redirect again, accepts ports 80 and 443 and HTML up to 3 MB, and gives up after ten seconds. It reads schema.org JSON-LD, then microdata, and prefers the page's canonical URL as the source. Results, in data.status:

  • draft: draft.content holds editable Recipe content, draft.image_url the image to fetch at Save, and draft.extraction is structured or llm. warnings lists every Save-time content issue; oversized content stays in the draft for the member to fix.
  • choose: the page holds several Recipes. Repeat the request with the chosen candidate_id. The service never picks by document order.
  • assist_required: no usable structured data. AI runs only when the request repeats with assisted: true after the member confirms the metered action (D-102).
  • failed: a closed reason such as blocked, timeout, not_html, unusable, or provider_unavailable. Clients offer paste mode (D-106).

Structured imports are free for everyone. AI imports and every paste import use the member's own Pro allowance: 25 actions across a trial, or 200 per UTC month. Without Pro the request returns 403 pro_required; with the allowance used up it returns 429 rate_limited. The service holds one action before calling the model and commits it only for a usable, schema-valid draft; any failure releases it, and a hold that cannot commit returns no draft (D-182). An Idempotency-Key pays for one model call: repeating it while that call runs or after it succeeded returns 409 conflict, so start a new import with a new key. A key whose attempt failed may be retried.

recipe-source-matches takes source_url and title. It returns every active Recipe in the destination Meal Space with the same normalized source URL, and can_edit for whether the member may review updates to it. Only when no source matches does it return same-title Recipes, as a warning and never as a target (D-140).

Images

Method and pathScopeBehavior
PUT /api/v1/meal-spaces/{groupId}/recipe-images/{imageId}writeIssue an upload slot, or return it again to the same member.

A Recipe has at most one image, and a Variation may replace or clear it. Clients do the image work: they decode the photo (HEIC included), drop its metadata, and upload two JPEGs. The master is at most 2,400 pixels on its long edge; the card is the size lists show. The server enforces the rest (D-184):

  1. The client picks an image id and calls the slot route. Any editor of the Meal Space may.
  2. Within a day, it uploads master.jpg and card.jpg to the returned paths in the private recipe-images bucket with its own Supabase session. Storage accepts JPEG up to 3 MB, only from the slot's creator, and never overwrites. Every reader of the Meal Space can download.
  3. It saves the Recipe or Variation with image: {id, crop?}. crop is a focal point x and y in 0..1 and a zoom of 1 to 4 against the master; omit it for the default centered view. The image is its own conflict unit. An edit that leaves image out leaves it unchanged; send null to remove it. A slot from another Meal Space, an unknown slot, or one being cleaned up returns 409 conflict.

Reads return image (or null) on Recipes and library cards, and Variation overrides carry an image override. Copy, Duplicate, Transfer, and Variation duplicate copy each included image into a fresh slot of the destination before the command runs, so copies never share objects. A retried command reuses its copies. Replacing, removing, or deleting frees the old image; a worker deletes an image a day after nothing references it, and removes every image of a deleted Meal Space. See the media runbook.

Step photos

Method and pathScopeBehavior
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/step-images/{imageId}?membership_id&size&variation_id?readA step photo the Recipe, or the named active Variation, shows, as private no-store JPEG.
GET /api/v1/meal-spaces/{groupId}/entries/{entryId}/recipe-step-images/{imageId}?membership_id&sizereadThe same through a qualifying Entry Recipe read.

An Instruction step may carry one photo (D-249): {kind: "step", text, image: {id, width, height}}. Upload it as any Recipe image (a slot, then master.jpg and card.jpg), then save the step with the slot id and the master's whole-pixel width and height (1 to 2,400). Step photos are never cropped. A step with a photo needs text, and one stored list (a Recipe's Instructions, or a Variation's Instructions override) holds at most 30 photos; either breach returns 422. The photo is part of its step, so it travels with the Instructions conflict unit and Variation line patches: an edit that sends a step back without image removes its photo, and a Variation may change only a line's photo. A read returns 404 unless the effective steps show that photo. Copy, Duplicate and Transfer copy step photos into fresh slots, as they do the Recipe image; a Variation duplicate and "Update the original" stay in one Meal Space and share them.

A member who may copy a Recipe out (Viewers and Free members too) may share the version on screen, the original or one active Variation, at https://<web origin>/r/{token} (D-217). The token is 32 base64url characters. Anyone holding it reads that version's effective cooking content; nothing identifies the Meal Space, its members, or their Tags, Notes and History.

Method and pathScopeSurfaceBehavior
GET /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/share-link?variation_id=readfirst-partyThe caller's live link to that version, or null, and links_enabled.
PUT /api/v1/meal-spaces/{groupId}/recipes/{recipeId}/share-linkwritefirst-partyBody {variation_id} (null for the original). Publishes the version, or returns the link the caller already made for it.
GET /api/v1/me/recipe-share-linksreadfirst-partyThe caller's links that still work, newest first, with title, version name and Meal Space.
DELETE /api/v1/me/recipe-share-links/{linkId}deletefirst-partyStops one of the caller's links: revoked, or unchanged when it was gone or not theirs.
POST /api/v1/meal-spaces/{groupId}/recipes/import-sharewriteanyBody {membership_id, client_updated_at, id, token} with an Idempotency-Key. Saves the version as a new Recipe.
PUT /api/v1/me/recipe-link-sharingwritefirst-partyBody {links_enabled} with an Idempotency-Key; returns the same. Off deletes every link the account made and refuses new ones (403 forbidden). GET /api/v1/me/recipe-share-links reports the current value.

Creating and revoking keep no receipt and take no Idempotency-Key: both are naturally idempotent, and a receipt would hold the token. The switch is not part of AccountPreferences, which installed builds parse strictly. A link stops when its Membership ends or loses copy-out, when the account turns links off or is pending deletion, and when the Recipe or the Variation it names is archived, removed, deleted or transferred. A rejoin is a new Membership and never revives an old link.

Import first replays a save that already completed under the same key and body, so a retry confirms it even after the sharer edits the Recipe or stops the link. Otherwise it resolves the link, copies its photo into a slot of the target derived from the command key (as Copy does), and runs an ordinary create with import_source: "url": capacity (pro_required for a full Free Personal library), role and Meal Space state apply, and a link that stopped returns 404. Tags never travel, and the copy is independent.

Method and pathBehavior
GET /public/recipe-links/{token}PublicSharedRecipe in the standard envelope: title, variation_name, description, Ingredients, Instructions (a step's photo is only {width, height}), times, yield, source, category, and image ({crop?} or null).
GET /public/recipe-links/{token}/image/{master,card}The photo the link shows, as image/jpeg.
GET /public/recipe-links/{token}/steps/{index}/image/{master,card}The photo of the Instructions row at index, as image/jpeg; 404 unless that row is a step with a photo.

These carry no credential and sit outside /api/v1 and the OpenAPI document; the SDK's readSharedRecipe reads the first and PublicSharedRecipeSchema validates it. Each spends a per-IP bucket (60 reads and 120 photos a minute) and answers an unknown, malformed, stopped or dormant token with the same 404. Responses send Cache-Control: no-store, X-Robots-Tag: noindex, nofollow, noarchive, noimageindex and Referrer-Policy: no-referrer. The web app renders /r/{token} on its server and sends the visitor's address with the ingress proof, so set the same INGRESS_PROOF_SECRET on the API and the web app.