# Loafy API reference

Everything one baker's Loafy API key can do: their bake journal, starters, containers, flours, timers, challenges, Ask Loafy and settings, plus the book, the calculators and the guided journeys. Written for a developer or an AI agent working for that baker.

- Base URL: `https://loafy.ai/api/v1`
- Authentication: send `Authorization: Bearer loafy_…` with every call. The key is the baker's own, from https://loafy.ai/api_keys. It reads and changes everything below for that baker, deleting the account included, so keep it like a password. It can be revoked on the same page.
- Requests: JSON bodies with `Content-Type: application/json`. Photos go up as `multipart/form-data`, one photo per request.
- Responses: JSON. Most answer `{"success": true, "data": …}`; each entry below shows its own shape. A 204 has no body.
- Pictures: a bake's share, recipe and flowchart cards are PNG images at addresses on https://loafy.ai itself, outside `/api/v1`. The bake's `share_token` opens them, without a key (under Bake journal).
- Errors: `{"success": false, "error": {"code": "…", "message": "…"}}`. `code` is stable to switch on, `message` can be shown as it is. Only the two Pizza Calculator endpoints keep shapes of their own; their entries say so. A missing or wrong key gets 401 `unauthorized`, an invalid JSON body or a missing wrapper object a 400.
- Ids: most records have UUIDs. Where an entry says so, send your own UUID when you create a record, so a retried call lands on the same record instead of a twin.
- Language and time: texts come in the account's language, else in the one `Accept-Language` asks for. Times are ISO 8601. `X-Time-Zone` (an IANA zone such as `Europe/Berlin`) sets the zone of an account that has none yet.
- Stability: these are the endpoints Loafy's own iPhone and Android apps use. Fields are added over time, so read the ones you need and ignore the rest.
- Not listed: signing in (a key comes from https://loafy.ai/api_keys) and the admin endpoints, which need a different kind of key.

## Contents

- [Book, calculators and journeys](#book-calculators-and-journeys)
- [Profile and account](#profile-and-account)
- [Ask Loafy](#ask-loafy)
- [Bake journal](#bake-journal)
- [Starters](#starters)
- [Containers](#containers)
- [Flours and calculator defaults](#flours-and-calculator-defaults)
- [Kitchen timers](#kitchen-timers)
- [Guided journeys and first steps](#guided-journeys-and-first-steps)
- [Challenges and badges](#challenges-and-badges)
- [Gallery and baker pages](#gallery-and-baker-pages)
- [Fermentation sensor](#fermentation-sensor)
- [Used by Loafy's apps and devices](#used-by-loafys-apps-and-devices)

## Book, calculators and journeys

Loafy's tools as plain JSON: the bread and pizza calculators, the bake planner, the bulk fermentation estimate, the guided journeys, the book and the answers to bakers' questions. Also the newest videos and what each app release brought. Most of these answer without a key.

#### Tool

- `name`, string: What POST /api/v1/tools/:name takes, such as calculate_bread_dough.
- `title`, string: A name for people.
- `description`, string: What it does and when to use it.
- `inputSchema`, object: The arguments as JSON Schema: `properties` with type, description, range, allowed values and default, and `required`.
- `annotations`, object: MCP hints: `readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint` and `title`.
- `outputSchema`, object: The result's JSON Schema, for the tools that declare one.
- `_meta`, object: MCP extras, for the tools that draw a card.
- `requires_api_key`, boolean: True for the tools that need a key.

#### Video

- `id`, string: The YouTube id.
- `kind`, string: video, or short for an upright 9:16 Short.
- `title`, string: As on YouTube, in English, without hashtags.
- `lead`, string or null: The description's first line of prose.
- `published_at`, string (ISO 8601): UTC.
- `new`, boolean: Published in the last 30 days.
- `in_catalog`, boolean: Also among the videos the guides and the apps play.
- `poster_url`, string or null: The thumbnail, served by loafy.ai, never by YouTube.
- `page_url`, string: Its page on loafy.ai.
- `youtube_url`, string: Where it plays on YouTube.

#### Release

- `version`, string: Such as 1.0.35.
- `date`, string (date) or null: The day it reached the App Store, YYYY-MM-DD. Null until then.
- `title`, string: Such as New in 1.0.35, in the reader's language.
- `lines`, array of strings: What it brought.
- `after`, integer or null: Only with platform=android: an Android build whose versionCode is greater carries this release. Null without Play notes.

### GET /api/v1/tools

Every tool with its JSON Schema. The same tools Loafy's MCP server at /mcp offers, without the ones that read and write a baker's own kitchen.

No key needed.

Response:

```
200 {"success": true, "tools": [Tool]}
```

Errors:

- 429 rate_limited: more than 120 calls an hour from one IP address

### POST /api/v1/tools/:name

Runs one tool. The arguments go in the body as a JSON object (or as form fields), named as in the tool's `inputSchema`. The calculators, the planner, the bulk estimate, the journeys, the book's contents and the videos answer anyone. Searching and reading the book and finding an answer (search_sourdough_book, read_sourdough_book, find_sourdough_answer) need the API key of a Loafy account, which every account has.

The key is optional here; the entry says what it changes.

Parameters:

- `name` (path, string, required): The tool's name, such as calculate_pizza_dough.

Example body:

```json
{"pizzas": 4, "weight_per_pizza_g": 250}
```

Response:

```
200 {"success": true, "result": {"tool": "calculate_pizza_dough", "input": {…}, …}}
```

Errors:

- 401 api_key_required: a question tool without a valid key; the message says where to get one
- 404 unknown_tool: no tool has that name; `error.available` lists the names
- 429 rate_limited: more than 120 calls an hour from one IP address

The tools are listed below this group with their parameters, and GET /api/v1/tools returns each one's JSON Schema. A value out of range is clamped, a fraction is rounded where a whole number belongs, and a word where a number belongs gets the default: never an error. `result.input` holds the values used and `result.notes` says what was changed. Most results carry a `url` to the same thing on loafy.ai. A lookup that finds nothing still answers 200; some say why in `result.error`. The hourly limit counts GET and POST together.

### GET /api/v1/videos

The newest videos of The Bread Code on YouTube from the last 30 days: the long videos first, then the Shorts, each group's newest on top, 12 at most. A video the channel took down is left out.

The key is optional here; the entry says what it changes.

Response:

```
200 {"success": true, "data": {"videos": [Video]}}
```

No key needed. A valid key is counted as used; any other is ignored.

### GET /api/v1/videos/:id

One video by its YouTube id, however old, as long as Loafy has seen it in the channel's feed.

The key is optional here; the entry says what it changes.

Parameters:

- `id` (path, string, required): The YouTube id, case-sensitive: 6 to 20 letters, digits, _ or -. Any other shape matches no route.

Response:

```
200 {"success": true, "data": {"video": Video}}
```

Errors:

- 404 not_found: no such video

### GET /api/v1/whats_new

Every Loafy app release, the newest first, with what it brought, in the reader's language.

The key is optional here; the entry says what it changes.

Parameters:

- `locale` (query, string): A language such as de or fr-CA. It wins over the account's language and Accept-Language.
- `platform` (query, string): android for the Android app's own notes and each release's `after`.

Response:

```
200 {"success": true, "data": {"title": "What’s new", "current": "1.0.35", "releases": [Release]}}
```

A key is welcome, never needed: a valid one makes the account's language the default, any other is ignored. The titles come in every app language; the lines exist in the App Store's eleven locales and read in English elsewhere, as do releases before 1.0.13. `current` is the newest version.

### The tools

Call each with `POST /api/v1/tools/<name>` and its parameters as the JSON body.

#### calculate_bread_dough

Bread dough calculator. No key needed. Calculate a sourdough bread recipe in grams from loaf count, loaf size and hydration, with add-ins such as walnuts, raisins or seeds when the baker wants them. Returns flour, water, starter, salt and the add-ins, plus a link to the same recipe on loafy.ai where the baker can adjust it, bake it with "Bake this" and run the timers. Pizza dough is calculate_pizza_dough, and when to start a bake is plan_sourdough_bake. A value outside its range is corrected, and notes name it.

- `loaves` (integer, optional, default 1, 1 to 100): How many loaves to bake.
- `loaf_size_g` (integer, optional, default 500, 50 to 2000): Flour per loaf in grams, not the dough weight: 500 g of flour makes one standard loaf of about 860 g of dough. For a loaf of a given dough weight, the flour is about 58 % of it at 60 % hydration.
- `hydration_percent` (integer, optional, default 60, 55 to 100): Water as a percentage of flour. The book recommends around 60 % for most flours; higher is more open but stickier.
- `whole_grain_percent` (integer, optional, default 20, 0 to 100): Share of the flour that is whole grain, the rest is bread flour.
- `add_ins` (string, optional): Add-ins for the dough, comma-separated, each as its name and its share of the flour in percent, such as "walnuts 15, raisins 10"; grams with "g" ("walnuts 80 g") are for the whole batch, and a name without a number takes 10 %. Names from the list: walnuts, hazelnuts, sunflower_seeds, pumpkin_seeds, sesame, flaxseeds, hemp_seeds, poppy_seeds, raisins, cranberries, olives, cheese, sun_dried_tomatoes, chocolate; anything else in the baker's words.
- `flours` (string, optional): The flours, comma-separated, each as the baker named it with its share of all the flour in percent, such as "Caputo Pizzeria 70, whole rye 30": the brand and name on the bag, a token from find_flours, or the grain with the word on its bag. The first takes what the others leave. With flours, the whole grain follows from them and whole_grain_percent is not needed.

#### calculate_pizza_dough

Pizza dough calculator. No key needed. Calculate pizza dough in grams from the number of pizzas, the ball weight and hydration, with either fresh yeast or sourdough starter. Returns flour, water, salt, leavening and toppings, plus a link to the same recipe on loafy.ai. method_url is the step-by-step method to hand the baker. A loaf of bread is calculate_bread_dough. A value outside its range is corrected, and notes name it.

- `pizzas` (integer, optional, default 4, 1 to 12): How many pizzas.
- `weight_per_pizza_g` (integer, optional, 50 to 350): Dough ball weight in grams. Left out, it follows the oven: 250 g home, 270 g pizza oven, 280 g wood-fired.
- `hydration_percent` (integer, optional, default 60, 55 to 75): Water as a percentage of flour. 55-65 is easy to handle, above 70 is expert.
- `dough_type` (string, optional, default yeast, one of yeast, sourdough): Leavened with fresh yeast or with sourdough starter.
- `oven` (string, optional, default home, one of home, pizza, wood): home is a domestic oven, pizza an Ooni or Roccbox, wood a wood-fired oven.

#### plan_sourdough_bake

Bake Planner. No key needed. Loafy's Bake Planner. Plan a sourdough bake backwards from when the bread should come out of the oven: when to feed the starter, mix, shape, proof in the fridge, preheat and bake, and how much starter suits the kitchen's temperature according to The Sourdough Framework. Returns the times and a link to the same plan in the Bake Planner on loafy.ai. The time is the baker's local date and time, such as 2026-10-24T10:00. The amounts of flour, water and starter are calculate_bread_dough; how long bulk fermentation takes at a given dough temperature and starter amount is estimate_bulk_fermentation.

- `ready_at` (string, required): When the bread should come out of the oven, as the baker's local date and time, e.g. "2026-10-24T10:00".
- `kitchen_temperature_c` (integer, optional, default 22, 15 to 32): Kitchen temperature in °C, which sets how much starter to use.
- `bulk_hours` (integer, optional, 4 to 16): Hours of bulk fermentation, if the baker knows their dough. Without it, the book's figure for the kitchen's temperature.
- `cold_proof_hours` (integer, optional, default 12, 8 to 24): Hours the shaped loaf proofs in the fridge. The book says 8 to 12.

#### estimate_bulk_fermentation

Bake Planner: bulk fermentation estimate. No key needed. Loafy's Bake Planner. Estimate how long the bulk fermentation of a sourdough bread dough (from mixing until shaping) takes at a given dough temperature and starter amount. Returns a range from several models with each model's figure and source: Bill Wraith's rise-time model (2007/08), the Loafy bakers (his model scaled by how long the bulk fermentations Loafy's bakers logged took) and, where the book names one, the figure from The Sourdough Framework. Every time is theoretical: the dough is done when it has grown, as the result's note says. For a whole bake planned backwards from when the bread should be ready, use plan_sourdough_bake.

- `dough_temperature_c` (number, required, 10 to 30): The dough's temperature in °C, measured in the dough. Convert °F: 72 °F is 22 °C.
- `starter_percent` (number, required, 1 to 50): Starter as a percentage of the flour weight: 100 g of starter on 500 g of flour is 20.
- `starter_hydration_percent` (integer, optional, default 100, 50 to 200): The starter's hydration in %: 100 for equal flour and water, 50 for a stiff one.
- `salt` (string, optional, default yes, one of yes, no): "yes" for a bread dough with about 2 % salt, "no" for a levain or the starter itself.

#### list_sourdough_journeys

List guided journeys. No key needed. List Loafy's guided sourdough journeys: making a starter, baking a loaf, scoring, and more. Each one is a timed, step-by-step walkthrough on loafy.ai. Returns each journey's slug, title, duration, difficulty, number of steps and link.

#### start_sourdough_journey

Start a guided journey. No key needed. Start one of Loafy's guided journeys and get the link that opens it at the first step. The journey runs on loafy.ai, where each fold, proof and bake is timed for the baker.

- `slug` (string, required): Journey identifier from list_sourdough_journeys, e.g. "sourdough-bread", or the journey's title.

#### get_sourdough_journey_step

Look up a journey step. No key needed. Look up one step of a guided journey by its id, its title or its position: its title, where it sits in the journey, its timer in minutes when the step has one, and the link that opens it. The instructions themselves are on the page, where the timer for that step runs.

- `slug` (string, required): Journey identifier, e.g. "sourdough-bread", or the journey's title.
- `step` (string, optional): Step identifier (e.g. "mix"), its title, or position ("5" is the fifth step). Left out, the first step is returned.

#### find_sourdough_answer

Find a sourdough answer. Needs the key. Search Loafy's library of answers to real questions from bakers, written by Hendrik Kleinwächter of The Bread Code and grounded in his book The Sourdough Framework. Returns the answers that match, each with the book chapter behind it and a link. When none matches, returns the closest passages from the book instead. The library covers starters, fermentation, dough, flour, baking and storage, and it is in English. The book itself is search_sourdough_book for passages and read_sourdough_book for a whole chapter.

- `query` (string, required): What the baker wants to know, in English, e.g. "my starter smells like vinegar".
- `limit` (integer, optional, default 3, 1 to 10): How many answers to return. Defaults to 3.

#### search_sourdough_book

Search The Sourdough Framework. Needs the key. Search Hendrik Kleinwächter's open-source book The Sourdough Framework and get the passages that answer a question, each with its chapter, a link and the part of the book it comes from, which read_sourdough_book returns in full. The book covers starters, fermentation, flour, hydration, shaping, baking and troubleshooting. It is written in English, and the search matches English words. Hendrik's published answers to common questions are find_sourdough_answer, and a whole chapter is read_sourdough_book.

- `query` (string, required): What to look up, in English, e.g. "starter smells like acetone" or "bulk fermentation temperature".
- `limit` (integer, optional, default 3, 1 to 5): How many passages to return. Defaults to 3.

#### get_sourdough_book_contents

Contents of The Sourdough Framework. No key needed. The table of contents of Hendrik Kleinwächter's open-source book The Sourdough Framework: every chapter and section with its number and each chapter's length in words. read_sourdough_book returns any of them in full. The book covers starters, fermentation, flour, hydration, shaping, baking and troubleshooting.

#### read_sourdough_book

Read The Sourdough Framework. Needs the key. Read a chapter or section of Hendrik Kleinwächter's open-source book The Sourdough Framework in full, by its number from get_sourdough_book_contents or by its title. Returns the text with its chapter, link and licence; a chapter longer than about 40,000 characters comes in pages.

- `part` (string, required): A chapter or section: its number from get_sourdough_book_contents, e.g. "8" or "8.3", or its title, e.g. "Bulk fermentation".
- `page` (integer, optional, default 1, 1 to 10): Which page of a long chapter. Most parts have one.

#### find_videos

Find Hendrik's videos. No key needed. Find Hendrik Kleinwächter's videos of The Bread Code by their words or a topic, such as stretch and fold, scoring or a stiff starter: the best match first, each with its title, the day it came out, its length, a line on what it shows, the chapters that hold the words and its page on loafy.ai, which plays it. Without words, the newest videos. The titles and chapters are in English. A written answer is find_sourdough_answer, the book itself search_sourdough_book.

- `query` (string, optional): What the video should show, in English, e.g. "shaping a batard". Left out, the newest videos.
- `kind` (string, optional, one of video, short): Only long videos (video) or only YouTube Shorts (short). Left out, both, the long ones first.
- `limit` (integer, optional, default 5, 1 to 10): How many videos to return. Defaults to 5.

## Profile and account

The account the key belongs to: its name, settings and photo, a message to Loafy, the baker's rating of Loafy itself, and their answer to Loafy's mails and news by push. DELETE /api/v1/me erases the whole account.

#### Profile

- `id`, string (UUID): The account's id.
- `email`, string: The account's e-mail address.
- `name`, string: The display name.
- `locale`, string or null: The account's language, for example `de`. Every text in every answer is in this language.
- `temperature_unit`, string: `celsius` or `fahrenheit`: the unit every temperature is shown and typed in.
- `avatar_url`, string or null: The profile photo, a 300 x 300 px square. Null without one.
- `joined_at`, string (ISO 8601): When the account was made.
- `marketing_consent_v2`, boolean: Whether mail and push are asked about one by one, with topics. True for every account today.
- `marketing_opt_in`, boolean: See MarketingConsent.
- `marketing_push_opt_in`, boolean: See MarketingConsent.
- `marketing_consent_needs_ask`, boolean: See MarketingConsent.
- `marketing_consent_on_home`, boolean: See MarketingConsent.
- `marketing_consent_at_signup`, boolean: See MarketingConsent.
- `marketing_push_needs_ask`, boolean: See MarketingConsent.
- `marketing_topics`, object: See MarketingConsent.
- `name_needs_ask`, boolean: True when the name was made up at sign-up (Apple sent none). Sending a name with PATCH turns it false.
- `notify_ask_answers`, boolean: Whether a finished Ask Loafy answer is pushed to the phone.
- `morning`, string: When the baker's morning starts, HH:MM on a 24-hour clock. 08:00 until it is moved. Every morning time a reminder offers moves with it.
- `morning_set`, boolean: False until the baker moved their morning once.
- `timezone`, string or null: The account's time zone, an IANA name such as `Europe/Berlin`. Null while no device told it and the baker never picked one.
- `timezone_chosen`, boolean: True once the baker picked the zone. Then a device's `X-Time-Zone` header no longer changes it.
- `referral_url`, string: The baker's own invite link.
- `loafy_sense_enabled`, boolean: Whether the account may use the Loafy Sense sensor screens.
- `feature_flags`, array of strings: The feature flags switched on for this account, for example `pressure_dashboard`.

#### MarketingConsent

- `marketing_opt_in`, boolean: Yes to Loafy's mails.
- `marketing_push_opt_in`, boolean: Yes to Loafy's news by push.
- `marketing_consent_needs_ask`, boolean: The mail question may be put now: never answered, shown on fewer than two days and not today. Or, once ever, 30 days after a no, unless the baker unsubscribed.
- `marketing_consent_on_home`, boolean: The mail question may be put on Home now.
- `marketing_consent_at_signup`, boolean: Show the consent screen of a new account: made in the last 24 hours, never asked about mail or push.
- `marketing_push_needs_ask`, boolean: The push question may be put now, by the same rule as the mail question.
- `marketing_topics`, object: `videos`, `challenges`, `news` and `offers`, each true unless the baker switched that topic off. A topic counts for mail and push alike.

#### LoafyRatingState

- `due`, boolean: Ask for a rating now: three counted bakes or more, no rating, and the question never shown on any device.
- `can_rate`, boolean: Three counted bakes or more, or a rating already given.
- `bakes`, integer: The baker's counted bakes.
- `rating`, LoafyRating or null: The baker's rating, null without one.
- `suggested`, object: `quote_name` (the account's first name) and `place` (the rating's place, else the country of the last visit, in English). Either may be null.
- `limits`, object: `body_max` (400) and `place_max` (60), in characters.

#### LoafyRating

- `stars`, integer: 1 to 5.
- `body`, string or null: One sentence for other bakers, on one line.
- `show_quote`, boolean: Whether loafy.ai may show the words with the first name and the place.
- `quote_name`, string or null: The first name the words would show with.
- `place`, string or null: The place shown after the name. Kept only while show_quote is true.
- `quote_status`, string or null: `waiting` (not read yet), `shown` (on loafy.ai), `not_shown`, or null while there are no words or the switch is off.
- `created_at`, string (ISO 8601)
- `updated_at`, string (ISO 8601)

### GET /api/v1/me

The account the key belongs to, with the settings the apps show. A cheap way to check that a key works.

Response:

```
200 {"success": true, "data": Profile}
```

Every request with an `X-Time-Zone` header (an IANA name) fills in the account's zone while it has none and the baker never picked one.

### PATCH /api/v1/me

Changes the name and the settings. Send only the keys that change: a key left out is left alone. One value that is not accepted refuses the whole request and changes nothing. Safe to repeat.

Parameters:

- `name` (body, string): The display name. An empty one is ignored.
- `notify_ask_answers` (body, boolean): Push a finished Ask Loafy answer to the phone.
- `morning` (body, string): HH:MM on a 24-hour clock, two digits each: `06:30`, not `6:30`.
- `temperature_unit` (body, string): `celsius` or `fahrenheit`.
- `timezone` (body, string or null): An IANA zone such as `America/New_York`, kept as the baker's pick. Null or an empty string goes back to automatic and keeps the current zone.

Example body:

```json
{"morning": "10:30", "temperature_unit": "fahrenheit"}
```

Response:

```
200 {"success": true, "data": Profile}
```

Errors:

- 422 invalid_morning: not HH:MM
- 422 invalid_temperature_unit: neither celsius nor fahrenheit
- 422 invalid_time_zone: not an IANA time zone
- 422 invalid: the account failed validation, the message says why

### DELETE /api/v1/me

DELETES THE WHOLE ACCOUNT, at once and for good. There is no undo and no confirmation step. Every bake, photo, starter, container, timer, Ask Loafy conversation, rating and message goes with it, and so do all its API keys, the one that made this call too. Call it only when the baker asked for their account to be deleted.

Response:

```
204, no body
```

Errors:

- 500 erasure_failed: the account was not deleted and the key still works. Try again.

204 means the account is gone. Two calls that cross both answer 204; a call after that answers 401, because the key went with the account.

### PATCH /api/v1/me/avatar

Sets the profile photo, as multipart form data. It replaces the photo there was.

Parameters:

- `avatar` (multipart, file, required): PNG, JPEG or GIF, 5 MB at most.

Example body:

```
curl -X PATCH -F "avatar=@me.jpg" …
```

Response:

```
200 {"success": true, "data": Profile}
```

Errors:

- 422 avatar_missing: no file
- 422 invalid: not a PNG, JPEG or GIF, or larger than 5 MB

### POST /api/v1/me/feedback

Sends a message to the people behind Loafy, with up to five screenshots. An answer goes by mail to the account's address. Every call is a new message.

Parameters:

- `message` (multipart, string, required): At most 4,000 characters.
- `source` (multipart, string, required): Where it was written: `settings`, `home_card`, `first_bake`, `share_sheet`, `help_page`, `contact_page`, `dashboard_card`, `ask_answer` or `club`.
- `screenshots[]` (multipart, file): Up to five. PNG, JPEG, HEIC, HEIF or WebP, 10 MB each at most.
- `app_version` (multipart, string): Up to 60 characters are kept.
- `device` (multipart, string): Up to 60 characters are kept.
- `os_version` (multipart, string): Up to 60 characters are kept.

Example body:

```
curl -F "message=The timer did not ring" -F "source=settings" -F "screenshots[]=@shot.png" …
```

Response:

```
201 {"success": true, "data": {"id": "<UUID>"}}
```

Errors:

- 422 invalid: no message, an unknown source, or a screenshot too many, too large or of the wrong type. Nothing is kept.

Without screenshots the same fields also work as a JSON body.

### GET /api/v1/me/loafy_rating

The baker's rating of Loafy itself (not of a bread), and whether to ask for one now.

Response:

```
200 {"success": true, "data": LoafyRatingState}
```

### PUT /api/v1/me/loafy_rating

Rates Loafy, or changes the rating. Each call replaces the words, the switch and the place, so send all of them every time. New or changed words with the switch on wait to be read before loafy.ai shows them; the switch turned off takes them down at once.

Parameters:

- `stars` (body, integer, required): 1 to 5, whole stars only.
- `body` (body, string): One sentence for other bakers, at most 400 characters.
- `show_quote` (body, boolean): Let loafy.ai show the words with the baker's first name and the place. Off when left out.
- `consent_text` (body, string): Required when show_quote is true: the words of the switch exactly as the baker saw them, kept as the proof of consent.
- `place` (body, string): At most 60 characters, shown after the name. Kept only with show_quote.
- `source` (body, string): `third_bake`, `settings` or `web`; anything else counts as settings. Kept from the first rating only.
- `app_version` (body, string): Kept from the first rating only.

Example body:

```json
{"stars": 5, "body": "My starter finally doubled on day six.", "show_quote": false}
```

Response:

```
200 {"success": true, "data": LoafyRatingState}
```

Errors:

- 403 too_early: fewer than three counted bakes and no rating yet
- 422 invalid: a field failed validation, the message says which

### DELETE /api/v1/me/loafy_rating

Takes the rating back, words and all. Safe to repeat.

Response:

```
200 {"success": true, "data": LoafyRatingState}
```

### POST /api/v1/me/loafy_rating/asked

Says the question was on screen, so `due` turns false on every device and the question is not put again. Safe to repeat. Needs no body.

Response:

```
200 {"success": true, "data": LoafyRatingState}
```

### POST /api/v1/me/marketing_consent

The baker's answer about Loafy's mails and news by push, and the topics they want. A channel left out or null stays as it is. Every answer is kept with its time and the screen it was given on. Send only what the baker chose themselves.

Parameters:

- `email` (body, boolean or null): Yes or no to mails.
- `push` (body, boolean or null): Yes or no to news by push.
- `place` (body, string): Where it was asked: `signup`, `home` (the default), `ask` or `settings`. `email: false` from `settings` is an unsubscribe: the mail question is never put again.
- `topics` (body, object): Any of `videos`, `challenges`, `news`, `offers`, each true or false. Alone, it only switches topics.
- `opted_in` (body, boolean): The older body: an answer about mails, given on Home. Read only when none of email, push or topics is sent.

Example body:

```json
{"email": true, "push": false, "place": "settings"}
```

Response:

```
200 {"success": true, "data": MarketingConsent}
```

Errors:

- 422 invalid_place: an unknown place
- 422 invalid_consent: email or push is not true, false or null
- 422 invalid_topics: an unknown topic, or a value that is not true or false
- 422 consent_missing: email and push both null and no topics
- 422 opted_in_missing: none of email, push, topics or opted_in

The answer is filed as given in the Loafy app: on Android when the `X-Loafy-Client` header names the Android app, on the iPhone otherwise. A yes to mails is filed with the words the app's own screen showed, worked out from the app's build; from any other client it covers Loafy's updates only, not offers.

### POST /api/v1/me/marketing_consent/prompted

Says the question was on screen today without an answer. Each question is put on two days at most and never twice on one day; a day counts once, however often this is called.

Parameters:

- `channel` (body, string): `email` (the default) or `push`.
- `place` (body, string): `signup`, `home`, `ask` or `settings`. `signup` is "Not now" on a new account's consent screen and counts the day for both questions.

Example body:

```json
{"channel": "push"}
```

Response:

```
200 {"success": true, "data": MarketingConsent}
```

Errors:

- 422 invalid_place, 422 invalid_channel

## Ask Loafy

Ask Loafy answers baking questions from The Sourdough Framework, in the language they are asked in. Make a conversation with POST /api/v1/me/ask/conversations, post a question to it with POST /api/v1/me/ask/conversations/:id/messages (add `?stream=false` for one JSON reply instead of a stream), and read the answer from that reply, or later from GET /api/v1/me/ask/conversations/:id. Each question counts against the baker's daily quota, which every response states in the `X-Ask-Quota` header.

#### Quota

- `tier`, string: `user`, or `admin` for an admin account.
- `left`, integer: Questions left today. Missing for an admin.
- `total`, integer: Questions a day for this account: 5 by default, more through invitations, at most 50. Missing for an admin.
- `resets_at`, string (ISO 8601): The next midnight in Berlin, when the count starts again.
- `invited`, integer: Bakers this baker invited who confirmed their address and asked a question. Each adds to `total`.
- `invited_by`, boolean: True when this baker came through an invitation, which adds to `total` too.

#### Conversation

- `id`, string (UUID): The conversation's id.
- `created_at`, string (ISO 8601)
- `context`, object or null: What the thread is about, with a `title` to show. From a guide step: `journey`, `step`, `title`, `chapter`, `locale` and, for the sourdough-bread guide, `amounts`. For a bake: `bake_log_id` and `bake`, a snapshot of the bake's numbers (never its notes or photos). For a bake told to Loafy: `new_bake: true`. Null for a plain thread.
- `answering`, boolean: True while the newest answer is still being written. Only in GET.
- `messages`, array of Message: Every question and answer, oldest first. Only in GET.

#### ConversationRow

- `id`, string (UUID): The conversation's id.
- `title`, string or null: The first question, cut to 90 characters.
- `preview`, string or null: One line of the first answer, up to 160 characters. Null until there is one.
- `chapter`, string or null: The first book chapter the first answer cites.
- `sources_count`, integer: How many sources the first answer cites.
- `messages_count`, integer
- `last_at`, string (ISO 8601): When the last question was asked.
- `answering`, boolean: True while the newest answer is still being written.
- `context`, object or null: As in Conversation.

#### Message

- `id`, string (UUID): The message's id. An answer's id is what feedback, cancel and the card endpoints take.
- `role`, string: `user` for a question, `assistant` for an answer.
- `status`, string: A question: `pending`, `answered`, `clarified` (Loafy asked back, not counted), `cancelled`, `failed`, or `rejected_input`, `rejected_budget`, `rejected_quota` when it was refused before an answer. An answer: `streaming`, `answered`, `cancelled` (stopped, keeps the text sent so far) or `failed`.
- `content`, string: The text. An answer's text has no source line and no follow-ups; those are fields of their own.
- `created_at`, string (ISO 8601)
- `photos`, array of AskPhoto: Questions only, when photos went with it.
- `details`, object: On a question with photos: `kind` and `problems` as sent. On Loafy's check-in the morning after a kept bake: `checkin` with `bake_log_id`, `title`, `url`, the bake's `rating` (null until rated) and `words` for the three faces, or `gone: true` once the bake is deleted. Missing otherwise.
- `shape`, string or null: Answers: `diagnosis`, `howto`, `short` or `clarify` (Loafy asks one question back instead of answering).
- `parts`, object or null: The answer in pieces. `diagnosis`, `todo` (list) and `why` for a diagnosis; `lead` and `steps` (list) for a how-to; `ask` and `options` (short replies to offer as buttons, the tapped one is the next question) for clarify. With a photo also `seen`, `confidence` (`high`, `medium`, `low`), `crumb` and `crumb_alt`, crumbs from `photos.crumbs` in GET state.
- `sources`, array: What the answer draws on, each with `title` and `url`. Book chapters have no `kind`; `kind` is `pizza` or `recipe` for material from outside the book.
- `followups`, array of strings: Questions to offer next.
- `exhibits`, array: Tables, figures and flowcharts of the book the answer shows: `id`, `kind` (`table`, `figure`, `flowchart`), `number`, `label`, `caption`, `chapter`, `section`, `url`, a `table` or an `image`, and `mentions`, the words in the text that name it.
- `video`, object or null: A part of a video that shows what the answer is about: `key`, `video_id` (YouTube), `start` and `end` in seconds, `title`, `video_title`, `year`, `poster`, `mentions`.
- `recipe`, RecipeCard or null: A recipe card for one of Loafy's breads.
- `pizza`, PizzaCard or null: The Neapolitan pizza card.
- `site_recipe`, SiteRecipeCard or null: A card for a recipe from the-bread-code.io (the Stollen so far).
- `bulk`, BulkCard or null: An estimate of bulk fermentation.
- `action`, ActionCard or null: Something Loafy offers to do in the baker's kitchen. Only when the question sent `action` in `cards`.
- `bakes`, array of BakeCard or null: Up to 3 of the baker's own bakes the answer talks about. Only when the question sent `bakes` in `cards`.
- `offer`, Offer: Only on an answer where Loafy offered to keep the bake in the journal.
- `not_in_book`, boolean: True when the book does not cover the question.
- `lang`, string: A rough guess at the question's language, `de` or `en`.
- `locale`, string: The language the answer is written in. Its cards and sources are in it too.
- `feedback`, string or null: `up`, `down` or null.
- `copied_at`, string (ISO 8601) or null: When the baker first copied the answer.
- `model`, string: The model that wrote the answer.
- `latency_ms`, integer or null
- `cost_cents`, number or null: What the answer cost, in US cents.

#### AskPhoto

- `id`, string: A signed id. It does not expire; name it in `photo_ids`.
- `url`, string: A path on loafy.ai to the photo, good for 2 hours. Every read of the thread gives fresh ones.
- `width`, integer: In pixels. The long side is at most 1600.
- `height`, integer

#### RecipeCard

- `key`, string: The bread: `free-standing`, `sandwich-bread` or `flatbread`.
- `title`, string
- `pieces`, integer: How many loaves.
- `piece_grams`, number: Flour per loaf, in grams.
- `piece_weight`, number: Dough per loaf, in grams.
- `speed`, string: `slow`, `medium` or `fast`, named in `speed_name`.
- `kitchen`, string: `warm` or `cool`. `kitchen_note` says why it matters, or is null.
- `ingredients`, array: Each with `key`, `name`, `grams` and `percent` of the flour.
- `list`, array: The whole day in order: `key` (`feed`, `mix`, `bulk`, `check`, `shape`, `proof_room`, `proof_fridge`, `heat`, `bake`, `ready`), `at`, `until`, `minutes`, `length`, `title`, `detail` and more.
- `feed`, object: Sourdough only: feeding the starter, which starts the day, with `at`, `until`, `title` and `text`.
- `mix_at`, string: The baker's wall clock, without offset, such as 2026-10-14T11:45.
- `ready_at`, string: Same clock.
- `late`, boolean: The mix time of a plan started earlier has passed.
- `too_soon`, string: Only when the baker's ready time could not be reached: the time they asked for. The card plans the earliest day instead.
- `started`, object: After POST recipe/start: `bake_url`, `steps_url`, `reminders`, `shift_minutes`, `later_minutes`, `by_app`, and after a split, `split` (one entry per loaf with `bake_url`, `name`, `grams`).
- `dough`, object: Only for one dough for several loaves: `flour`, `grams`, `open`, `loaves` and `breads`.
- `url`, string: The bread calculator with these numbers, a path on loafy.ai.
- `locale`, string: The card's language. `labels`, `words`, `guide`, `flowchart` and the other fields are for drawing it.

#### PizzaCard

- `leaven`, string: `yeast` or `sourdough`.
- `speed`, string: `slow` (overnight) or `fast`. Sourdough is always `slow`. `ways` lists the three ways.
- `pizzas`, integer: How many pizzas, with `ball_grams` of dough each.
- `ingredients`, array: Each with `key`, `name`, `grams`, `percent`, and maybe `note`, `up_to` or `or` (a second choice, such as dry yeast).
- `list`, array: The steps on the baker's clock, each with `key`, `at`, maybe `until`, `title` and `text`.
- `mix_at`, string: Wall clock without offset.
- `ready_at`, string: When the pizzas go into the oven.
- `too_soon`, string: Only when the time asked for could not be reached.
- `url`, string: The full recipe page.
- `locale`, string: The card's language. `key`, `title`, `icon`, `way` and `labels` are for drawing it.

#### SiteRecipeCard

- `key`, string: The recipe, `stollen`.
- `count`, integer: How many, between `min` and `max`, counted in `unit`.
- `groups`, array: The recipe's tables in order, each with `key`, `title` and `ingredients` (`key`, `name`, `grams`, maybe `percent` and `note`).
- `list`, array: The steps on the baker's clock, each with `key`, `at`, maybe `until`, `title` and `text`.
- `bake_on`, string (date): The baking day.
- `ready_on`, string (date): The day it may be cut.
- `too_soon`, string (date): Only when the day asked for could not be reached.
- `url`, string: The recipe on the-bread-code.io.
- `challenge`, object: Only while a challenge for this recipe runs: `path`, `title`, `days_left`, `prize`, `photo`.
- `locale`, string: The card's language. `title`, `icon` and `labels` are for drawing it.

#### BulkCard

- `dough_temperature_c`, number: 22 when the question named none (`temperature_assumed`).
- `starter_percent`, number: Starter as % of the flour, 20 when the question named none (`starter_assumed`).
- `from_hours`, number: The earliest any model expects the dough to be ready.
- `to_hours`, number: The latest. `range` says both in English.
- `models`, array: Each estimate: `model` (`wraith`, `bakers`, `book` or `journal`, the baker's own bakes), `name`, `from_hours`, `to_hours`, `time`, and maybe `source` and `bakes`.
- `note`, string: Always there: these are theoretical estimates, and the dough decides. Show it with the times.
- `url`, string: The timing page with this dough, a path on loafy.ai.
- `locale`, string: The card's language. `words` holds its labels.

#### ActionCard

- `tool`, string: `log_bake`, `update_bake`, `add_starter`, `update_starter`, `start_timer`, `remind_me`, `cancel_reminder`, `switch_reminder` or `split_bake`.
- `status`, string: `proposed` (waiting for a tap) or `done`. A card undone or dismissed comes as only `tool` and `status` (`undone`, `dismissed`): show nothing.
- `args`, object: What the tool runs with.
- `kind`, string: `journal`, `starter`, `timer` or `reminder`, with its `icon` and `label`.
- `title`, string: The card's heading. `subtitle` names the bake a change or split is for.
- `rows`, array: Each value Loafy understood, as `label` and `value`, some with `items`.
- `confirm`, string: The button's word. `undo` is the word for Undo.
- `secondary`, object: The second button: `label` and `url` of a web form to change the values first, or `label` and `dismiss: true` to put the card away.
- `photos`, array of AskPhoto: Open bake cards only: the photos that go into the bake. `photos_label` is the line above them.
- `failed`, string: Open cards only: the line to show when a tap did not work.
- `empty`, boolean: An open `log_bake` card where Loafy caught nothing: show `notice` and only the form button, never `confirm`.
- `done`, string: After the tap: the line saying what was done, with `url` (the bake or starter), `bake_id` and, after `log_bake`, `details` (the form to add more).
- `undoable`, boolean: True while Undo still works: until a newer question in the thread.

#### Offer

- `keep`, boolean: Whether Loafy offers to keep this bake in the journal. When false, nothing else comes.
- `when`, string: `today`, `tomorrow` or `done` (already baked).
- `bake_type`, string
- `title`, string: The name the thread gives the bake.
- `answer`, string: `accepted` or `declined`. Missing until the baker answers.
- `expired`, boolean: True when it can no longer be accepted: its day is over, or an action card in the thread took the bake. Show nothing then.
- `bake`, KeptBake: After yes.
- `words`, object: Loafy's question and the button words in the thread's language: `question`, `yes`, `no`, `kept`, `checkin`, `tip_kept`, `faces`.

#### KeptBake

- `id`, string (UUID): The bake's id, for the bakes endpoints below and the journal. Fields without a value are left out.
- `title`, string
- `rating`, integer: 1 to 5. Missing until rated.
- `face`, string: The rating as an emoji.
- `summary`, string: Starter, water and salt in one line.
- `note`, string: The bake's note for next time.
- `checkin_at`, string (ISO 8601): When Loafy asks how it turned out: 09:00 the day after, on the baker's clock.
- `checkin_label`, string: The same in words, while it is still ahead.
- `url`, string: The bake's page, a path on loafy.ai.

#### BakeCard

- `id`, string (UUID): The bake's id in the journal.
- `title`, string
- `bake_type`, string
- `baked_on`, string (date)
- `rating`, integer or null: 1 to 5.
- `in_progress`, boolean: Not rated and still baking.
- `photo_url`, string or null: A 400 px square, an absolute address that does not expire.
- `summary`, string or null: Hydration, bulk, bake and core temperature, as far as known, in one line.
- `url`, string: The bake's page on loafy.ai.

### GET /api/v1/me/ask/state

What a client needs before the first question: the quota, the words to show while Loafy works, the length limits and what the crumb check offers.

Response:

```
200 {"enabled": true, "tier": "user", "quota": Quota, "turnstile": {...}, "quick_questions": [string], "waiting": {...}, "limits": {"max_question_chars": 6000, "max_bake_chars": 6000}, "photos": {...}, "intro": {...}, "updates": {...}, "today": []}
```

Errors:

- 403 email_unconfirmed: the account's address is not confirmed yet

`waiting.states` has the words for each `status` state of the stream, `waiting.tips` lines from the book to show while waiting, and `waiting.chapters` the book's chapters in order. `photos` says whether photos are on (`enabled`), how many go with a question (`max_per_question`), the crumb check's `problems` and `crumbs` with their labels, the `default_question` and `bake_question` to send when the baker types nothing, and the baker's 12 latest `bakes` (`id`, `title`) to pick from. `intro` and `updates` are the words of the empty chat. Unlike most groups, the Ask endpoints answer with their object as it is, without `success` and `data`; a refusal is `{"success": false, "error": {"code": "…", "message": "…"}}` with `message` in the baker's language. Every Ask endpoint answers 403 `email_unconfirmed` while the account's address is not confirmed, and every other answer carries `X-Ask-Quota`, the Quota as JSON.

### GET /api/v1/me/ask/conversations

The baker's conversations, newest first, grouped by day, 30 to a page. Threads without a message are left out.

Parameters:

- `q` (query, string): Only threads with a question or answer containing this text.
- `page` (query, integer): From 1, the default.

Response:

```
200 {"days": [{"date": "2026-10-13", "label": "today", "conversations": [ConversationRow]}], "page": 1, "next_page": null}
```

`label` is `today`, `yesterday` or null. `next_page` is the next page's number, or null on the last one.

### POST /api/v1/me/ask/conversations

Starts a conversation, with or without a context. Post questions to it next. A context is kept with the thread, and every answer in it reads it.

Parameters:

- `context.journey` (body, string): The guide the question comes from, with `context.step`, `context.title`, `context.chapter` and `context.locale`. Each is cut to 120 characters.
- `context.amounts` (body, object): From the `sourdough-bread` guide only: `loaves` (1 to 10), `hydration` (55 to 100) and `starter` (a step of the bread planner). Dropped without a word when a number is out of reach.
- `context.bake_log_id` (body, string (UUID)): A bake from the baker's journal: the thread gets a snapshot of its numbers. A bake that is not the baker's is ignored.
- `context.new_bake` (body, boolean): A thread that tells Loafy about a bake for the journal. Every other context key is then dropped.
- `via` (body, string): A tag for where the question started, up to 64 letters, digits, dots, dashes and underscores. Anything else is dropped.

Example body:

```json
{"context": {"bake_log_id": "6b1c0f7e-3d2a-4f5b-9c8d-1e2f3a4b5c6d"}}
```

Response:

```
201 {"id": "…", "created_at": "…", "context": {...} or null}
```

### GET /api/v1/me/ask/conversations/:id

One conversation with every question and answer. Read it again after a dropped stream: `answering` stays true while Loafy is still writing.

Parameters:

- `id` (path, string (UUID), required)

Response:

```
200 Conversation
```

Errors:

- 404 not_found: no such conversation, or not the baker's

### PATCH /api/v1/me/ask/conversations/:id

Names the bake a conversation is about after it started, for instance under a crumb check. The thread takes a snapshot of the bake's numbers, replaces any bake named before and keeps the rest of its context. Ask the next question (such as `photos.bake_question` from GET state) after this; the photos of the earlier question go along by themselves.

Parameters:

- `id` (path, string (UUID), required)
- `context.bake_log_id` (body, string (UUID), required): One of the baker's bakes.

Example body:

```json
{"context": {"bake_log_id": "6b1c0f7e-3d2a-4f5b-9c8d-1e2f3a4b5c6d"}}
```

Response:

```
200 {"id": "…", "created_at": "…", "context": {...}}
```

Errors:

- 404 not_found: no such conversation
- 422 bake_not_found: no bake given, or not the baker's

### DELETE /api/v1/me/ask/conversations/:id

Deletes a conversation with its messages and the photos of its questions.

Parameters:

- `id` (path, string (UUID), required)

Response:

```
204, no body
```

Errors:

- 404 not_found: no such conversation, also when it is already gone

### POST /api/v1/me/ask/conversations/:id/messages

Asks a question in a conversation. By default the answer streams as Server-Sent Events while Loafy writes it; with `?stream=false` the call waits and answers with one JSON body. A question counts against the quota once it is answered, or stopped after text went out.

Parameters:

- `id` (path, string (UUID), required): The conversation.
- `stream` (query, string): `false` for one JSON reply. Anything else, or nothing, streams.
- `question` (body, string, required): 1 to 6000 characters after trimming, in any language. The answer follows its language.
- `client_id` (body, string): Your id for this question. Sent again within 60 seconds, it repeats the stored answer instead of asking twice; after a failure, it asks the same question again.
- `photo_ids` (body, array of strings): Ids from POST /api/v1/me/ask/photos, at most 3 (more are ignored). Only the baker's own uploads that no other question holds; a retry in the same thread may send them again.
- `details.kind` (body, string): With photos: `crumb_check` (Loafy reads the crumb) or `bake_photo` (the photo is for a bake in the journal).
- `details.problems` (body, array of strings): On a crumb check, what bothers the baker: `too_dense`, `big_holes`, `gummy`, `flat`, `too_sour`, `just_checking`. Others are dropped.
- `cards` (body, string): The cards your client draws, comma separated: `recipe`, `bulk`, `pizza`, `site_recipe`, `action`, `bakes`. With one of the first four the text leaves the card's grams or times to it; without `cards` every amount and time stays in the text. `action` lets Loafy offer to log a bake, add a starter, set a timer or reminder and so on; `bakes` lets it show the baker's own bakes.
- `time_zone` (body, string): The baker's IANA zone, such as Europe/Berlin. Times on the cards are read on this clock; without it, UTC.
- `kitchen` (body, string): `warm` or `cool`: the kitchen picked on an earlier recipe card, used when the question does not say.
- `model` (body, string): Admin accounts only: the model to answer with. Ignored otherwise.

Example body:

```json
{"question": "Why is my loaf flat?", "client_id": "8c0e7c1e-2f7a-4a59-9a43-7b1f3f2f6a10", "time_zone": "Europe/Berlin"}
```

Response:

```
200 text/event-stream (events below), or with ?stream=false 200 {"user_message": Message, "assistant_message": Message, "error": null, "quota": Quota}
```

Errors:

- 404 not_found: no such conversation
- 422 question_blank: no question after trimming
- 422 question_too_long: more than 6000 characters
- 422 photos_invalid: a photo id is not the baker's upload, or another question holds it
- 404 photos_disabled: photos are switched off on the server
- 402 budget_exhausted: the day's spending on answers, shared by every baker, is used up
- 429 quota_exhausted: the baker's questions for today are used up; `message` says in how many hours they come back
- 409 conversation_busy: an answer in this thread is still being written

A refusal comes before any stream, as plain JSON with the status above, and carries `quota` next to `error`. The checks run in this order: blank, too long, budget, photos, quota, busy.

The stream sends these events, each as `event: <name>` and a `data:` line of JSON:

- `message`: the question as saved, a Message.
- `meta`: `{"id", "role": "assistant", "model", "status": "streaming"}`. Keep `id`: it is the answer's id, for cancel.
- `status`: what Loafy is doing, `{"state", "model", "elapsed_ms"}`. `state` is `reading`, `looking` (reading the photos), `thinking` (with `provider`), `found` (with `chapter` and `number`, its place in `waiting.chapters`), `writing` or `retrying`. GET state has the words for each.
- `delta`: `{"text", "part"}`, plain text in order; `part` is `lead`, `diagnosis`, `todo`, `why`, `steps`, `ask`, `options`, `seen`, `confidence` or `crumb`. Paragraphs break at a blank line.
- `answer`: the whole answer as a Message. It replaces the streamed text and adds the sources, follow-ups and cards.
- `quota`: the Quota after this question.
- `error`: `{"code": "model_failed", "message"}` when no answer came. The question is not counted; ask again.
- `done`: `{}`, the last event.

Every 10 seconds a `: ping` comment line keeps the connection open. The `X-Ask-Quota` header of a stream is the quota before the question.

Closing the connection does not stop the answer: it is written to the end and saved, so GET the conversation to read it. To stop it, call POST /api/v1/me/ask/messages/:id/cancel with the id from `meta`; the stream then ends without `answer` and `done`. With `?stream=false` a failed answer is still a 200, with `error` set. A question sent again with the same `client_id` within 60 seconds replays `message`, `meta`, `answer`, `quota` and `done` without asking again. Loafy may ask back (`shape: "clarify"`) at most twice in a thread; that costs no question.

### POST /api/v1/me/ask/messages/:id/cancel

Stops an answer that is still being written. It stops shortly after and keeps the text sent so far as a `cancelled` answer; the question counts only if text went out. Safe to repeat.

Parameters:

- `id` (path, string (UUID), required): The answer's id, from the `meta` event.

Response:

```
202 {"id": "…", "status": "streaming", "cancel_requested_at": "…"}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 409 not_streaming: the answer is already done

### POST /api/v1/me/ask/photos

Uploads one photo for a question, as multipart form data, before the question names it in `photo_ids`. The server turns it upright, makes it at most 1600 px, stores it as JPEG without any metadata (no location, no camera) and deletes it after a day if no question took it. Up to 30 uploads a day, refused ones included.

Parameters:

- `photo` (multipart, file, required): JPEG, PNG, WebP or HEIC, 20 MB and 120 megapixels at most.

Example body:

```
curl -F "photo=@crumb.jpg" …
```

Response:

```
201 AskPhoto
```

Errors:

- 404 photos_disabled: photos are switched off on the server
- 422 photo_missing, photo_type, photo_too_large, photo_unreadable
- 429 photo_limit: 30 uploads in the last 24 hours

### POST /api/v1/me/ask/messages/:id/feedback

A thumb up or down on an answer, with an optional line why. Sending it again replaces the thumb; null takes it away.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `value` (body, string or null): `up`, `down`, or null.
- `note` (body, string): Up to 500 characters; longer is cut.

Example body:

```json
{"value": "down", "note": "Too short"}
```

Response:

```
200 {"feedback": "down"}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 422 invalid_feedback: a value other than up, down or null

### GET /api/v1/me/ask/messages/:id/recipe

The answer's recipe card worked out again for another number of loaves or another kitchen. Nothing is stored.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `pieces` (query, integer): 1 to 100.
- `kitchen` (query, string): `warm` or `cool`.

Response:

```
200 {"recipe": RecipeCard}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 404 with no body: the answer has no recipe card

### POST /api/v1/me/ask/messages/:id/recipe/start

Starts baking the recipe card: the plan goes into the journal as a bake, with a timer for every moment still ahead (for sourdough, feeding the starter too), and Loafy asks how it turned out the morning after its day. Safe to repeat: a card already started comes back as it is.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `pieces` (body, integer): 1 to 100, as the card was switched to.
- `kitchen` (body, string): `warm` or `cool`.

Example body:

```json
{"pieces": 2, "kitchen": "warm"}
```

Response:

```
200 {"recipe": RecipeCard} with `started`
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 404 with no body: the answer has no recipe card

### POST /api/v1/me/ask/messages/:id/recipe/later

"Not yet" at the dough check of a started card: the check and every step after it move one hour later, timers included. Each call moves it again. A card not started stays as it is.

Parameters:

- `id` (path, string (UUID), required): An answer's id.

Response:

```
200 {"recipe": RecipeCard}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 404 with no body: the answer has no recipe card

### POST /api/v1/me/ask/messages/:id/recipe/split

Divides the dough of a started card into one journal entry per loaf. The started bake becomes the first loaf; each other loaf is a new entry with its share of the dough. Once: a card already divided comes back as it is.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `pieces` (body, integer or array, required): A number of equal loaves (2 to 10), or 2 to 10 loaves as `{key, grams}` or `{key, share}`. `key` is `free-standing`, `sandwich-bread` or `flatbread`, left out for the dough's own bread. Loaves without grams share what the others leave.

Example body:

```json
{"pieces": [{"key": "sandwich-bread", "grams": 1770}, {"key": "free-standing", "grams": 885}]}
```

Response:

```
200 {"recipe": RecipeCard} with `started.split`
```

Errors:

- 404 not_found, or 404 with no body when the answer has no recipe card
- 422 split_not_started: start the card first
- 422 split_rated: the bake is already rated
- 422 split_pieces: not 2 to 10 loaves
- 422 split_bread: a `key` that is no bread
- 422 split_amount: grams or shares that do not add up
- 422 split_no_bake: the started bake is gone

### GET /api/v1/me/ask/messages/:id/pizza

The answer's pizza card worked out again for another number of pizzas or another way. Nothing is stored.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `pizzas` (query, integer): 1 to 100.
- `leaven` (query, string): `yeast` or `sourdough`.
- `speed` (query, string): `slow` or `fast`. Sourdough is always slow.

Response:

```
200 {"pizza": PizzaCard}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 404 with no body: the answer has no pizza card

### GET /api/v1/me/ask/messages/:id/site_recipe

The answer's card for a recipe from the-bread-code.io, worked out again for another number. Nothing is stored.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `count` (query, integer): Held between the card's `min` and `max`.

Response:

```
200 {"site_recipe": SiteRecipeCard}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 404 with no body: the answer has no such card

### GET /api/v1/me/ask/messages/:id/bulk

The answer's bulk fermentation card worked out again for another dough, with the baker's own bakes as one of the models. Nothing is stored.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `temp` (query, number): Dough temperature in °C, 10 to 30. Out of range keeps the answer's own.
- `starter` (query, number): Starter as % of the flour, 1 to 50. Out of range keeps the answer's own.

Response:

```
200 {"bulk": BulkCard}
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 404 with no body: the answer has no bulk card

### POST /api/v1/me/ask/messages/:id/action/confirm

Does what the answer's action card offers, once: logs or changes the bake, adds or changes the starter, starts the timer, sets the reminder. Safe to repeat: a card already done comes back as it is.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `photo_ids` (body, array of strings): The card's photos to put into the bake. Left out: all of them; `[]`: none. Ids not on the card are ignored.

Example body:

```json
{"photo_ids": []}
```

Response:

```
200 {"action": ActionCard}
```

Errors:

- 404 not_found: no such answer
- 404 no_action: the answer has no action card
- 403 not_yours: another baker's answer
- 409 action_closed: the card was undone or dismissed
- 409 action_replaced: a newer card for the same bake is further down; `message` says so
- 422 action_empty, action_expired, action_failed, action_gone, each with a `message` for the baker

`action_empty`: a new bake with nothing in it (send the baker to the form instead). `action_expired`: a reminder whose time has passed. `action_gone`: the bake, starter or reminder the card names no longer exists. `action_failed`: the tool could not do it.

### POST /api/v1/me/ask/messages/:id/action/undo

Takes back what a done action card did: deletes what it made, restores what it changed, stops its timer or reminder. Only until a newer question is asked in the thread.

Parameters:

- `id` (path, string (UUID), required): An answer's id.

Response:

```
200 {"action": {"tool": "…", "status": "undone"}}
```

Errors:

- 404 not_found, 404 no_action, 403 not_yours
- 409 action_closed: the card is not done
- 409 undo_closed: a newer question is in the thread, or a divided loaf changed since
- 422 action_failed: it could not be undone

### POST /api/v1/me/ask/messages/:id/action/dismiss

Puts an open action card away. Nothing is made. Safe to repeat.

Parameters:

- `id` (path, string (UUID), required): An answer's id.

Response:

```
200 {"action": {"tool": "…", "status": "dismissed"}}
```

Errors:

- 404 not_found, 404 no_action, 403 not_yours
- 409 action_closed: the card is already done or undone

### GET /api/v1/me/ask/messages/:id/offer

Whether Loafy offers to keep the bake this answer is about in the journal. The first call decides it with a small model, which can take a few seconds, and stores it; later calls read what was stored.

Parameters:

- `id` (path, string (UUID), required): An answer's id.

Response:

```
200 {"offer": Offer}, often {"offer": {"keep": false}}
```

Errors:

- 404 not_found: no such answer in the baker's threads

### POST /api/v1/me/ask/messages/:id/offer/accept

"Yes, keep it": adds the bake to the journal, dated on the day of the question (the next day for `tomorrow`). A bake for today or tomorrow is a plan until it is rated; one already baked counts at once, with Loafy's tip as its note for next time. The morning after, at 09:00, Loafy asks how it turned out. Safe to repeat: a second yes returns the same bake.

Parameters:

- `id` (path, string (UUID), required): An answer's id.
- `time_zone` (body, string): The baker's IANA zone, such as Europe/Berlin.

Example body:

```json
{"time_zone": "Europe/Berlin"}
```

Response:

```
200 {"offer": Offer} with `answer` and `bake`
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 422 no_offer: Loafy did not offer to keep a bake here
- 422 offer_expired: the bake's day is over

### POST /api/v1/me/ask/messages/:id/offer/decline

"No thanks" to the offer. Safe to repeat; an offer already answered stays as it is.

Parameters:

- `id` (path, string (UUID), required): An answer's id.

Response:

```
200 {"offer": Offer} with `answer`
```

Errors:

- 404 not_found: no such answer in the baker's threads
- 422 no_offer: Loafy did not offer to keep a bake here

### POST /api/v1/me/ask/bakes/:id/rate

Rates a bake Loafy kept from the chat (a kept offer or a started recipe card), as the faces under Loafy's check-in do.

Parameters:

- `id` (path, string (UUID), required): The bake's id.
- `rating` (body, integer, required): 1 to 5.
- `from_mail` (body, boolean): True for a face picked in the check-in mail: it rates only a bake not rated yet.

Example body:

```json
{"rating": 5}
```

Response:

```
200 {"bake": KeptBake}
```

Errors:

- 404 not_found: no such bake kept from the chat
- 422 invalid_rating: not a whole number from 1 to 5

### POST /api/v1/me/ask/bakes/:id/note

Keeps an answer as the bake's note for next time: its to-do steps, else its text, up to 600 characters, added under the note already there. The same tip is never added twice.

Parameters:

- `id` (path, string (UUID), required): The bake's id.
- `message_id` (body, string (UUID), required): An answer from the thread where the bake was kept.

Example body:

```json
{"message_id": "7b2e5a40-1c3d-4e6f-8a9b-0c1d2e3f4a5b"}
```

Response:

```
200 {"bake": KeptBake}
```

Errors:

- 404 not_found: no such kept bake, or the answer is not from its thread

## Bake journal

The baker's bake journal: every bake logged, planned or done, with its numbers, notes, photos and share cards. Photos go up one at a time after the bake exists. A spoken note can be turned into text here, and the Pizza Calculator site saves its pizzas into the journal through its own two calls.

#### BakeLog

- `id`, string (UUID): The bake's id.
- `title`, string: A label built by the server, not the baker's own `name`: the guide it was logged from (`Sourdough bread`), else its kind and day (`Pizza on 2026-10-12`).
- `baked_on`, string (date): The day it was baked, YYYY-MM-DD.
- `bake_type`, string: One of sourdough_bread, pizza, focaccia, bagels, brioche, croissant, baguettes, loaf_pan_bread, bread_rolls, pan_bread, tortilla, naan, flatbread, panettone, stollen, other.
- `rating`, integer or null: 1 to 5 stars. Null while it is unrated.
- `notes`, string or null: The baker's own notes. Never shown on the public page.
- `next_time_notes`, string or null: What to change next time. Private like `notes`.
- `caption`, string or null: The one line the share cards and the public page show, up to 90 characters.
- `journey_slug`, string or null: The guide it was logged from, such as `sourdough-bread`.
- `problems`, array of strings: What went wrong, from dense_crumb, gummy_interior, no_oven_spring, flat_loaf, burnt_crust, pale_crust, bland_flavor, too_sour, didnt_rise, sticky_dough.
- `hydration_percent`, integer or null: Water as a share of the flour.
- `salt_percent`, string (decimal) or null: Salt as a share of the flour.
- `starter_percent`, string (decimal) or null: Starter as a share of the flour.
- `starter_id`, string (UUID) or null: The baker's starter it used.
- `autolyse_minutes`, integer or null
- `fermentolyse`, boolean or null: An autolyse with the starter already in.
- `stretch_fold_count`, integer or null: Sets of stretch and folds.
- `bake_temp_celsius`, integer or null: The oven in the first baking phase, whole °C. The tenth is in `bake_temp_celsius_exact`.
- `bake_minutes`, integer or null: Length of the first baking phase.
- `bulk_hours`, string (decimal) or null: Bulk fermentation, in hours.
- `bulk_temp_celsius`, integer or null: The bulk's temperature, whole °C.
- `dough_rise_percent`, integer or null: How much the dough grew in bulk.
- `dry_yeast_percent`, string (decimal) or null: Dry yeast as a share of the flour.
- `fresh_yeast_percent`, string (decimal) or null: Fresh yeast as a share of the flour.
- `fridge_proof_hours`, string (decimal) or null
- `room_temp_proof_hours`, string (decimal) or null
- `proof_hours`, string (decimal) or null
- `proof_method`, string or null: room_temp or fridge.
- `baking_method`, string or null: home_oven, pizza_oven, wood_fired or stove.
- `based_on_id`, string (UUID) or null: The baker's earlier bake that this one repeats.
- `flours`, array of strings: The flour kinds used, as in `FlourLine.name`.
- `flour_amounts`, array of FlourLine: Each flour with its grams.
- `other_bake_type_description`, string or null: The baker's word for an `other` bake, such as `Cheesecake`.
- `preheat_temp_celsius`, integer or null: The oven before the bake went in, whole °C.
- `second_bake_temp_celsius`, integer or null: The oven in the second phase, whole °C.
- `second_bake_minutes`, integer or null
- `pieces`, integer or null: How many pieces the dough made. Null reads as one.
- `piece_weight_grams`, integer or null: What each piece weighed.
- `proof_rise_percent`, integer or null: How much the shaped dough grew in the proof.
- `loaf_shape`, string or null: boule or batard. Sourdough bread only.
- `preheat_level`, integer or null: A stove's dial while heating, 1 to 12.
- `bake_level`, integer or null: A stove's dial while baking, 1 to 12.
- `steam_method`, string or null: What the first phase baked in: dutch_oven, clay_pot, cloche, tray, oven_steam or none. Home oven only.
- `bake_fan`, boolean: The fan in the first phase. Always false outside a home oven.
- `second_bake_fan`, boolean: The fan in the second phase.
- `ph_readings`, array of objects: `{step, value}`, one per step, in the dough's order. step is starter_ready, mixing, end_of_bulk, shaping, before_proof, after_proof or after_bake; value is 2.0 to 9.0.
- `add_ins`, array of objects: `{name, label, grams}` in the baker's order. name is walnuts, hazelnuts, sunflower_seeds, pumpkin_seeds, sesame, flaxseeds, hemp_seeds, poppy_seeds, raisins, cranberries, olives, cheese, sun_dried_tomatoes, chocolate, or `other` with the baker's words as label. label and grams only when there are some.
- `recipe_source`, string or null: Where its numbers came from: `calculator` (planned with a calculator's Bake this), `pizza_calculator` (the Pizza Calculator site) or `ask` (kept from Ask Loafy). Null for a bake logged by hand.
- `preset`, boolean: Pinned to the presets on the app's Home. Three at most.
- `name`, string or null: The baker's own name for the bake, up to 40 characters.
- `done`, boolean: Marked done without stars.
- `tags`, array of strings: The baker's tags.
- `recipe`, Recipe or null: The bake's own recipe, for a bake that is no bread dough.
- `bulk_temp_celsius_exact`, number or null: The bulk's temperature to the tenth of a degree.
- `preheat_temp_celsius_exact`, number or null: To the tenth.
- `bake_temp_celsius_exact`, number or null: To the tenth.
- `second_bake_temp_celsius_exact`, number or null: To the tenth.
- `core_temp_celsius`, number or null: The core temperature it reached, °C to the tenth.
- `share_token`, string or null: The token of its public page.
- `share_url`, string or null: The public page's address, open to anyone with the link.
- `share_framing`, Framing: Which part of the featured photo every card shows that has no framing of its own.
- `share_framings`, object of Framing: Each card's framing, under story, square, landscape and wide.
- `share_style`, string: How the cards show the photo: photo or print. Always print without a photo.
- `share_print_shape`, string: The print's shape on the Stories card: landscape, square or portrait. When none was set, the featured photo's own.
- `recipe_card_design`, string: The version of the recipe and flowchart cards' design.
- `show_in_gallery`, boolean: The baker asked for it in the Loafy gallery.
- `gallery_status`, string: off, waiting (asked, not reviewed yet), shown or declined.
- `created_at`, string (ISO 8601)
- `updated_at`, string (ISO 8601)
- `photos`, array of strings: The originals' addresses, oldest first.
- `photo_details`, array of BakePhoto: Each photo with its id, sizes and whether it is the face of the bake, oldest first.
- `featured_photo_url`, string or null: The face of the bake, up to 1600 px: the photo chosen, else the oldest.

#### FlourLine

- `name`, string: The kind: bread_flour, all_purpose, whole_wheat, rye, spelt, einkorn, durum, tipo_00 or other.
- `grams`, integer: Whole grams. 0 is a flour that was not weighed.
- `flour_id`, string (UUID): A flour from Loafy's flour list, when it was picked there.
- `own_flour_id`, string (UUID): One of the baker's own flours.
- `grain`, string: wheat, spelt, rye, einkorn, emmer, durum, khorasan, barley, oat, buckwheat, rice, corn, gluten_free or other.
- `milling`, string: white, semi or whole.
- `strength`, string: cake, all_purpose or bread. White or semi wheat only.
- `label`, string: The word on the bag.
- `display`, string: The name to show, as it was when picked.

#### Recipe

- `servings`, integer: 1 to 500.
- `equipment`, array of strings: Up to 20, each up to 80 characters.
- `ingredients`, array of objects: `{group, name, amount, unit}`, up to 60. Only name is required (up to 120 characters); group up to 40, unit up to 24, amount a number above 0 and up to 100000. `1,5`, `1/2` and `½` read as numbers; words that are no number join the unit.
- `steps`, array of objects: `{title, text, minutes}`, up to 40. Only text is required (up to 2000 characters); title up to 80, minutes whole, 1 to 10080.

#### Framing

- `x`, number: The focal point across the upright photo, 0 to 1.
- `y`, number: The focal point down the photo, 0 to 1.
- `zoom`, number: 1 (the loosest crop that fills the card's window) to 5. Values outside these ranges are brought inside.

#### BakePhoto

- `id`, string (UUID): The photo's id, for DELETE and featured_photo.
- `checksum`, string: MD5 of the bytes, base64. The same bytes sent twice give back this photo.
- `url`, string: Up to 1600 x 1600 px.
- `thumb_url`, string: 400 x 400 px, cropped.
- `featured`, boolean: Whether it is the face of the bake.

### GET /api/v1/me/bake_logs

Every bake of the baker, a page at a time, newest first: by the day it was baked, then by when it was logged. Read on until `page` reaches `pagination.total_pages`.

Parameters:

- `page` (query, integer): From 1. Anything below is 1.
- `per` (query, integer): Bakes per page, 50 by default, 200 at most. The name is `per`; `per_page` is ignored.

Response:

```
200 {"success": true, "data": [BakeLog], "count": 50, "pagination": {"page": 1, "per_page": 50, "total": 120, "total_pages": 3}}
```

`count` is the number of bakes on this page. There are no filters: plans, bakes still baking and finished ones all come back. Fields typed `string (decimal)` are numbers sent as strings ("2.0"): parse them.

### POST /api/v1/me/bake_logs

Logs a bake. Only `baked_on` is required; a field left out stays empty. Send your own UUID as `bake_log.id` to make a retry safe: a second call with the same id hands back the bake already saved.

Parameters:

- `bake_log.id` (body, string (UUID)): Your own id for it. Anything that is not a UUID is ignored, and an id another baker's bake has gets a new one.
- `bake_log.baked_on` (body, string (date), required): YYYY-MM-DD.
- `bake_log.bake_type` (body, string): A kind from `BakeLog.bake_type`. sourdough_bread when left out.
- `bake_log.rating` (body, integer): 1 to 5. Leave it out while the bake is unrated.
- `bake_log.done` (body, boolean): Done without stars.
- `bake_log.name` (body, string): The baker's own name for it, up to 40 characters.
- `bake_log.notes` (body, string): Private.
- `bake_log.next_time_notes` (body, string): Private.
- `bake_log.caption` (body, string): Up to 90 characters, shown on the cards and the public page.
- `bake_log.journey_slug` (body, string): The guide it was logged from.
- `bake_log.starter_id` (body, string (UUID)): One of the baker's starters (GET /api/v1/me/starters).
- `bake_log.based_on_id` (body, string (UUID)): One of the baker's own bakes that this one repeats. Anything else is dropped and the bake still saves.
- `bake_log.other_bake_type_description` (body, string): For `other`: what it was. Panettone or Stollen named here, in any language Loafy speaks, becomes that kind.
- `bake_log.hydration_percent` (body, integer): 40 to 120.
- `bake_log.salt_percent` (body, number): 0 to 5.
- `bake_log.starter_percent` (body, number): 1 to 50.
- `bake_log.dry_yeast_percent` (body, number): 0 or more.
- `bake_log.fresh_yeast_percent` (body, number): 0 or more.
- `bake_log.autolyse_minutes` (body, integer): 0 to 1440.
- `bake_log.fermentolyse` (body, boolean)
- `bake_log.stretch_fold_count` (body, integer): 0 to 10.
- `bake_log.bulk_hours` (body, number)
- `bake_log.bulk_temp_celsius` (body, number): 0 to 50.
- `bake_log.dough_rise_percent` (body, integer): 0 to 300.
- `bake_log.proof_method` (body, string): room_temp or fridge.
- `bake_log.proof_hours` (body, number)
- `bake_log.room_temp_proof_hours` (body, number)
- `bake_log.fridge_proof_hours` (body, number)
- `bake_log.proof_rise_percent` (body, integer): 0 to 300.
- `bake_log.baking_method` (body, string): home_oven, pizza_oven, wood_fired or stove.
- `bake_log.steam_method` (body, string): dutch_oven, clay_pot, cloche, tray, oven_steam or none. Kept only for a home oven or a bake without a method.
- `bake_log.bake_fan` (body, boolean): Kept only for a home oven or a bake without a method, else false.
- `bake_log.second_bake_fan` (body, boolean): The same rule.
- `bake_log.preheat_temp_celsius` (body, number): 0 to 1000.
- `bake_log.bake_temp_celsius` (body, number): 0 to 1000.
- `bake_log.bake_minutes` (body, integer)
- `bake_log.second_bake_temp_celsius` (body, number)
- `bake_log.second_bake_minutes` (body, integer)
- `bake_log.bulk_temp_celsius_exact` (body, number): To the tenth. Wins over the whole degree in `bulk_temp_celsius`.
- `bake_log.preheat_temp_celsius_exact` (body, number): The same, for `preheat_temp_celsius`.
- `bake_log.bake_temp_celsius_exact` (body, number): The same, for `bake_temp_celsius`.
- `bake_log.second_bake_temp_celsius_exact` (body, number): The same, for `second_bake_temp_celsius`.
- `bake_log.core_temp_celsius` (body, number): 30 to 110.
- `bake_log.preheat_level` (body, integer): A stove's dial, 1 to 12.
- `bake_log.bake_level` (body, integer): A stove's dial, 1 to 12.
- `bake_log.pieces` (body, integer): 1 to 500.
- `bake_log.piece_weight_grams` (body, integer): 1 to 10000.
- `bake_log.loaf_shape` (body, string): boule or batard. Kept for sourdough_bread only.
- `bake_log.flours` (body, array of strings): Flour kinds, as in `FlourLine.name`. Not checked against the list.
- `bake_log.flour_amounts` (body, array of FlourLine): Each with `name` and `grams`, the other fields optional. A line with a name but no grams, and nothing else, is dropped.
- `bake_log.problems` (body, array of strings): From the list in `BakeLog.problems`. Unknown ones are dropped.
- `bake_log.ph_readings` (body, array of objects): `{step, value}`, steps and values as in `BakeLog.ph_readings`. A second reading for a step replaces the first.
- `bake_log.add_ins` (body, array of objects): `{name, label, grams}`, up to 12. A name not on the list becomes `other` with it as label. grams 1 to 5000, label up to 60 characters.
- `bake_log.tags` (body, array of strings): Up to 12, each up to 30 characters. Each tag once, whatever its capitals; a leading # is dropped.
- `bake_log.recipe` (body, Recipe): The bake's own recipe.
- `bake_log.preset` (body, boolean): Pin it to the presets on the app's Home.
- `bake_log.show_in_gallery` (body, boolean): Ask for it in the Loafy gallery. It shows once it has a photo and Loafy approved it.
- `bake_log.share_style` (body, string): photo or print.
- `bake_log.share_print_shape` (body, string): landscape, square or portrait.
- `bake_log.share_framing` (body, Framing): One framing for every card.
- `bake_log.share_framings` (body, object of Framing): A framing per card, under story, square, landscape or wide. A card left out keeps its own.
- `bake_log.recipe_source` (body, string): Only `calculator` is taken, for a bake planned from a calculator: it stays a plan until it is rated or done. Anything else is dropped.
- `ask_message_id` (body, string): Next to `bake_log`: the Ask Loafy answer whose bake card opened this form. Saving closes that card and adds its photos to the bake.
- `photo_ids` (body, array of strings): Next to `bake_log`: which of that card's photos to add, by signed id, up to 10. All of them when left out.

Example body:

```json
{"bake_log": {"id": "6f1c2a9e-8d3b-4c55-9a07-2b1e4f6d8c10", "bake_type": "sourdough_bread", "baked_on": "2026-11-29", "rating": 4, "hydration_percent": 75, "salt_percent": 2.0, "starter_percent": 20, "bulk_hours": 5, "bulk_temp_celsius": 24, "proof_method": "fridge", "fridge_proof_hours": 12, "baking_method": "home_oven", "steam_method": "dutch_oven", "bake_temp_celsius": 250, "bake_minutes": 20, "second_bake_temp_celsius": 230, "second_bake_minutes": 25, "flour_amounts": [{"name": "bread_flour", "grams": 400}, {"name": "whole_wheat", "grams": 100}], "notes": "Open crumb, a little sour", "tags": ["weekend"]}}
```

Response:

```
201 {"success": true, "data": BakeLog}, or 200 when the id already existed
```

Errors:

- 400 bad_json: the body is not valid JSON
- 400: `bake_log` holds none of the fields listed here (Rails' own error, without `error.code`)
- 422 params_missing: no `bake_log` object
- 422 invalid_starter: `starter_id` is not one of the baker's starters
- 422 invalid: a field failed validation, the message says which

An unknown value for `bake_type`, `proof_method` or `baking_method` is refused with 422 invalid, and nothing is saved. Fields outside this list are ignored. The share cards are drawn in the background, except for a plan.

### PATCH /api/v1/me/bake_logs/:id

Changes a bake. Send only the fields that change: a field left out keeps its value, and null clears a field that may be empty. The lists `problems`, `ph_readings`, `add_ins` and `tags` are replaced whole and cleared by an empty list; `recipe` is replaced whole and removed by one with no part.

Parameters:

- `id` (path, string (UUID), required)
- `bake_log` (body, object, required): Any field of POST's `bake_log` but `id` and `recipe_source`.
- `ask_message_id` (body, string): As on POST.
- `photo_ids` (body, array of strings): As on POST.

Example body:

```json
{"bake_log": {"rating": 5, "next_time_notes": "Bulk an hour longer", "problems": ["flat_loaf"], "starter_id": null}}
```

Response:

```
200 {"success": true, "data": BakeLog}
```

Errors:

- 404 not_found: no such bake, or not the baker's
- 400 bad_json, 422 params_missing, 422 invalid_starter, 422 invalid

What an edit leaves as it is: where the bake came from (`recipe_source`); a pin (`preset: true`) while three other bakes are pinned, though the rest of the edit saves; `bake_type: "other"` on a Panettone or a Stollen, which older apps send back. A whole degree equal to the stored tenth rounded is no change: send the `_exact` field to change a tenth. An empty `based_on_id`, the bake's own id or one that is not the baker's is dropped, so the link cannot be removed here. The same `share_framing` sent back as it was read changes nothing.

### PUT /api/v1/me/bake_logs/:id

Same as PATCH.

### DELETE /api/v1/me/bake_logs/:id

Deletes a bake and its photos. Bakes that repeat it stay, without the link. Safe to repeat: an id that is gone, or not the baker's, also answers 204.

Response:

```
204, no body
```

### PATCH /api/v1/me/bake_logs/:id/featured_photo

Makes one of the bake's photos its face, on its public page and its share cards, which are drawn again. Until one is chosen, the oldest photo is the face.

Parameters:

- `id` (path, string (UUID), required): The bake.
- `photo_id` (body, string (UUID), required): An id from `photo_details`.

Example body:

```json
{"photo_id": "3d6f0b52-1c4e-4b8a-9f3e-7a2d5c8e1b90"}
```

Response:

```
200 {"success": true, "data": BakeLog}
```

Errors:

- 404 not_found: no such bake
- 422 photo_not_found: the photo is not on this bake

### POST /api/v1/me/bake_logs/:bake_log_id/photos

Adds one photo, as multipart form data, and has the share cards drawn again. Sending the same bytes again hands back the photo already there. Up to 300 photo calls an hour, uploads and removals together.

Parameters:

- `photo` (multipart, file, required): JPEG, PNG or GIF, 10 MB at most.

Example body:

```
curl -F "photo=@loaf.jpg" …
```

Response:

```
201 {"success": true, "data": {"photo": BakePhoto, "bake_log": BakeLog}}, or 200 for a photo already there
```

Errors:

- 404 not_found: no such bake
- 422 photo_missing, photo_type, photo_too_large
- 429: more than 300 photo calls in an hour

### DELETE /api/v1/me/bake_logs/:bake_log_id/photos/:id

Removes one photo and has the share cards drawn again. If it was the face of the bake, the oldest photo left takes its place. Safe to repeat.

Response:

```
204, no body
```

Errors:

- 404 not_found: no such bake

### GET /api/v1/me/bake_logs/:bake_log_id/share_link

The bake's short address, the one its card prints, to paste into a chat or a link sticker, and its long page address. Asking for it is what makes the short address work: until a share screen has shown it, the code leads nowhere.

Response:

```
200 {"data": {"card_url": "https://loafy.ai/b/x7k", "card_address": "loafy.ai/b/x7k", "page_url": "https://loafy.ai/bake/<token>?via=share-link"}}
```

Errors:

- 404 not_found: no such bake

The code is three characters and may grow: show the address as it comes. `page_url` is null for a bake without a share token. This answer has no `success` key.

### GET /bake/:share_token/share-card.png

The bake's share card as a picture: its photo (or the print of it on a mat), its name, its numbers and the baker's first name, in the baker's language. loafy.ai draws a card the first time it is asked for and keeps it. The address is on loafy.ai itself, outside /api/v1: fetch it as any image, for a post or a story.

No key needed.

Parameters:

- `share_token` (path, string, required): The bake's `share_token`. A bake without one has no cards.
- `card_format` (query, string): story (1080 × 1920, the default), square (1080 × 1080), landscape (1200 × 630) or wide (1920 × 1080). Anything else is story.
- `style` (query, string): photo or print. The bake's own `share_style` when left out; always print for a bake without a photo.
- `shape` (query, string): The print's shape on the Stories card: landscape, square or portrait. The bake's own `share_print_shape` when left out.
- `layer` (query, string): words: everything but the photo, for an app that puts the photo in itself.

Response:

```
200 image/png, cacheable for a day
```

Errors:

- 404: no bake with this share token
- 429, no body: more than 30 cards drawn in a minute from one IP address. A card loafy.ai already keeps does not count.
- 503: the card could not be drawn this time; ask again

The Stories card prints the bake's short address, and asking for it makes that address work, as GET /api/v1/me/bake_logs/:bake_log_id/share_link does. Anyone with the share token can fetch the cards, as anyone with it can open the bake's page. After a change to the bake, the next request draws its card anew.

### GET /bake/:share_token/recipe-card.png

The bake's recipe as a picture: its ingredients in grams and its steps, with a QR code to the bake's page. Drawn the first time it is asked for and kept. On loafy.ai itself, outside /api/v1.

No key needed.

Parameters:

- `share_token` (path, string, required): The bake's `share_token`.
- `card_format` (query, string): story (1080 × 1920, the default) or square (1080 × 1080). Anything else is story.
- `locale` (query, string): The language to draw it in, one of Loafy's (such as de or fr). The baker's own when left out or unknown.

Response:

```
200 image/png, cacheable for a day
```

Errors:

- 404: no bake with this share token, or a bake with no recipe to show: neither a recipe of its own nor its flour in grams with a hydration
- 429, no body: more than 30 cards in a minute from one IP address
- 503: the card could not be drawn this time; ask again

### GET /bake/:share_token/flowchart-card.png

The same recipe as a flowchart, the whole bake at a glance, as a picture. Takes the same parameters as the recipe card and has a card exactly when it does. On loafy.ai itself, outside /api/v1.

No key needed.

Parameters:

- `share_token` (path, string, required): The bake's `share_token`.
- `card_format` (query, string): story (the default) or square.
- `locale` (query, string): The language to draw it in. The baker's own when left out or unknown.

Response:

```
200 image/png, cacheable for a day
```

Errors:

- 404: no bake with this share token, or no recipe to show
- 429, no body: more than 30 cards in a minute from one IP address
- 503: the card could not be drawn this time; ask again

### POST /api/v1/me/pizza_bakes

Saves a pizza from the Pizza Calculator site into the journal, dated today and unrated. The calculator's recipe is kept whole for the bake's page on loafy.ai; only its hydration becomes a field. To log a pizza with your own numbers, use POST /api/v1/me/bake_logs with `bake_type: pizza`.

Parameters:

- `recipe` (body, object, required): The Pizza Calculator's recipe. `recipe.inputs.hydration` (a number, 40 to 120 once rounded) becomes `hydration_percent`, `recipe.inputs.style` the pizza's style.
- `recipe.photo_data_url` (body, string): A photo as a data URL, `data:image/jpeg;base64,…`. One that cannot be read is skipped, and the bake still saves.

Example body:

```json
{"recipe": {"inputs": {"pizzas": 4, "style": "neapolitan", "hydration": 65}}}
```

Response:

```
201 {"id": "…", "journal_url": "https://loafy.ai/bakes/…"}
```

Errors:

- 400 {"error": "bad json"}: the body is not valid JSON
- 422 {"error": "recipe required"}: no `recipe`

Not idempotent: every call saves a new bake. The answers here are not wrapped in `success` and `data`. `journal_url` is the bake's page in the baker's journal, which needs the baker signed in. The stored recipe is not part of `BakeLog` in this API.

### PATCH /api/v1/me/pizza_bakes/:id

Rates one of the baker's pizza bakes, 1 to 5 stars. Sending no rating, or null, clears it.

Parameters:

- `id` (path, string (UUID), required): A bake whose `bake_type` is pizza.
- `rating` (body, integer): 1 to 5.

Example body:

```json
{"rating": 4}
```

Response:

```
200 {"id": "…", "rating": 4}
```

Errors:

- 404 {"error": "not found"}: no such bake, or it is no pizza
- 422 {"error": ["Rating is not included in the list"]}: a rating outside 1 to 5

### PUT /api/v1/me/pizza_bakes/:id

Same as PATCH.

### POST /api/v1/me/transcriptions

Turns a short spoken note into text, for a bake's notes or a question. Send the audio as multipart form data. Nothing is kept: the text comes back and goes nowhere else. Up to 60 an hour.

Parameters:

- `audio` (multipart, file, required): 8 MB at most. The format is read from the file name: wav, mp3, flac, m4a, ogg, webm or aac (mp4, mpeg, mpga, oga and opus too). Anything else is tried as m4a.
- `language` (multipart, string): The speech's two-letter language code, en by default. It sharpens short clips; it does not translate.

Example body:

```
curl -F "audio=@note.m4a" -F "language=de" …
```

Response:

```
200 {"success": true, "data": {"text": "Great oven spring today."}}
```

Errors:

- 403 email_unconfirmed: the account has not confirmed its email address
- 422 audio_missing, audio_too_large
- 429: more than 60 in an hour
- 503 provider_failed: the transcription service failed; try again, or type it

## Starters

The baker's sourdough starters. Each has a public passport page that opens to anyone with its link. Photos go up one at a time after the starter exists.

#### Starter

- `id`, string (UUID): The starter's id.
- `name`, string: Its name, unique among the baker's starters.
- `birthday`, string (date): The day it was started, YYYY-MM-DD.
- `age_in_days`, integer: Days since its birthday.
- `notes`, string or null: The baker's notes.
- `story`, string or null: Its story, shown on the passport.
- `share_token`, string or null: The token of its public passport.
- `share_url`, string or null: The passport's public address.
- `photos`, array of strings: The originals' addresses, oldest first.
- `photo_details`, array of Photo: Each photo with its id, a 1600 px version and a 400 px thumbnail.
- `created_at`, string (ISO 8601)
- `updated_at`, string (ISO 8601)

#### Photo

- `id`, string (UUID): The photo's id, for DELETE.
- `checksum`, string: MD5 of the bytes, base64. The same bytes sent twice give back this photo.
- `url`, string: Up to 1600 x 1600 px.
- `thumb_url`, string: 400 x 400 px, cropped.

### GET /api/v1/me/starters

Every starter of the baker, by name.

Response:

```
200 {"success": true, "data": [Starter], "count": 1}
```

### POST /api/v1/me/starters

Adds a starter. Send your own UUID as `starter.id` to make a retry safe: a second call with the same id hands back the starter already saved.

Parameters:

- `starter.name` (body, string, required): Unique among the baker's starters.
- `starter.birthday` (body, string (date), required): YYYY-MM-DD.
- `starter.notes` (body, string)
- `starter.story` (body, string)
- `starter.id` (body, string (UUID)): Your own id for it. Anything that is not a UUID is ignored.

Example body:

```json
{"starter": {"name": "Fritz", "birthday": "2026-03-01", "notes": "Rye, 100 % hydration"}}
```

Response:

```
201 {"success": true, "data": Starter}, or 200 when the id already existed
```

Errors:

- 422 params_missing: no `starter` object
- 422 invalid: a field failed validation, the message says which

### PATCH /api/v1/me/starters/:id

Changes a starter's name, birthday, notes or story. Send only the fields that change.

Parameters:

- `id` (path, string (UUID), required)
- `starter` (body, object, required): Any of name, birthday, notes, story.

Example body:

```json
{"starter": {"notes": "Fed 1:5:5 at 24 °C"}}
```

Response:

```
200 {"success": true, "data": Starter}
```

Errors:

- 404 not_found
- 422 params_missing, 422 invalid

### PUT /api/v1/me/starters/:id

Same as PATCH.

### DELETE /api/v1/me/starters/:id

Deletes a starter. Bakes that used it keep their entry. Safe to repeat: an id that is gone, or not the baker's, also answers 204.

Response:

```
204, no body
```

### POST /api/v1/me/starters/:starter_id/photos

Adds one photo, as multipart form data. Sending the same bytes again hands back the photo already there. Up to 300 uploads an hour.

Parameters:

- `photo` (multipart, file, required): JPEG, PNG or GIF, 10 MB at most.

Example body:

```
curl -F "photo=@starter.jpg" …
```

Response:

```
201 {"success": true, "data": {"photo": Photo, "starter": Starter}}, or 200 for a photo already there
```

Errors:

- 404 not_found: no such starter
- 422 photo_missing, photo_type, photo_too_large

### DELETE /api/v1/me/starters/:starter_id/photos/:id

Removes one photo. Safe to repeat.

Response:

```
204, no body
```

Errors:

- 404 not_found: no such starter

## Containers

The bowls and jars a starter or dough is weighed in, each with its empty weight, so what is inside can be told from what the scale shows. Photos go up one at a time after the container exists.

#### Container

- `id`, string (UUID): The container's id.
- `name`, string: Its name, unique among the baker's containers.
- `weight_grams`, integer: Its empty weight in whole grams, 1 to 10000.
- `notes`, string or null: The baker's notes.
- `photos`, array of strings: The originals' addresses, oldest first.
- `photo_details`, array of Photo: Each photo with its id, a 1600 px version and a 400 px thumbnail.
- `created_at`, string (ISO 8601)
- `updated_at`, string (ISO 8601)

### GET /api/v1/me/containers

Every container of the baker, by name.

Response:

```
200 {"success": true, "data": [Container], "count": 1}
```

### POST /api/v1/me/containers

Adds a container. Send your own UUID as `container.id` to make a retry safe: a second call with the same id hands back the container already saved.

Parameters:

- `container.name` (body, string, required): Unique among the baker's containers.
- `container.weight_grams` (body, integer, required): The empty weight in grams, more than 0 and at most 10000.
- `container.notes` (body, string)
- `container.id` (body, string (UUID)): Your own id for it. Anything that is not a UUID is ignored, and so is an id another baker's container has: the container then gets an id of its own.

Example body:

```json
{"container": {"name": "Weck jar", "weight_grams": 425, "notes": "The tall one"}}
```

Response:

```
201 {"success": true, "data": Container}, or 200 when the id already existed
```

Errors:

- 422 params_missing: no `container` object
- 422 invalid: a field failed validation, the message says which

### PATCH /api/v1/me/containers/:id

Renames a container, corrects its weight or changes its notes. Send only the fields that change.

Parameters:

- `id` (path, string (UUID), required)
- `container` (body, object, required): Any of name, weight_grams, notes.

Example body:

```json
{"container": {"weight_grams": 430}}
```

Response:

```
200 {"success": true, "data": Container}
```

Errors:

- 404 not_found
- 422 params_missing, 422 invalid

### PUT /api/v1/me/containers/:id

Same as PATCH.

### DELETE /api/v1/me/containers/:id

Deletes a container and its photos. Safe to repeat: an id that is gone, or not the baker's, also answers 204.

Response:

```
204, no body
```

### POST /api/v1/me/containers/:container_id/photos

Adds one photo, as multipart form data. Sending the same bytes again hands back the photo already there. Up to 300 photo calls an hour, uploads and deletions together.

Parameters:

- `photo` (multipart, file, required): JPEG, PNG or GIF, 10 MB at most.

Example body:

```
curl -F "photo=@jar.jpg" …
```

Response:

```
201 {"success": true, "data": {"photo": Photo, "container": Container}}, or 200 for a photo already there
```

Errors:

- 404 not_found: no such container
- 422 photo_missing, photo_type, photo_too_large

### DELETE /api/v1/me/containers/:container_id/photos/:id

Removes one photo. Safe to repeat.

Response:

```
204, no body
```

Errors:

- 404 not_found: no such container

## Flours and calculator defaults

Loafy's list of flours as the bake form's flour picker reads it, the baker's own flours, their list of the flours they bake with ("Your flours"), and the values the bread and pizza calculators open on.

#### Flour

- `id`, string (UUID): The flour's id.
- `name`, string: The name it is sold under.
- `brand`, string or null
- `kind`, string: One of bread_flour, all_purpose, whole_wheat, rye, spelt, einkorn, durum, tipo_00, other.
- `type_designation`, string or null: The type printed on the bag, such as Type 1150 or Tipo 00.
- `protein_per_100g`, number or null: Grams of protein in 100 g.
- `countries`, array of strings: Where it is sold, as lower-case ISO 3166-1 alpha-2 codes.
- `image_url`, string or null: Loafy's copy of the bag's picture.
- `source`, string: open_food_facts or loafy.
- `references`, array of FlourReference: The numbers it is known by elsewhere.

#### FlourReference

- `source`, string: open_food_facts.
- `external_id`, string: The product's barcode there.
- `url`, string: The product's page there.

#### PickerIndex

- `version`, integer: The list's format. A new version can change what the rows hold.
- `fields`, array of strings: The names of each row's columns, in order: id, name, brand, kind, grain, milling, strength, type, protein, countries, image, picks, curated, alt.
- `kinds`, array of strings: The nine kinds; a row's kind is a position in this list.
- `grains`, array of strings: wheat, spelt, rye, einkorn, emmer, durum, khorasan, barley, oat, buckwheat, rice, corn, gluten_free, other.
- `millings`, array of strings: white, semi, whole.
- `strengths`, array of strings: cake, all_purpose, bread.
- `picture_url`, string: Where a row's picture is, with {id} and {file} to fill in. A path is relative to the API's host.
- `brands`, array of strings: Each brand once; an empty string for the flours without one.
- `brand_alt`, array of strings: For each brand, its other spellings, with " | " between them.
- `items`, array of arrays: One row per flour, its columns in the order of `fields`.
- `attribution`, string: The credit the data's licence (ODbL) and the photos' (CC BY-SA) ask for. Show it wherever the flours are shown.

#### PickerSetup

- `country`, string or null: The country whose bag words are given, or null when Loafy knows none for the baker.
- `grains`, array of strings: The grains the picker shows as chips: wheat, spelt, rye, einkorn, emmer, durum, other.
- `other_grains`, array of strings: The grains behind Other: khorasan, barley, oat, buckwheat, rice, corn, gluten_free.
- `bag_words`, object: The words on the bags of the country, per grain: keys wheat, spelt, rye, durum, each an array of BagWord, and default (white, semi, whole) for every other grain.
- `own`, array of OwnFlour: The baker's own flours: the twelve changed last, then every other one on their list. Without `flour_id`.
- `recent`, array of PickerLine: The flours of the baker's last bakes, once each, newest first, six at most. No grams.
- `last`, array of PickerLine or null: The last bake's lines with their grams, or null when there are none.
- `saved`, array of PickerLine: The baker's list (Your flours), in their order. No grams.

#### BagWord

- `label`, string: The word as the bag prints it, such as Type 550. Absent in `default`.
- `word`, string: white, semi or whole, for the app to put in its own language. Only in `default`.
- `milling`, string: What the word says about the milling: white, semi or whole.
- `strength`, string: cake, all_purpose or bread, when the word says it. Absent otherwise.
- `more`, boolean: true when the word waits behind a More chip. Absent otherwise.

#### PickerLine

- `name`, string: The kind the line counts as, one of the nine, worked out from its grain, milling and strength.
- `flour_id`, string (UUID): A flour of Loafy's list. Absent on other lines.
- `own_flour_id`, string (UUID): One of the baker's own flours. Absent on other lines.
- `grain`, string: One of PickerIndex's grains.
- `milling`, string: white, semi or whole.
- `strength`, string: cake, all_purpose or bread, for white wheat only.
- `label`, string: The word on the bag.
- `display`, string or null: An exact or own flour: the name to show. A grain line: the baker's own words for it, or null.
- `image`, string or null: The flour's picture, or the baker's photo of their own flour's bag.
- `grams`, integer: Only in `last`. 0 means not weighed.

#### OwnFlour

- `own_flour_id`, string (UUID): The flour's id, for PATCH /api/v1/me/baker_flours/:id and for lines.
- `display`, string: Brand and name together.
- `grain`, string
- `milling`, string or null
- `strength`, string or null
- `label`, string or null: The word on the bag.
- `name`, string: The kind it counts as, one of the nine.
- `image`, string or null: The baker's photo of the bag, small. Only they see it.
- `flour_name`, string: The name alone, as the baker gave it.
- `brand`, string or null
- `protein_per_100g`, number or null
- `town`, string or null: Where it comes from.
- `shared`, boolean: Offered to Loafy for its list.
- `flour_id`, string (UUID) or null: Only in the answers of /api/v1/me/baker_flours: the flour of Loafy's list it was matched to after review, null until then.

#### CalculatorDefaults

- `bread`, BreadDefaults: Absent until the bread calculator's values are saved or cleared.
- `pizza`, PizzaDefaults: Absent until the pizza calculator's values are saved or cleared.

#### BreadDefaults

- `count`, integer: Loaves, 1 to 100.
- `loaf_size`, integer: Grams of flour per loaf, 50 to 2000. Not the dough's weight.
- `hydration`, integer: Water in percent of the flour, 55 to 100.
- `whole_grain`, integer: Whole grain in percent of the flour, 0 to 100.
- `starter`, number: The baker's own starter share in percent of the flour, 1 to 50, to a tenth. Absent when the recipe's own is used.
- `salt`, number: The baker's own salt in percent of the flour, 0 to 5, to a tenth. Absent when the recipe's own is used.
- `add_ins`, array of AddIn: Absent when there are none.
- `flours`, array of CalculatorFlour: The flours in place of the whole-grain share. Absent when there are none.
- `updated_at`, string (ISO 8601): When the block was last saved, in UTC, so a device can take the newer one.
- `cleared_at`, string (ISO 8601): Only in a block forgotten with DELETE, and then its only field.

#### PizzaDefaults

- `pizza_count`, integer: Pizzas, 1 to 12.
- `ball_weight`, integer: Grams of dough per ball, 50 to 350.
- `hydration`, integer: Water in percent of the flour, 55 to 75.
- `leavening`, string: yeast or sourdough.
- `salt`, number: The baker's own salt in percent of the flour, 0 to 5, to a tenth. Absent when the recipe's own is used.
- `updated_at`, string (ISO 8601): When the block was last saved, in UTC.
- `cleared_at`, string (ISO 8601): Only in a block forgotten with DELETE, and then its only field.

#### AddIn

- `name`, string: One of walnuts, hazelnuts, sunflower_seeds, pumpkin_seeds, sesame, flaxseeds, hemp_seeds, poppy_seeds, raisins, cranberries, olives, cheese, sun_dried_tomatoes, chocolate, or other.
- `label`, string: Only with other: the baker's own name for it, 60 characters at most. A label that names one of the list becomes that one.
- `percent`, number: Its share of the flour, 1 to 100, to a hundredth. Missing or 0 is 10.

#### CalculatorFlour

- `flour_id`, string (UUID): A flour of Loafy's list.
- `own_flour_id`, string (UUID): One of the baker's own flours.
- `grain`, string: A line needs at least one of flour_id, own_flour_id and grain.
- `milling`, string
- `strength`, string
- `label`, string: The word on the bag.
- `display`, string: The name to show.
- `percent`, integer: Its share of the flour, 0 to 100. The first line takes what the others leave, so the shares add up to 100.

### GET /api/v1/flours

Searches Loafy's flour database by name, brand or barcode, the same flours the apps' flour picker shows. Up to 600 searches an hour per key.

Parameters:

- `q` (query, string): Words of the name or the brand (every word must match), or a barcode.
- `kind` (query, string): One of the nine kinds.
- `country` (query, string): Sold in this country: two letters, such as de.
- `limit` (query, integer): 1 to 100, 50 when left out.

Response:

```
200 {"success": true, "data": [Flour], "meta": {"total": 2, "limit": 50}, "attribution": "Contains information from Open Food Facts …"}
```

Errors:

- 403 forbidden: a key made for one admin area only
- 422 bad_request: a kind or a country it does not know
- 429 rate_limited: more than 600 searches in an hour

Only flours that are neither hidden nor merged into another, by name. The `meta.total` counts every match, the `data` only up to the limit. Show `attribution` wherever the flours are shown.

### GET /api/v1/me/flours/picker

Loafy's flour list as the flour picker searches it on the device: one compact row per flour. The list is large: keep it with its ETag and send If-None-Match, a 304 means it has not changed.

Response:

```
200 {"success": true, "data": PickerIndex}, or 304 with no body
```

The flours are those of Loafy's list that are neither hidden nor merged and have a brand or were added by Loafy. Each row of `items` holds, in the order of `fields`: the id; the name a baker reads; brand, kind, grain, milling and strength as positions in `brands`, `kinds`, `grains`, `millings` and `strengths` (grain, milling and strength may be null); the type printed on the bag or null; the protein per 100 g, or null when it is unknown or not believable for the grain; the countries it is sold in, comma-separated; the picture's file name or null; the countries where it is one of Loafy's picks, comma-separated; 1 when Loafy checked it by hand, else 0; and other names it is known by, with " | " between them. A row's picture is `picture_url` with the row's id and file filled in.

### GET /api/v1/me/flours/setup

What the flour picker starts with: the grains, the words on the bags of the baker's country, the baker's own flours, the flours of their last bakes, the last bake's lines and their list (Your flours).

Parameters:

- `country` (query, string): The device's region, two letters. Used when Loafy knows that country's bags; otherwise the request's country, then the account's language decide.

Response:

```
200 {"success": true, "data": PickerSetup}
```

### POST /api/v1/me/flours/:id/pictures

Sends a better photo of a flour's bag, as multipart form data. Loafy reviews it, and once approved it becomes the flour's picture for every baker. One open photo per baker and flour: a second replaces the first. Up to 30 an hour.

Parameters:

- `id` (path, string (UUID), required): A flour of the picker's list.
- `photo` (multipart, file, required): JPEG, PNG, WebP or HEIC, 15 MB at most.

Example body:

```
curl -F "photo=@bag.jpg" …
```

Response:

```
201 {"success": true, "data": {"id": "…", "flour_id": "…", "status": "pending"}}
```

Errors:

- 404 not_found: no flour of the list has this id
- 422 invalid_photo: no photo, or not one it takes
- 429: more than 30 in an hour

### PUT /api/v1/me/flours/shelf

Replaces the baker's list of the flours they bake with (Your flours), which the picker offers first. Send the whole list in the baker's order: adding, removing and moving are each one call with the new list.

Parameters:

- `lines` (body, array, required): Each line one of {flour_id}, {own_flour_id} or {grain, milling?, strength?, label?, display?}. Other keys are ignored. The same flour twice is kept once. 12 lines at most.

Example body:

```json
{"lines": [{"flour_id": "00000000-0000-4000-8000-000000000002"}, {"grain": "rye", "milling": "whole"}]}
```

Response:

```
200 {"success": true, "data": {"saved": [PickerLine]}}
```

Errors:

- 422 invalid: no list, a line that names no flour of the list, none of the baker's own flours and no grain, or more than 12; nothing changes

A flour merged into another is saved as the one it went into. The list is kept on the account, so every device and the web see the same one.

### POST /api/v1/me/baker_flours

Adds a flour of the baker's own, one Loafy's list does not have, and answers it as a picker line. Multipart form data, so a photo of the bag can come along; without a photo a JSON body works too. Up to 30 calls an hour, edits included.

Parameters:

- `baker_flour.name` (multipart, string, required): The name as on the bag, 120 characters at most.
- `baker_flour.grain` (multipart, string, required): One of PickerIndex's grains.
- `baker_flour.brand` (multipart, string): The mill or brand, 120 characters at most.
- `baker_flour.milling` (multipart, string): white, semi or whole.
- `baker_flour.strength` (multipart, string): cake, all_purpose or bread.
- `baker_flour.label` (multipart, string): The word on the bag, 40 characters at most.
- `baker_flour.protein_per_100g` (multipart, number): More than 0, at most 100.
- `baker_flour.town` (multipart, string): Where it comes from, 120 characters at most.
- `baker_flour.country` (multipart, string): Two letters. Left out, the request's country or the account's language give it when Loafy knows that country's bags.
- `baker_flour.barcode` (multipart, string): Digits only are kept, 8 to 14 of them.
- `baker_flour.shared` (multipart, boolean): "1" or "0", on when left out: Loafy may review it and add it to its list for everyone.
- `baker_flour.photo` (multipart, file): The bag: JPEG, PNG, WebP or HEIC, 15 MB at most.

Example body:

```
curl -F "baker_flour[name]=Bela moka T-500" -F "baker_flour[brand]=Mlinotest" -F "baker_flour[grain]=wheat" -F "baker_flour[label]=T-500" …
```

Response:

```
201 {"success": true, "data": OwnFlour}
```

Errors:

- 400: no `baker_flour` object
- 422 invalid: a field failed validation, the message says which, in the account's language
- 429: more than 30 calls in an hour

### PATCH /api/v1/me/baker_flours/:id

Edits one of the baker's own flours. Only the fields sent change, an empty one clears it, and the photo stays unless a new one comes (send multipart form data for that). Every line of the baker's list that names the flour follows; a bake keeps the name it was logged with.

Parameters:

- `id` (path, string (UUID), required): The flour's own_flour_id.
- `baker_flour` (body, object, required): Any of the fields POST takes. Name and grain stay required.

Example body:

```json
{"baker_flour": {"brand": "Kialla", "protein_per_100g": 12.5}}
```

Response:

```
200 {"success": true, "data": OwnFlour}
```

Errors:

- 400: no `baker_flour` object
- 404 not_found: not one of the baker's flours
- 422 invalid: a field failed validation; nothing changes
- 429: more than 30 calls in an hour

When the grain, milling, strength or label changes, send all four, so a change made meanwhile on another device is not mixed with this one. A match Loafy made to a flour of its list stays.

### GET /api/v1/me/calculator_defaults

The values the baker saved with "Make this my default" in the bread and pizza calculators. An empty object when nothing was saved.

Response:

```
200 {"success": true, "data": CalculatorDefaults}
```

### PUT /api/v1/me/calculator_defaults

Saves one calculator's values, or both. A block left out is not touched. Values outside their range are brought into it, never refused.

Parameters:

- `bread` (body, object): count, loaf_size, hydration, whole_grain, starter, salt, add_ins, flours, as in BreadDefaults.
- `pizza` (body, object): pizza_count, ball_weight, hydration, leavening, salt, as in PizzaDefaults. A leavening other than sourdough is saved as yeast.

Example body:

```json
{"bread": {"count": 2, "loaf_size": 500, "hydration": 70, "whole_grain": 20, "salt": 1.8, "add_ins": [{"name": "walnuts", "percent": 15}]}}
```

Response:

```
200 {"success": true, "data": CalculatorDefaults}
```

Errors:

- 422 params_missing: neither a bread nor a pizza block

Each save replaces the calculator's block and stamps `updated_at`. A field left out is gone, except `salt` and `add_ins`: without their key the saved ones stay. `"salt": null` forgets the salt, `"add_ins": []` takes the add-ins out. count, loaf_size, hydration, whole_grain, pizza_count and ball_weight are kept as whole numbers.

### DELETE /api/v1/me/calculator_defaults

Forgets one calculator's values, or all of them. The forgotten block keeps only `cleared_at`, so another device can tell it was forgotten on purpose. Safe to repeat.

Parameters:

- `calculator` (query, string): bread or pizza. Left out, everything is cleared and data is an empty object.

Response:

```
200 {"success": true, "data": CalculatorDefaults}
```

## Kitchen timers

Timers shared across the baker's devices: the phone and the web count down the same clock, and stopping a timer in one place stops it everywhere. When one ends, Loafy sends an alert to the baker's phones. A guide step's "Remind me" is a timer too.

#### KitchenTimer

- `id`, string (UUID): The timer's id.
- `label`, string: What it is for, 60 characters at most.
- `preset_key`, string or null: The preset it was started from, such as preheat_oven.
- `journey_slug`, string or null: The guide it belongs to.
- `step_id`, string or null: The guide's step it belongs to.
- `remind_via`, string or null: app or email for a guide step's reminder, null for an ordinary timer.
- `duration_seconds`, integer: Its length. Extending a timer moves `ends_at` and leaves this as it was.
- `started_at`, string (ISO 8601)
- `ends_at`, string (ISO 8601): When it rings.
- `status`, string: running, finished (it rang) or dismissed (stopped, or done after it rang; final). A running timer whose ends_at has passed counts as finished.
- `finished_at`, string (ISO 8601) or null: When it ended, once it has rung.
- `dismissed_at`, string (ISO 8601) or null: When it was stopped.
- `created_at`, string (ISO 8601)
- `updated_at`, string (ISO 8601)

### GET /api/v1/me/kitchen_timers

The timers a device syncs from, the soonest end first: every one that runs or has rung, and the ones stopped in the last day, so a device that missed the stop drops them too.

Response:

```
200 {"success": true, "data": [KitchenTimer], "count": 1}
```

### POST /api/v1/me/kitchen_timers

Starts a timer. Send your own UUID as `kitchen_timer.id` to make a retry safe: a second call with the same id hands back the timer already saved. Values are brought into range, never refused: a label too long is cut, a length too long is capped.

Parameters:

- `kitchen_timer.label` (body, string, required): 60 characters at most.
- `kitchen_timer.duration_seconds` (body, integer, required): 1 to 259200 (72 hours); for a reminder up to 691200 (8 days).
- `kitchen_timer.started_at` (body, string (ISO 8601)): For a timer started offline: up to 72 hours back. Left out, further back, or more than a minute ahead, the start is now.
- `kitchen_timer.preset_key` (body, string)
- `kitchen_timer.journey_slug` (body, string)
- `kitchen_timer.step_id` (body, string)
- `kitchen_timer.remind_via` (body, string): app or email makes it a reminder; any other value an ordinary timer. Needs a confirmed e-mail address.
- `kitchen_timer.time_zone` (body, string): With a reminder: the device's IANA zone, such as Europe/Berlin. Kept as the baker's zone unless they chose one in Settings.
- `kitchen_timer.id` (body, string (UUID)): Your own id for it. Anything that is not a UUID is ignored.
- `kitchen_timer.origin_push_token` (body, string): For Loafy's apps: the phone's own push token. That phone rings on its own, so the alert leaves it out.

Example body:

```json
{"kitchen_timer": {"label": "Preheat oven", "duration_seconds": 1800, "preset_key": "preheat_oven"}}
```

Response:

```
201 {"success": true, "data": KitchenTimer}, or 200 when the id already existed
```

Errors:

- 422 params_missing: no `kitchen_timer` object, or no label or duration_seconds
- 403 unconfirmed: a reminder before the account's e-mail address is confirmed
- 422 invalid: a field failed validation, or the id is already taken

A timer whose end has passed by the time it arrives (it rang offline) is stored as finished and does not ring again. A new reminder dismisses a running reminder of the same kind in the same guide. When a timer ends, the alert goes to the baker's phones, and a reminder with remind_via email also goes out as an e-mail.

### PATCH /api/v1/me/kitchen_timers/:id

Gives a running timer a new length: it then ends that long after it started, never sooner than a minute from now. The same length sent again changes nothing, so a retry is safe. A timer that has rung stays as it is; give it more time with extend.

Parameters:

- `id` (path, string (UUID), required)
- `kitchen_timer.duration_seconds` (body, integer, required): The whole new length, at most 72 hours (8 days for a reminder).
- `kitchen_timer.origin_push_token` (body, string): For Loafy's apps: the phone's own push token, so that phone is not woken.

Example body:

```json
{"kitchen_timer": {"duration_seconds": 32400}}
```

Response:

```
200 {"success": true, "data": KitchenTimer}
```

Errors:

- 404 not_found
- 409 dismissed: the timer was already stopped
- 422 params_missing: no duration_seconds

### PUT /api/v1/me/kitchen_timers/:id

Same as PATCH.

### DELETE /api/v1/me/kitchen_timers/:id

Takes a stopped timer out of the history. It stays in the list GET answers for the rest of its day, so other devices still learn of the stop. Safe to repeat.

Response:

```
200 {"success": true, "data": KitchenTimer}
```

Errors:

- 404 not_found
- 409 still_live: the timer still runs or rings; dismiss it first

### GET /api/v1/me/kitchen_timers/history

The timers that are over, the last stopped first: every dismissed timer that is not a reminder and was not taken out of the history.

Parameters:

- `before` (query, string (UUID)): The id of the last timer you have: the read goes on with the older ones.
- `limit` (query, integer): 1 to 200, 50 when left out.

Response:

```
200 {"success": true, "data": [KitchenTimer], "count": 2, "more": false}
```

`more` is true when older timers follow. An id in `before` that is not one of the baker's stopped timers reads from the top.

### POST /api/v1/me/kitchen_timers/:id/extend

More time. A running timer's end moves by `seconds`, never past 72 hours after its start (8 days for a reminder). A timer that has rung runs again and ends `seconds` from now. Each call adds time again.

Parameters:

- `id` (path, string (UUID), required)
- `seconds` (body, integer): 300 when left out.
- `origin_push_token` (body, string): For Loafy's apps: the phone's own push token, so that phone is not woken.
- `card_refused` (body, boolean): For Loafy's iPhone app: iOS would not start the timer's card on that phone, so Loafy starts it there by push.

Example body:

```json
{"seconds": 600}
```

Response:

```
200 {"success": true, "data": KitchenTimer}
```

Errors:

- 404 not_found
- 409 dismissed: the timer was already stopped

### POST /api/v1/me/kitchen_timers/:id/dismiss

Stops a running timer, or ends one that rang. Final, and the baker's other devices learn of it. Safe to repeat.

Parameters:

- `id` (path, string (UUID), required)
- `origin_push_token` (body, string): For Loafy's apps: the phone's own push token, so that phone is not woken.

Response:

```
200 {"success": true, "data": KitchenTimer}
```

Errors:

- 404 not_found

## Guided journeys and first steps

What the baker did with Loafy's guided journeys: the ones they opened and finished, and the version of a journey they chose. Also the first-steps guide a new baker sees on Home. The journeys themselves, their slugs, titles and steps, come from the tools API without a key: `POST /api/v1/tools/list_sourdough_journeys` and `POST /api/v1/tools/get_sourdough_journey_step`.

#### JourneyCompletion

- `journey_slug`, string: The journey's slug, for example `make-starter`.
- `completed_at`, string (ISO 8601): When it was finished, in UTC.

#### JourneyStart

- `journey_slug`, string
- `started_at`, string (ISO 8601): When it was first opened, in UTC.

#### JourneyVariant

- `journey_slug`, string
- `variant`, string: The version chosen, for example `overnight`.
- `chosen_at`, string (ISO 8601): In UTC.

#### Achievement

- `key`, string: For example `starter_journey`.
- `name`, string
- `description`, string
- `emoji`, string
- `mascot`, string: The file name of its dough mascot.
- `category`, string: `journeys`.
- `target`, integer: Only on Journey Master: the number of journeys it takes (5).

#### Guide

- `state`, string: `guide` (the welcome and the four steps), `celebration` (all four done, not yet celebrated) or `off` (finished, hidden, or not a new baker).
- `done_count`, integer: Steps done. 0 when the guide is off.
- `total`, integer: 4.
- `making_starter`, boolean: The latest journey is `make-starter`, so a first loaf is still a week or two away.
- `intent`, string or null: The answer to the welcome question "What do you want to do first?": `bake`, `starter`, `ask`, `check`, `learn` or `skip`. Null while never answered, and always when the guide is off.
- `steps`, array of GuideStep: The four steps in this order: journey, starter, bake, ask. Empty when the guide is off.

#### GuideStep

- `key`, string: `journey`, `starter`, `bake` or `ask`.
- `done`, boolean
- `journey_slug`, string or null: Only on `journey`: the latest journey opened or finished.
- `starter`, object or null: Only on `starter`: the newest starter's `id` and `name`.
- `count`, integer: Only on `bake`: the baker's counted bakes.

### GET /api/v1/me/journey_completions

Every journey the baker finished, the newest first.

Response:

```
200 {"success": true, "data": [JourneyCompletion], "count": 1}
```

### POST /api/v1/me/journey_completions

Marks a journey as finished, so its badge is earned on every device. Safe to repeat: a journey finished before answers 200 with the first completion.

Parameters:

- `journey_slug` (body, string, required)
- `completed_at` (body, string (ISO 8601)): When it was finished. Missing or unreadable means now.

Example body:

```json
{"journey_slug": "make-starter", "completed_at": "2026-10-13T06:30:00Z"}
```

Response:

```
201 {"success": true, "data": JourneyCompletion, "already_completed": false, "achievement": Achievement or null, "journey_master": Achievement or null}, or 200 {"success": true, "data": JourneyCompletion, "already_completed": true}
```

Errors:

- 422 params_missing: no journey_slug
- 404 not_found: no journey has that slug

`achievement` is the badge this journey awards, null for a journey without one. `journey_master` is Journey Master when this was the last of the five journeys with a badge; its name and description are in English. Both badges count as already celebrated, so GET /api/v1/me/badges/fresh does not offer them again.

### POST /api/v1/me/journey_starts

Records that the baker opened a journey, so the first-steps guide ticks its journey step. Safe to repeat: a journey opened before answers 200 with the first start.

Parameters:

- `journey_slug` (body, string, required)

Example body:

```json
{"journey_slug": "sourdough-bread"}
```

Response:

```
201 {"success": true, "data": JourneyStart, "already_started": false}, or 200 with "already_started": true
```

Errors:

- 422 params_missing: no journey_slug
- 404 not_found: no journey has that slug

### GET /api/v1/me/journey_variants

The version of each journey the baker chose last, by journey slug.

Response:

```
200 {"success": true, "data": {"sourdough-bread": "overnight"}}
```

### POST /api/v1/me/journey_variants

Keeps the version of a journey the baker chose, so loafy.ai and every device open it the same way. The latest choice wins.

Parameters:

- `journey_slug` (body, string, required)
- `variant` (body, string, required): One of the journey's own versions. Today `sourdough-bread` has `day` and `overnight`, `sandwich-bread` has `wheat` and `rye`.

Example body:

```json
{"journey_slug": "sourdough-bread", "variant": "overnight"}
```

Response:

```
200 {"success": true, "data": JourneyVariant}
```

Errors:

- 404 not_found: no journey has that slug
- 422 invalid_variant: the journey has no such version

### GET /api/v1/me/guide

The first-steps guide: the welcome question and four steps (a journey, a starter, a bake, a question to Ask Loafy), each ticked by what the baker really did. Reading it never ends it.

Response:

```
200 {"success": true, "data": Guide}
```

The guide is for accounts younger than 30 days and for bakers without a counted bake, and for 30 days after the welcome question is answered again from Settings. Hiding or finishing it on loafy.ai or in an app ends it everywhere. A step is done by any journey opened or finished, any starter, any counted bake, and any Ask Loafy question answered or stopped mid-answer.

### POST /api/v1/me/guide/hide

"Hide this guide": ends the guide on every device. Safe to repeat: `ended` is true only for the call that ended it.

Response:

```
200 {"success": true, "data": Guide, "ended": true}
```

### POST /api/v1/me/guide/finish

Says the celebration was shown, so loafy.ai does not show it again, and ends the guide. Accepted whenever the guide is on, not only at four of four. Safe to repeat: `ended` is true only for the call that ended it.

Response:

```
200 {"success": true, "data": Guide, "ended": true}
```

### POST /api/v1/me/guide/intent

The answer to the welcome question "What do you want to do first?". Each call keeps a new answer; the latest wins.

Parameters:

- `intent` (body, string, required): `bake`, `starter`, `ask`, `check`, `learn` or `skip`.
- `source` (body, string): `settings` when the question was asked again from Settings: any answer but `skip` opens the guide again for 30 days.
- `time_zone` (body, string): The device's IANA zone. Kept while the account has no zone of its own.

Example body:

```json
{"intent": "bake"}
```

Response:

```
200 {"success": true, "data": Guide}
```

Errors:

- 422 invalid_intent: not one of the six answers

## Challenges and badges

Loafy's challenges (one bake everyone makes by a date, entered with a photo) and the baker's badges: every badge with what it takes, the new ones still to celebrate, and the pictures to share one. Every text comes ready to show, in the account's language.

#### ChallengeList

- `on_home`, boolean: False once the baker switched challenge cards off on Home. The lists below are the same either way.
- `challenges`, array of Challenge: Every running challenge, the hidden ones included.
- `past`, array of PastChallenge: Every challenge whose entries have closed, the latest last day first.
- `words`, object: Texts around the cards and the list: `hidden`, `hidden_listed`, `undo`, `title`, `on_home`, `on_home_hint`, `synced`, `running`, `on_your_home`, `hidden_from_home`, `show_again`, `hide`, `none`, `step_done`, `step_now`, `step_later`, `list_title`, `list_subtitle`, `past`, `past_none`.

#### Challenge

- `slug`, string: The challenge's name in paths, for example `stollen`.
- `state`, string: `invite` (not in), `joined` (in, nothing to submit), `ready` (in, and `offered_bake` can be entered) or `entered` (a bake is submitted).
- `hidden`, boolean: The baker took it off Home, on every device.
- `title`, string
- `heading`, string
- `lead`, string
- `prize`, string or null: What one baker wins.
- `terms`, string or null: The short terms.
- `bake_name`, string: The bake, as a sentence names it: `Stollen`.
- `photo_alt`, string: The photo's description.
- `recipe_url`, string: The recipe the challenge is about.
- `photo_url`, string
- `drawing_url`, string: An SVG drawing of the bake's kind.
- `host_photo_url`, string: The host's photo.
- `challenge_url`, string: The challenge's page on loafy.ai.
- `bakes_from`, string (date): The first day an entered bake may be baked on, YYYY-MM-DD.
- `last_day`, string (date): The last day to enter, YYYY-MM-DD.
- `closes_at`, string (ISO 8601): When entries close: once the last day has ended everywhere, at noon UTC the day after.
- `days_left`, integer: The last day included. At least 1 while entries are open.
- `bakers_count`, integer or null: Bakers in with a confirmed address, from 25 on. Null below that.
- `entry`, ChallengeEntry or null: Null until the baker joins.
- `offered_bake`, OfferedBake or null: The newest bake the challenge would take, while the baker is in and has submitted none.
- `wall_count`, integer: Entries on the wall now.
- `enterable_bake_ids`, array of strings (UUID): The baker's bakes of the challenge's kind it would take now, newest first, 20 at most. Empty once one is submitted.
- `steps`, array of objects: Empty for `invite`, else three: `label`, `state` (`done`, `now` or `later`) and `hint` (string or null).
- `actions`, array of objects: The card's buttons in order: `action` (`join`, `details`, `log`, `recipe`, `submit` or `entry`), `label` and `style` (`primary` for the main one, `secondary`).
- `log_prefill`, object: What a new bake for this challenge starts with, for example `{"bake_type": "stollen"}`.
- `words`, object: The card's lines, ready to show: `live`, `days_left`, `by_line`, `you_are_in`, `hide`, `bakers`, `closes_on`, `recipe`, `recipe_hint`, `terms_title`, `fine_print`, `row_status`, `row_next`, `enter_title`, `submit`, `wall`, `wall_empty`. A line with nothing to say is left out.

#### ChallengeEntry

- `joined_at`, string (ISO 8601)
- `status`, string: `none` (nothing submitted), `waiting` (to be looked at), `shown` (on the wall), `declined`, `off` (the baker took the bake out of the gallery) or `photo` (the bake has no photo any more).
- `bake_log_id`, string (UUID) or null: The submitted bake.
- `submitted_at`, string (ISO 8601) or null

#### OfferedBake

- `id`, string (UUID): The bake's id, for POST …/entry.
- `name`, string
- `baked_on`, string (date): YYYY-MM-DD.
- `baked_on_label`, string: The same day, written out.
- `photo`, object or null: The photo the wall would show: `id`, `checksum`, `url` (up to 1600 px) and `thumb_url` (400 px square).

#### PastChallenge

- `slug`, string
- `state`, string: `closed`.
- `title`, string: As in Challenge, and so are heading, lead, prize, terms, photo_alt, photo_url, drawing_url, challenge_url, bakes_from, last_day and closes_at.
- `wall_count`, integer: Entries on the wall.
- `entry`, ChallengeEntry or null: Null when the baker was not in.
- `words`, object: `row_status`, `row_entry` (only for a baker who was in), `closed`, `wall`, `wall_empty`, `by_line`, `terms_title`, `fine_print`.

#### BadgeGuide

- `title`, string
- `lead`, string
- `earned`, integer: Badges the baker holds.
- `total`, integer: Badges there are.
- `summary`, string: "3 of 34 earned".
- `unclaimed`, string or null: A line about the badges no baker holds yet, null when there are none.
- `filters`, object: Labels `all`, `to_earn`, `earned`.
- `empty`, object: What to show when a filter is empty: `to_earn`, `earned`.
- `groups`, array of BadgeGroup

#### BadgeGroup

- `key`, string: `milestones`, `consistency`, `learning`, `variety`, `engagement`, `quality`, `tools`, `journeys` or `community`.
- `name`, string
- `note`, string or null: What counts towards the group's badges.
- `count`, string: "3 of 7".
- `badges`, array of Badge

#### Badge

- `key`, string: For example `ten_bakes`.
- `name`, string
- `mascot`, string: The file name of its dough mascot.
- `emoji`, string
- `how`, string: Exactly what it takes: "Log 10 bakes."
- `earned`, boolean
- `earned_line`, string or null: "Earned October 5, 2026", null while not earned.
- `earned_on`, string (date) or null
- `progress`, BadgeProgress or null: For a badge not yet earned that counts towards a number.
- `holders`, object or null: How many bakers hold it: `style` (`rare`, `nobody`, `everyone` or `plain`) and `text`. Null until the counts exist.

#### BadgeProgress

- `current`, integer
- `target`, integer
- `share`, number: 0 to 1.
- `label`, string: "8 of 10".

#### BadgeScene

- `title`, string or null: "2 new achievements". Null when there is nothing to celebrate.
- `lead`, string or null: A line under the title in the calm tone, or for a comeback (a tough-bake badge earned with a good bake). Else null.
- `tone`, string or null: `cheer`, or `calm` within two days of a bake rated two stars or less. Null when there is nothing to celebrate.
- `short`, boolean: One small badge alone.
- `badges`, array of SceneBadge: In the order to show them, the rarest last. Empty when there is nothing to celebrate.
- `next`, NextBadge or null: The badge the baker is closest to. Null when there is nothing to celebrate.

#### SceneBadge

- `key`, string
- `name`, string
- `description`, string
- `how`, string
- `mascot`, string
- `emoji`, string
- `category`, string: The BadgeGroup key.
- `tier`, string: `big` or `small`.
- `rare`, boolean: Fewer than one in ten bakers hold it.
- `rise`, boolean: False for a badge shown as a small chip, from four new badges on.
- `holders`, object or null: As in Badge.

#### NextBadge

- `key`, string
- `name`, string
- `mascot`, string
- `emoji`, string
- `how`, string
- `line`, string: "Next up: Back for More".
- `progress`, BadgeProgress

#### AchievementShare

- `key`, string
- `name`, string
- `mascot`, string
- `emoji`, string
- `title`, string: The share screen's title.
- `caption`, string: The line to send with the picture, followed by referral_url, where the target takes text.
- `referral_url`, string: The baker's invite link.
- `versions`, array of objects: The pictures: `id` (`loaf`, `medal` or `bake`), `label` and `images` with a `story` and a `square` PNG address. Only `medal` unless the bake that earned it has a photo.
- `formats`, array of objects: `id` (`story` or `square`) and `label`.
- `targets`, object: A label for each target: `instagram`, `whatsapp`, `messages`, `save`, `copy_link`, `more`, `download`.
- `words`, object: `share`, `copied`, `saved`, `failed`, `close`.

### GET /api/v1/me/challenges

The running challenges with where the baker stands in each, and the past ones.

Response:

```
200 {"success": true, "data": ChallengeList}
```

### PATCH /api/v1/me/challenges

Switches challenge cards on Home on or off, for every challenge. Safe to repeat.

Parameters:

- `on_home` (body, boolean, required)

Example body:

```json
{"on_home": false}
```

Response:

```
200 {"success": true, "data": ChallengeList}
```

Errors:

- 422 invalid_on_home: not true or false

### POST /api/v1/me/challenges/:slug/join

Joins a challenge ("I'm in"). Safe to repeat: the baker joins once.

Parameters:

- `slug` (path, string, required)
- `via` (body, string): Where the baker joined, kept with the entry: letters, digits, `_`, `.` and `-`, 64 characters at most. Anything else is ignored.

Response:

```
200 {"success": true, "data": ChallengeList}
```

Errors:

- 404 challenge_not_found
- 422 challenge_closed: entries have closed

### POST /api/v1/me/challenges/:slug/hide

Takes a challenge's card off Home on every device. The baker stays in. Safe to repeat.

Response:

```
200 {"success": true, "data": ChallengeList}
```

Errors:

- 404 challenge_not_found

### DELETE /api/v1/me/challenges/:slug/hide

Puts the card back on Home. Safe to repeat.

Response:

```
200 {"success": true, "data": ChallengeList}
```

Errors:

- 404 challenge_not_found

### POST /api/v1/me/challenges/:slug/entry

Enters one of the baker's bakes, joining first if needed. A second entry takes the place of the first. The bake goes into the gallery and shows on the challenge's wall once someone at Loafy has looked at it.

Parameters:

- `bake_log_id` (body, string (UUID), required): A bake of the challenge's kind (or Other), baked since `bakes_from`, made rather than only planned, with a photo.
- `via` (body, string): As for join.

Example body:

```json
{"bake_log_id": "0a52aa46-555e-4493-91b6-f616a0a7d609"}
```

Response:

```
200 {"success": true, "data": ChallengeList}
```

Errors:

- 403 email_unconfirmed: the account's address is not confirmed yet
- 404 bake_not_found: no bake of the baker has that id
- 422 not_accepted: the challenge does not take this bake, the message says why in the baker's words
- 404 challenge_not_found, 422 challenge_closed

### GET /api/v1/me/badges

Every badge in its group, exactly what it takes, how far the baker has come and how many bakers hold it.

Response:

```
200 {"success": true, "data": BadgeGuide}
```

### GET /api/v1/me/badges/fresh

The badges the baker has earned and not celebrated yet, as one scene to show. Reading changes nothing.

Response:

```
200 {"success": true, "data": BadgeScene}
```

### POST /api/v1/me/badges/celebrated

Marks badges as celebrated, so no device shows them as new again. Send it before showing them, and show only the keys `claimed` lists: a key missing there was celebrated elsewhere first.

Parameters:

- `keys` (body, array of strings, required): Badge keys. Unknown keys are ignored. A key not earned yet is kept and never shows as new.
- `surface` (body, string): `ios` or `android`; anything else is filed as `app`.
- `claim` (body, string (UUID)): Your own id for this claim. A retry with the same id gets back what the first try claimed. Anything that is not a UUID is ignored.

Example body:

```json
{"keys": ["first_bake", "perfect_bake"], "claim": "5b0e7c2a-8f4d-4a61-9c3e-2d7b1f6a0e94"}
```

Response:

```
200 {"success": true, "data": {"claimed": ["first_bake"], "celebrated": ["first_bake", "perfect_bake"]}}
```

`claimed` is what this call recorded, plus what earlier calls with the same `claim` recorded. `celebrated` is every badge celebrated so far.

### GET /api/v1/me/achievements/:key/share

The pictures and the words to share a badge the baker holds. The picture addresses are signed and load without the key.

Parameters:

- `key` (path, string, required): A badge key, for example `ten_bakes`.

Response:

```
200 {"success": true, "data": AchievementShare}
```

Errors:

- 404 not_earned: the baker does not hold that badge, or no badge has that key

### POST /api/v1/me/achievements/:key/share_events

Counts one completed share of a badge. Every call counts once more.

Parameters:

- `key` (path, string, required)
- `version` (body, string): `loaf`, `medal` or `bake`.
- `card_format` (body, string): `story` or `square`.
- `target` (body, string): `instagram`, `whatsapp`, `messages`, `save`, `copy_link`, `more` or `download`. An unknown value of any of the three is left out, not refused.

Example body:

```json
{"version": "medal", "card_format": "story", "target": "instagram"}
```

Response:

```
201 {"success": true}
```

Errors:

- 404 not_earned: the baker does not hold that badge, or no badge has that key

## Gallery and baker pages

The Loafy gallery of bakes their bakers chose to show, the bakers' board, and each baker's public page, for a client that draws them itself. Every text comes ready in the reader's language, with the same words loafy.ai uses: show it as it is.

#### GalleryCard

- `id`, string (UUID): The bake's id.
- `share_token`, string: The token of the bake's public page. GET /api/v1/me/gallery/:share_token opens it.
- `bake_type`, string: One of sourdough_bread, pizza, focaccia, bagels, brioche, croissant, baguettes, loaf_pan_bread, bread_rolls, pan_bread, tortilla, naan, flatbread, panettone, stollen, other.
- `emoji`, string: The bake type's emoji.
- `title`, string: The name its baker gave it, else the bake type in the reader's language.
- `baker`, string or null: The baker's public name: their username, else their first name.
- `hydration_percent`, integer or null
- `hours`, integer or null: Whole hours from the first step to the oven. Null under an hour or without times.
- `photo_url`, string or null: The featured photo, else the first, 600 x 600 px, cropped.
- `page_url`, string or null: The bake's public page on loafy.ai.
- `baker_url`, string or null: The baker's public page, once they switched it on. Null before.
- `gallery_status`, string: waiting, shown or declined. Always shown in the public gallery.

#### PublicBake

- `id`, string (UUID): The bake's id.
- `share_token`, string
- `page_url`, string: The bake's public page, the link to share.
- `title`, string: As on a GalleryCard.
- `emoji`, string: The bake type's emoji.
- `rating_emoji`, string or null: The baker's rating of this bake, as an emoji.
- `caption`, string or null: The baker's caption.
- `date`, string: The day it was baked, written out in the reader's language.
- `own`, boolean: True for the reader's own bake.
- `photos`, array of objects: Every photo, the featured one first: `url` up to 1200 px and `thumb_url` 400 x 400 px.
- `cards`, array of objects: For a bake that reads as a recipe, its recipe card and flowchart as pictures: `key` (recipe or flowchart), `label`, `photo_label` (the name of the photos' tab) and `image_url`. Empty otherwise.
- `baker`, object or null: `name`, `label` (the by-line), `avatar_url`, and while their page is open `baker_slug`, `baker_url` and `numbers` (bakes and achievements in one line, only while shown). Null for a baker without a public name.
- `starter`, string or null: The starter it rose with, by name and age, in one line.
- `recipe`, object or null: For a bake with weights: `tiles` (value and label each: dough weight, duration, hydration, or servings and time), `ingredients_heading`, `ingredients` (`name`, `grams` as written such as 500 g, `percent` or null), `method_heading`, `steps` (`time` or null, `text`) and `bake_along` (`label`, `url` to bake it step by step on loafy.ai).
- `ingredients`, array of objects: Without a recipe: the flours and add-ins as logged, each `name` and `grams` (text or null). Empty when there is a recipe.
- `method`, object or null: Without a recipe: `heading` and `steps` (`time`, `text`). Null when the bake has no steps to show.
- `details`, object or null: The baking numbers: `label`, `open` (true for a bake in the gallery, which shows them unfolded) and `items` (`label`, `value`, both text).
- `more`, object or null: Up to three more of the baker's gallery bakes, while their page is open: `heading`, `link` and `bakes` (`share_token`, `title`, `photo_url` 300 px).
- `gallery`, object or null: For a bake in the gallery: `position` (such as 1 of 39) and `newer` and `older` (`share_token`, `label`), each null at an end.
- `board_place`, BoardPlace or null: For a bake in the gallery: its baker's place among this month's top ten.
- `report`, object or null: For someone else's bake in the gallery, the Report button's texts: `button`, `confirm` and `done`.

#### BakerPage

- `baker_slug`, string: The page's address. GET /api/v1/me/bakers/:slug takes it.
- `baker_url`, string: The page on loafy.ai, the link to share.
- `name`, string: The public name: the username, else the first name, else a word for a baker.
- `avatar_url`, string or null: 300 x 300 px.
- `lines`, array of strings: The header: the year they began baking (while shown), then the year they joined Loafy. One line when both years are the same.
- `own`, boolean: True on the reader's own page.
- `owner`, BakerPageOwner or null: Only on the reader's own page.
- `numbers`, array of objects: Bakes, achievements and bakes in the gallery, each `value` and `label`. Empty while achievements are hidden.
- `kinds`, object or null: What they bake most, from two kinds on: `label` and `items` (`bake_type`, `emoji`, `name`, `count`).
- `rank`, object or null: The level card: `key`, `name`, `mascot`, `emoji`, `level` of `levels`, `level_label`, `line` (what it took), `rare` (or null), `progress` toward the next level from 0 to 1, and `next` (null at the top level).
- `board_place`, BoardPlace or null: Their place among this month's top ten bakers.
- `badges`, object or null: `heading`, `count`, the texts `show`, `hide`, `rare_heading`, `rare_sub` and `also_heading`, then `featured` (up to three rare ones, for cards) and `others`, both arrays of PageBadge.
- `activity`, object or null: The baking calendar: `title`, `years` with bakes, `streak` (text or null), `streak_live`, `less`, `more`, `months` (short month names) and `days` (`date`, `count` of bakes that day).
- `gallery`, object: `heading`, `empty` (the text for a page without bakes) and `bakes`: GalleryCards with a `date` each, newest first.

#### PageBadge

- `key`, string: The achievement's key.
- `name`, string
- `mascot`, string: The name of its mascot picture.
- `emoji`, string: For a client without that picture.
- `line`, string: What the baker did for it.
- `rare`, string or null: How few bakers hold it, for a rare one.
- `earned`, string or null: The day it was earned, as a line of text.
- `earned_on`, string (date) or null: The same day, YYYY-MM-DD.

#### BakerPageOwner

- `public`, boolean: The page is switched on.
- `open`, boolean: Others can open it: public and with a bake in the gallery.
- `note`, string: Says whether others see the page yet.
- `title`, string: The settings' heading.
- `lead`, string
- `fine_print`, string
- `switches`, array of objects: public, badges and since in that order, each `key`, `title`, `hint` and `on`.
- `username`, object: The username field: `title`, `hint`, `value` (or null), `shown` (a line while the username shows, else null), `save` and `saved`.

#### BakerBoard

- `period`, string: month, last_month or all.
- `title`, string
- `intro`, string: What the score counts.
- `countdown`, string or null: The days left, on this month's board only.
- `periods`, array of objects: The three periods, each `key`, `label` and `selected`.
- `you`, BoardYou or null: The reader's own place. Null for Loafy's team accounts.
- `rows`, array of BoardRow: Places 1 to 10, nobody after them.
- `rest`, null: Always null.
- `empty`, string or null: The text for an empty board, this month only.
- `last_month_leaders`, string or null: On an empty month: last month's top three, as one line.
- `rules`, string: How the board counts.
- `see_board`, string: A link text to the whole board.

#### BoardRow

- `rank`, integer: 1 to 10, one baker per place.
- `medal`, string or null: gold, silver or bronze for places 1 to 3.
- `name`, string
- `baker_slug`, string: Opens their page with GET /api/v1/me/bakers/:slug.
- `avatar_url`, string or null: Their picture, else their newest loaf in the gallery, 300 px.
- `level`, string or null: Their level and its name, as one line.
- `score`, integer: Baking days in the month, or weeks with a bake for all time.
- `score_text`, string: The score in words.
- `own`, boolean: The reader's own row.
- `photos`, array of objects: Places 1 to 3: up to three of their gallery bakes from the period, each `share_token`, `title`, `photo_url`. Empty below.

#### BoardYou

- `rank`, integer or null: Only within the top ten.
- `score`, integer
- `line`, string: The reader's row in one line.
- `place_text`, string or null: This month only: the place and days, or how far the top ten is.
- `hint`, string or null: This month, for a reader who can be on the board: the next goal.
- `step`, object or null: For a reader who cannot be on the board yet, the nearest step: `kind`, `text`, `button` (or null), `bake_id` (or null) and `photo_url` (or null). See the notes of GET /api/v1/me/gallery/bakers.

#### BoardPlace

- `rank`, integer: 1 to 10.
- `score`, integer: Baking days this month.
- `text`, string: The place in one line.
- `score_text`, string: The days in words.

### GET /api/v1/me/gallery

The bakes in the public gallery, the newest first, 24 a page. Narrow it to one bake type, to the baker's own bakes that asked for the gallery, or to a challenge's wall.

Parameters:

- `page` (query, integer): 1 or more, default 1.
- `type` (query, string): A bake type, such as pizza. Anything else is ignored.
- `mine` (query, string): 1 for the baker's own bakes that asked for the gallery: waiting, shown and declined ones, the latest change first.
- `challenge` (query, string): A challenge's slug: its entries that are in the gallery, the newest entry first. type and mine are ignored with it.

Response:

```
200 {"success": true, "data": {"bakes": [GalleryCard], "next_page": 2, "types": ["sourdough_bread", "pizza"]}}
```

Errors:

- 404 challenge_not_found: no challenge has that slug

`next_page` is the next page's number, or null on the last page. `types` lists the bake types the whole gallery holds, the most common first, for filter chips; it does not change with the filters. Under `mine` a bake can have no photo yet, so `photo_url` is null.

### GET /api/v1/me/gallery/bakers

The bakers' board: bakers ranked by the days they baked and logged a loaf with a photo, this month or last month, or by the weeks with a bake over all time. Places 1 to 10, and the reader's own place or their next step onto the board.

Parameters:

- `period` (query, string): month (default), last_month or all. Anything else reads as month.

Response:

```
200 {"success": true, "data": BakerBoard}
```

On the board are bakers whose page is public, shows achievements, and has a bake in the gallery. A day counts once, however many loaves. `you.step` appears when the reader cannot be on the board yet; its `kind` says what the button does: page_off and badges_hidden mean a baker page switch (PATCH /api/v1/me/baker_page), offer means asking for the bake `bake_id` in the gallery (PATCH /api/v1/me/bake_logs/:id with `bake_log.show_in_gallery` true), log means logging a new bake, and waiting has no button.

### GET /api/v1/me/gallery/:share_token

A bake's public page as loafy.ai/bake/<share_token> shows it: photos, recipe or method, the numbers, its baker and more of their bakes. Any bake its link opens, in the gallery or not. The baker's notes and the ratings of their other bakes never appear.

Parameters:

- `share_token` (path, string, required): From a GalleryCard, a board row's photos or a bake's share link.

Response:

```
200 {"success": true, "data": PublicBake}
```

Errors:

- 404 not_found: no bake has that token

Temperatures come in the baker's own unit with the other one after it, such as 450°F (232°C).

### POST /api/v1/me/gallery/:share_token/report

Reports a bake, as the Report button on its page does: a bake in the gallery leaves it until it has been checked again. Reporting a bake that is not shown, or the reader's own, changes nothing and answers the same. Up to 5 reports an hour per baker.

Parameters:

- `share_token` (path, string, required)

Response:

```
200 {"success": true, "data": {"message": "Thanks. The bake is hidden until it has been checked."}}
```

Errors:

- 404 not_found: no bake has that token
- 429 too_many_reports: more than 5 in an hour

### GET /api/v1/me/bakers/:slug

A baker's public page. It opens while its baker has it public and has a bake in the gallery; the reader's own page always opens.

Parameters:

- `slug` (path, string, required): A `baker_slug`, or the last part of a `baker_url`. An older address of the same baker, or their code alone, works too.

Response:

```
200 {"success": true, "data": BakerPage}
```

Errors:

- 404 not_found: no such baker, or their page is not open

What is worked out from all their bakes, private ones too (numbers, kinds, rank, badges, activity), is there only while the baker shows their achievements: otherwise `numbers` is empty and the rest are null. Ratings never appear; the calendar counts bakes per day.

### GET /api/v1/me/baker_page

The baker's own page as others see it, plus `owner`: its switches, its username and whether others can open it yet.

Response:

```
200 {"success": true, "data": BakerPage}
```

### PATCH /api/v1/me/baker_page

Flips the page's switches or sets its username. Send only what changes. Answers with the page as it is now.

Parameters:

- `baker_page.public` (body, boolean): Shows the page to others. Once the baker sets it, the gallery never switches the page on by itself.
- `baker_page.badges` (body, boolean): Shows achievements and numbers, worked out from all bakes, private ones too.
- `baker_page.since` (body, boolean): Shows the year of the first logged bake.
- `baker_page.username` (body, string): 3 to 20 characters: letters a to z, digits, dots and underscores, with at least one letter. Shows at once. An empty string goes back to the first name.

Example body:

```json
{"baker_page": {"badges": false}}
```

Response:

```
200 {"success": true, "data": BakerPage}
```

Errors:

- 422 invalid_switch: no known field, or a switch that is not true or false (null and an empty string are neither)
- 422 invalid_username: the name breaks a rule or is taken; the message says why in the baker's language, and nothing sent with it changes

A switch also takes "true", "false", "1", "0", 1 or 0. Names that would pass for Loafy's own are refused as taken. With a JSON body the `baker_page` wrapper may be left out.

## Fermentation sensor

The Loafy jar sensor measures the pressure and temperature in a sealed jar of starter or dough. A run (a fermentation session) groups a device's readings from a start to a stop and works out when the starter is ready and how much of it to use. The sensor and run endpoints answer without a `data` wrapper; their errors are the usual `{"success": false, "error": {"code", "message"}}`.

#### Device

- `id`, string (UUID): The device's id.
- `mac_address`, string: From the X-Device-Mac header; unknown when a device sent none.
- `name`, string or null
- `firmware_version`, string or null
- `chip_model`, string or null
- `chip_revision`, string or null
- `idf_version`, string or null
- `sensor`, string or null
- `last_rssi`, integer or null: Wi-Fi signal, dBm.
- `last_free_heap`, integer or null: Bytes.
- `last_uptime_ms`, integer or null
- `reset_reason`, string or null
- `last_ip`, string or null
- `last_seen_at`, string (ISO 8601) or null: Its latest upload.
- `reading_count`, integer: Readings stored for it.

#### SensorReading

- `pressure_pa`, number: Pa.
- `temperature_c`, number: °C.
- `recorded_at`, string (ISO 8601): When it was measured.
- `device_timestamp_ms`, integer or null: The device's own timestamp, as sent.
- `sequence`, integer or null: The device's counter, as sent.

#### FermentationSession

- `id`, string (UUID): The run's id.
- `device_id`, string (UUID)
- `name`, string
- `notes`, string or null
- `starter_id`, string (UUID) or null: The baker's starter it measures.
- `starter_name`, string or null
- `started_at`, string (ISO 8601)
- `ended_at`, string (ISO 8601) or null: Null while it runs.
- `active`, boolean: True while it runs.
- `reading_count`, integer
- `last_reading_at`, string (ISO 8601) or null
- `room_regime`, string or null: cool or warm: how warm the kitchen is, which picks the dose table.
- `room_regime_source`, string or null: stated (the baker said so) or weather (suggested from the weather outside).
- `recipe`, object: `flour_grams`, `water_grams`, `salt_grams`, `starter_grams`, `total_dough_grams` and `hydration_percent` (the starter counted as half flour, half water), each a number or null.
- `analysis`, SessionAnalysis

#### SessionAnalysis

- `started_at`, string (ISO 8601)
- `ended_at`, string (ISO 8601) or null
- `max_pressure_pa`, number or null: The highest pressure, after the first hour.
- `max_pressure_kpa`, number or null: The same in kPa.
- `max_pressure_per_flour_kpa_g`, number or null: That per gram of flour. Null without flour.
- `peak_rate_pa_per_s`, number or null: The fastest rise, Pa per second.
- `peak_rate_at`, string (ISO 8601) or null: When it rose fastest.
- `peak_rate_kpa_per_h`, number or null: The fastest rise over 5 minutes, kPa per hour.
- `readiness`, object: `status` and `label`: green (ready to use now), red (not ready) or finished (the run has ended).
- `ready_at`, string (ISO 8601) or null: When the starter first became ready.
- `ready_after_seconds`, integer or null: Seconds from the start to ready.
- `avg_temperature_c`, number or null

#### SessionReport

- `points`, array of objects: Up to about 300 averaged points over the run, each `t` (epoch seconds), `value_pa`, `temperature_c`, `dpdt_pa_s` and `dpdt_smoothed_pa_s` (the rate of change, raw and smoothed).
- `guidance`, array of GuidanceZone: The starter's stages in order. Empty until the readings show a ferment.
- `feed_at`, integer or null: When to feed the spent starter, epoch seconds.
- `temperature`, object or null: What set the doses: `avg_c`, `start_c`, `source` (stated, weather, sensor or unknown), `sensor_c`, `regime` (cool or warm), `warm_above_c` and `doses` (percent of flour for peak, maturing and decay). Null until the readings show a ferment.
- `seal`, object: Whether the jar holds pressure: `checked` false with a `reason`, or `checked` true with `sealed`, `temperature_delta_c`, `expected_thermal_pa`, `observed_pa` and `ratio`.

#### GuidanceZone

- `phase`, string: getting_ready, peak, maturing or decay.
- `label`, string
- `recommendation`, string: What to do, with the dose.
- `dose_base_percent`, number or null: Starter to use, percent of flour. Null while getting ready.
- `dose_percent`, number or null: The same.
- `starts_at`, integer: Epoch seconds.
- `ends_at`, integer or null: Null for the current stage.
- `color`, string: A hex color for the stage.

#### RoomHint

- `outdoor_c`, number: The temperature outside, °C.
- `regime`, string: warm above 18 °C outside, else cool.
- `place`, string or null: Where the weather was read.

### POST /api/v1/me/sensor_readings

Sends readings from the jar sensor, one reading or an array of them. The device is the one in the X-Device-Mac header, created on its first upload. Readings join the device's open run. Safe to retry: a reading the device already sent for the same moment is skipped.

Parameters:

- `pressure` (body, number, required): Per reading, Pa.
- `temperature` (body, number, required): Per reading, °C.
- `timestamp_ms` (body, integer): When it was measured, Unix epoch milliseconds. Without it, the moment it arrives.
- `sequence` (body, integer): The device's counter, kept as sent.

Example body:

```json
[{"pressure": 101325.0, "temperature": 22.5, "timestamp_ms": 1781000000000}]
```

Response:

```
202 {"success": true, "accepted": 1, "inserted": 1, "duplicates": 0, "rejected": 0}
```

Errors:

- 400 bad_json: the body is not JSON, or neither an object nor an array

`accepted` counts the readings with both values, `inserted` the new ones, `duplicates` those already stored for that device and moment, `rejected` those without pressure or temperature. Without X-Device-Mac the readings go to a device called unknown. Other headers describe the device and are kept on it: X-Device-Name, X-Device-Firmware, X-Device-Chip, X-Device-Chip-Rev, X-Device-Idf, X-Device-Sensor, X-Device-Reset-Reason, X-Device-Rssi, X-Device-Free-Heap, X-Device-Uptime-Ms, X-Device-Battery-Mv, X-Device-Battery-Pin-Mv, X-Device-Battery-Pct, X-Device-Ota-Result, X-Device-Ota-Target and X-Device-Ota-Error. A header left out keeps the value stored before.

### GET /api/v1/me/sensor_readings

The latest readings from all the baker's devices, the newest first, and the devices themselves. Handy to check that a device is sending.

Parameters:

- `limit` (query, integer): 1 to 500, default 50.

Response:

```
200 {"success": true, "devices": [Device], "readings": [SensorReading], "count": 50}
```

A reading does not name its device: with several devices, their readings come mixed.

### GET /api/v1/me/fermentation_sessions

The baker's runs on all their devices, the newest first, at most 100, each with its headline numbers and readiness.

Response:

```
200 {"success": true, "sessions": [FermentationSession], "count": 2}
```

### POST /api/v1/me/fermentation_sessions

Starts a run on a device: ends the device's open run, opens this one and claims the readings already stored from `started_at` on. A device has one open run at a time. Each call starts a new run.

Parameters:

- `name` (body, string): Default: Fermentation and the start time.
- `notes` (body, string)
- `device_mac` (body, string): The device by its MAC address. Default: the device seen last.
- `started_at` (body, string (ISO 8601)): Default now, and now when it cannot be read.
- `room` (body, string): cool or warm: how warm the kitchen is, which picks the dose table. Without it the server suggests one from the weather near the request's IP address.
- `starter_id` (body, string (UUID)): One of the baker's starters.
- `flour_grams` (body, number): 0 or more, like the three below.
- `water_grams` (body, number)
- `salt_grams` (body, number)
- `starter_grams` (body, number)

Example body:

```json
{"name": "Rye loaf", "room": "cool", "flour_grams": 500, "water_grams": 375, "salt_grams": 10, "starter_grams": 100}
```

Response:

```
201 {"success": true, "session": FermentationSession, "backfilled": 12}
```

Errors:

- 422 no_device: no device yet (it has to send readings first), or none with that device_mac
- 422 invalid: a field failed validation, such as a negative amount or another account's starter

The fields go at the top level of the body, without a wrapper. `backfilled` counts the stored readings the run claimed.

### GET /api/v1/me/fermentation_sessions/:id

One run with what its chart needs: the pressure series, the starter's stages with their doses, when to feed, what set the doses and whether the jar holds pressure. Poll it for a live view.

Parameters:

- `id` (path, string (UUID), required)
- `debug` (query, string): Any value adds `diagnostics` (the inputs and thresholds behind the verdict) and `stage_events` (every stage the run was announced to be in), for troubleshooting.

Response:

```
200 {"success": true, "session": FermentationSession, "report": SessionReport}
```

Errors:

- 404 not_found: no such run on the baker's devices

The first hour of a run is left out of every analysis: the jar settles after the lid closes.

### PATCH /api/v1/me/fermentation_sessions/:id

Changes a run's name, notes, starter, room or recipe. Only the fields sent change.

Parameters:

- `id` (path, string (UUID), required)
- `name` (body, string): A blank name is ignored.
- `notes` (body, string): Blank clears it.
- `starter_id` (body, string (UUID)): Blank clears it.
- `room` (body, string): cool or warm, saved as the baker's own answer. Anything else is ignored.
- `flour_grams` (body, number): Also water_grams, salt_grams and starter_grams. Blank clears one.

Example body:

```json
{"name": "Rye loaf, take two", "room": "warm"}
```

Response:

```
200 {"success": true, "session": FermentationSession}
```

Errors:

- 404 not_found: no such run on the baker's devices
- 422 invalid: a field failed validation, such as a negative amount or another account's starter

### PUT /api/v1/me/fermentation_sessions/:id

Same as PATCH.

### DELETE /api/v1/me/fermentation_sessions/:id

Deletes a run. Its readings stay, no longer part of a run.

Parameters:

- `id` (path, string (UUID), required)

Response:

```
200 {"success": true, "id": "<the run id>"}
```

Errors:

- 404 not_found: no such run on the baker's devices, also for one already deleted

### POST /api/v1/me/fermentation_sessions/:id/stop

Ends a run, now or at the moment named. Safe to repeat: a run that has ended stays as it was.

Parameters:

- `id` (path, string (UUID), required)
- `ended_at` (body, string (ISO 8601)): When the jar came off. Default now, and now when it cannot be read. After the start and not in the future.

Response:

```
200 {"success": true, "session": FermentationSession}
```

Errors:

- 404 not_found: no such run on the baker's devices
- 422 invalid: ended_at is before the start or in the future

### GET /api/v1/me/fermentation_sessions/room_hint

A suggested answer to "cool or warm kitchen?" for a new run, from the weather near the request's IP address.

Response:

```
200 {"success": true, "hint": RoomHint}, with hint null when the place or the weather is unknown
```

## Used by Loafy's apps and devices

The apps and the fermentation sensor call these for themselves. An agent has no use for them.

- `POST /api/v1/me/events`: What the app saw the baker do (a calculator used, a video played), sent in batches of up to 100.
- `POST /api/v1/me/diagnostics`: The iPhone's MetricKit crash and hang reports, stored without the account.
- `POST /api/v1/me/invite_events`: An invitation the app showed, or an invite link its share sheet handed on.
- `POST /api/v1/me/push_tokens`: Registers the phone's push token, so reminders and alerts reach it.
- `DELETE /api/v1/me/push_tokens/:token`: Stops pushes to this phone, on sign-out. Safe to repeat.
- `GET /api/v1/me/developer`: The developer screen of Loafy's team accounts. 404 for every other account.
- `GET /api/v1/me/developer/moment`: Any achievement as its moment, a preview that records nothing. Team accounts only, 404 otherwise.
- `POST /api/v1/me/developer/reset_achievements`: Makes every earned achievement play again. Team accounts only, 404 otherwise.
- `POST /api/v1/me/ask/messages/:id/copied`: Records that the baker copied an answer. The first time is kept; later calls change nothing.
- `POST /api/v1/me/ask/messages/:id/detach`: The app going to the background mid-answer: a push says when the answer is done. 202 with `detached: true` while it streams, 200 with `detached: false` once it has finished.
- `POST /api/v1/me/bake_logs/:bake_log_id/share_events`: Counts a card or link the app's share sheet handed on, in Loafy's share numbers.
- `GET /api/v1/me/firmware`: The jar's firmware manifest for the device in X-Device-Mac, with a download URL valid 15 minutes.
- `GET /api/v1/me/debug`: Whether the device in X-Device-Mac is in debug mode, with its latest telemetry. An unknown device reads as off.
- `POST /api/v1/me/debug`: Uploads a diagnostics snapshot, a JSON object of 64 KB at most, for the device in X-Device-Mac.
