Skip to content

API conventions

These rules apply to authenticated /api/v1 routes. OAuth protocol endpoints, public Recipe reads, and binary image responses have their own formats.

Envelopes and errors

JSON successes return { "data": ..., "meta": { "request_id": ..., "timestamp": ... } }. data may be a resource, a page, a draft, or a command outcome. A 200 response alone does not mean a requested change was applied: Entry results can be stale, and conditional Recipe edits can return outcome: "conflict" without writing anything.

Errors use the same metadata with an error object:

{
  "error": {
    "code": "validation_error",
    "message": "Check the request fields and try again.",
    "details": [{ "path": "title", "message": "Invalid value." }]
  },
  "meta": {
    "request_id": "0f0b0000-0000-4000-8000-0000000000ff",
    "timestamp": "2026-10-27T18:00:00.000Z"
  }
}

details is optional. Branch on error.code, not the human-readable message. The complete PublicErrorCode enum is available in the interactive REST reference and the OpenAPI document. Common cases are:

HTTP statusMeaning and examples
400Malformed path/query or cursor, including invalid_cursor
401Missing, invalid, expired, revoked, or no-longer-entitled credential
403Missing scope, first-party restriction, insufficient role, pro_required, or account_deletion_pending
404Resource absent or unreadable by this caller; do not infer another space's contents
409Changed/in-flight command, domain conflict, meal_space_read_only, or manifest_changed
412precondition_failed; refresh the relevant content before trying a new action
413Payload too large where the route uses that status
422Body/header validation or a route-specific input failure
429Request rate limit, AI attempt limit, or exhausted AI credits
500 / 503Internal error or unavailable dependency; internal details are not returned

Zod path/query failures return 400; body/header failures return 422. Some route-specific limits use 422 rather than 413. Authentication and scope checks can reject a request before validation.

Request correlation and caching

Send a UUID in X-Request-ID if you need to correlate a call. Missing or invalid values are replaced. The response header and meta.request_id carry the same ID. Retain it for diagnostics, along with the status and error code, without retaining the credential.

/api/v1/* responses, including errors, send Cache-Control: no-store. Native reads may send Cache-Control: no-cache as a request header. React Native's fetch cache option adds a query parameter, which strict route validation rejects.

Dates, identity, and authorization

Meal dates are YYYY-MM-DD calendar dates in the Meal Space's Planning timezone. Date windows include from and exclude to. An Entry conflict timestamp is a separate instant: client_updated_at requires milliseconds and an explicit UTC offset.

{groupId} identifies a Meal Space. A membership_id identifies one Membership period, so leaving and rejoining produces a different write authority. Get current IDs through GET /api/v1/sync/access; never substitute another actor's Membership ID. Revision and journal positions are decimal strings, not JavaScript numbers.

Pagination

There is no universal pagination envelope or cursor encoding. Most collections put items and their continuation inside data:

ReadContinuation
Entriesdata.next_after is a UUID; send after with the same from/to window. At most 200 items per page.
Recipe libraryOpaque data.next_after; send after with unchanged filters. limit is at most 50.
API keysOpaque data.next_after; send after. limit is at most 100.
Access manifestOpaque data.next_cursor; send cursor until complete: true. At most 100 items per page. Restart on manifest_changed.
Sync snapshot/deltaUse the signed cursors and completion markers described in sync. Empty pages can still advance progress.

Treat opaque cursors as strings and URL-encode them. Preserve the original query when continuing. Do not invent page, offset, or a ts|id format across routes. Online collection pages can change during a scan; use the scoped sync protocol when maintaining an authoritative offline replica.

Idempotency and conflicts

Use a UUID Idempotency-Key when the route declares it. This applies to many PATCH, PUT, and DELETE commands as well as POST. Some naturally repeatable operations need no header. Sync push instead carries stable operation IDs inside its commands.

For replayable commands, keep the exact body, timestamp, identity, and key after an uncertain response. A changed payload cannot reuse the key. Authorization is checked again, so an old receipt cannot restore lost Membership or entitlement. Receipts may return only IDs and outcomes; fetch current content after a result.

Exceptions need their own recovery:

  • Entry writes use last-write-wins conflict timestamps and can return stale without changing content. Do not replace the timestamp just to force an uncertain retry through.
  • Recipe conditional edits can return a 200 conflict containing current content and collisions. They write no receipt on conflict. Follow the Recipe edit protocol to resolve and retry rather than blindly resubmitting an old candidate.
  • AI generation keys pay for one call and do not replay a successful output. Reuse while running or after success returns 409. A failed attempt may reuse its key. Do not automatically regenerate after a timeout; a new explicit generation with a fresh key can spend another credit. See suggestions.
  • API-key creation shows plaintext once and cannot replay it. After a lost response, inspect the key list before creating another key.
  • Grocery sends retain reviewed item identity; partial retries use the run's finish route. Follow the integration retry rules.

Rate limits and AI allowances

The request limiter is a token bucket backed by the database. It fails with 503 if the store is unavailable. Default account budgets are sessions 600/min, session sync 300/min, and programmatic credentials 300/min on Pro or 60/min on a trial. The caller's entitlement selects the programmatic budget. Promo redemption also spends 10/min per account.

Responses from this limiter include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset, an ISO timestamp. A limiter rejection includes integer seconds in Retry-After. Respect it. Do not treat each key as an independent account allowance.

AI has separate credits and temporary attempt limits. Read /api/v1/me/ai-usage and /api/v1/me/ai-features for allowance and deployment availability. Exhausted credits do not carry a short Retry-After; temporary attempt limits do. Read the relevant feature page before retrying a generation or nutrition request.

Payload and batch limits

The current sync push contract accepts 1 to 50 supported commands with individual accepted/rejected results. Its request body limit is 2 MiB. There is no general /batch endpoint and no blanket 100-command guarantee. Other limits depend on the operation; image upload, for example, accepts a private JPEG of at most 10 MiB. Schemas and shared constants define the bounds.

Versioning

Authenticated routes use /api/v1/*. Additive routes and optional fields can stay in that version. Existing repo policy calls for a new major path and documented migration window for breaking changes. Sync separately negotiates protocol and projection versions; a protocol_incompatible response requires the recovery described in sync.

Unversioned routes include /health, /metrics, /auth/login-method, /oauth/*, /.well-known/*, /public/recipe-links/*, and the public /openapi.json contract. The web app hosts /api-docs and its guides. See the versioning policy and changelog.