Skip to content

Entry API

The Entry backend supports Simple, Recipe, Leftovers, Eating out, Placeholder, and Prep. See Recipe Entries for the Recipe link rules and Recurring meals for how an attached Entry behaves under ordinary Entry commands. The routes accept first-party sessions, API keys, and OAuth access tokens. They use user-scoped database clients, the standard success/error envelope, and no-store caching.

All paths below start with /api/v1/meal-spaces/{groupId}/entries.

Method and suffixBehavior
GETRead a calendar window with from, exclusive to, and optional UUID after.
GET /{entryId}Read one current Entry.
POSTCreate with a client-generated UUID.
PATCH /{entryId}Save complete editable content or an explicit status.
POST /{entryId}/moveChange date, Slot, or shared position within the same Meal Space.
POST /{entryId}/reorderMove up/down or place before/after a current neighbor in the same date and Slot.
POST /{entryId}/replaceCreate a new Entry and mark the original Replaced, atomically.
DELETE /{entryId}Hard-delete, with explicit confirm_history when the Entry is past.

Fields and reads

Entry dates are valid YYYY-MM-DD calendar dates in years 0001 through 9999. Prep has a null Slot; other types use breakfast, lunch, dinner, snack, or dessert. Multiple Entries may share a date and Slot. Titles are trimmed, nonempty, and limited to 200 characters; notes allow 10,000. Position is a string of 1 through 64 alphanumeric characters ordered using the database's C collation.

Reads return at most 200 Entries in a window of at most 410 days, ordered by immutable ID. Continue with next_after until null, retaining the same window. The client sorts the assembled online view by date, Slot, position, and creation time. These are live online pages, so concurrent moves may change their contents. They cannot establish snapshot completeness or offline access loss. Phase 3 supplies the separate sync snapshot/delta protocol.

revision is a decimal string. created_at and updated_at are server-owned. The client supplies client_updated_at with millisecond precision and an explicit UTC offset. Past planned Simple, Leftovers, and Eating out Entries have an effective Completed status; Prep and Placeholder do not. Core computes this from Today in the Meal Space's Planning timezone without rewriting stored status.

Commands and retries

Every mutation requires a UUID Idempotency-Key, the originating membership_id, and client_updated_at. The database derives the actor, checks the current Membership period, and uses content.write authorization. Editors may delete Entries. Removal, rejoin, role downgrade, account deletion, and shared read-only state are checked before replay or a new write.

Command results contain only outcome, entry_id, and nullable replacement_id. Outcomes are applied, unchanged, or stale. A timestamp no newer than the current row returns Stale without writing. For ordinary Entry edits and moves, a newer canonical no-op advances only the conflict timestamp and returns Unchanged without activity or a content revision change. A changed command under the same key returns 409. Missing-row edits return 404 and never create a row. Receipts retain no title or notes; after a result, fetch the current Entry through an authorized read.

Replacement preserves the original plan and links a new Entry on the same date and Slot. Further replacements form a chain with one predecessor per Entry and no cycles. Corrections to an earlier Replaced Entry retain its status and link. A move that would separate a chain returns 409, as does deleting an Entry still referenced by its predecessor. Deleting a past Entry requires History confirmation even if its stored status is still Planned.

Leftovers may link a same-space Entry on the same or an earlier date. Cycles are forbidden. Deleting the source clears the link while retaining the Leftovers title and notes. Invalid references disclose no other Meal Space's content. Failed link changes roll back every row, activity event, and receipt.

Activity types are entry.created, entry.edited, entry.moved, entry.replaced, and entry.deleted. Events contain Entry/replacement IDs, with actor identity in the existing event columns. They contain no meal content and are not sync journal references.

Recipe Entries

A Recipe Entry has entry_type: "recipe" and a recipe_id for an active Recipe in the same Meal Space. Planning in another space needs an explicit Copy first (D-157), so a Recipe from any other space returns not_found. Create and replace require recipe_id. Every other type carries no Recipe fields.

The Entry's title is a snapshot of the Recipe title, taken when the link is set or changed. The server ignores a client title for Recipe Entries, and later Recipe renames never rewrite it (D-132). target_yield_quantity optionally sets the batch size for this meal. It needs a positive base yield on the Recipe; otherwise the command returns 409. The server saves the Recipe's current unit as target_yield_unit (D-133, D-134). If the Recipe's unit later changes, scaling pauses until a member confirms the batch size in the new unit: send target_yield_unit with the Recipe's current unit, even when the number is unchanged. A different unit returns 409, and an ordinary save that carries the same number keeps the old unit.

recipe_id and target_yield_quantity are optional keys. An edit without them keeps the stored link and target, so commands queued by apps built before Recipe Entries still apply. Linking a Recipe or marking a Recipe Entry completed advances the Recipe's recent-use time, which orders the library (D-158).

A Recipe Entry may also select one active Variation of its Recipe with variation_id. The server saves the Variation name as variation_name_snapshot and never rewrites it after a rename (D-168). The batch size then uses the Variation's effective yield. Changing the Recipe, the Variation, or the number when the effective unit differs from the saved one returns 409 until the request names the new unit in target_yield_unit. Changing the Recipe without variation_id drops the Variation.

When a Recipe is deleted, past Entries keep their title and target label and lose only the live link. Future planned Entries block deletion until the member converts them to Simple Entries or removes them; see the Recipe API.

Recurring meals

An Entry can be attached to a recurring meal, which materializes it and keeps its content in line with the rule. See Recurring meals for creating, editing, pausing, ending, and deleting rules. This section covers only how ordinary Entry commands above interact with an attached Entry.

A server-side hook runs on any write to an attached Entry: before the row write for edit and move (in the same transaction), and after the row is gone for delete.

  • An ordinary status edit (Made, Skipped, and back to Planned) keeps the Entry attached. "Skip this time" on the Timeline is exactly this: an Entry edit to status: "skipped", not a recurring-meal command, so it works offline and after midnight.
  • A move that keeps the same date and Slot keeps the Entry attached.
  • A change to entry_date, slot, entry_type, title, recipe_id, variation_id, target_yield_quantity, target_yield_unit, or notes — including a move to a different date or Slot — detaches the Entry: the rule stops managing it, though the Entry still records which rule it originated from.
  • Replace keeps the original's link (it becomes replaced); the new Entry from replace has no link.
  • Deleting an attached Entry dated today or later does not simply lose the occurrence: it records a restorable skip that the rule's restore command can bring back. Deleting a past attached Entry records nothing further; History never regenerates.

Every Entry read, History item, and sync row carries two nullable recurrence fields:

  • recurring_meal_id names the rule that currently manages the Entry. It is null for an Entry that was never attached, and it clears when the Entry detaches.
  • recurrence_origin_id names the rule the Entry came from. It is kept after the Entry detaches, so a read can still say where the meal came from.

Neither field is accepted by create, edit, or replace; only recurring-meal commands and materialization set them. Deleting a rule clears both on its Entries. Both fields arrived with sync content projection 4.

Shared ordering

Reorder accepts membership_id, client_updated_at, entry_date, nullable slot, and either direction of up or down, or anchor_entry_id with side of before or after. Mixing these variants is invalid. Date and Slot guard the source's current schedule; a changed schedule or Replaced source returns 409. An anchor must be a different current Entry in the same Meal Space, date and Slot. A missing, moved or Replaced anchor returns 409. The command cannot reschedule a meal.

The server orders non-Replaced Entries within that bucket by position in C collation, creation instant, then UUID. It swaps the selected Entry with its immediate neighbor for a direction request, or removes the source and inserts it beside the anchor for a placement. It assigns bounded hexadecimal positions atomically. Only changed positions are written. Every changed row and the source must have an older client clock or the entire move returns Stale. A boundary move returns Unchanged without advancing clocks. An already satisfied placement also returns Unchanged without normalizing positions. Content, links and historical Replaced rows stay intact. The result uses the same content-free receipt and Membership-before-replay checks as other Entry commands. Each changed row receives its normal revision and sync journal reference. After a result, refresh the complete bucket or catch up its shared stream. Reading only the source misses changed sibling positions.

Both clients offer accessible up/down controls. Inside its complete saved window, native queues anchored placements online or offline, including around pending creations. /sync/push accepts kind: reorder only with anchored input. The local queue sends each reorder alone after earlier changes in that space settle; later changes wait for atomic catch-up and acknowledgment. Unknown results reuse the persisted operation ID and input across restarts.

Web and out-of-window native History use direct direction requests. Native History requires a connection, current write permission and a drained queue, then waits for a post-request sync cycle and local reload. Unknown direct results reuse the exact request while the screen is mounted; acknowledged results retry only the refresh.

The Entry provider now has journal, transport and local cleanup coverage. The online web Timeline at /plan reads these pages and sends these commands. Its local query keys include actor, Meal Space, Membership period and date window. The native Timeline uses leased SQLCipher pages and pending overlays behind the default-off scoped-sync flag.