openapi: 3.1.0
info:
  title: Vital data API
  version: "1.0.0"
  summary: Read-only access to one person's own Vital data.
  description: |
    The prose reference, with worked examples and the sync recipe, is README.md in this folder.
    Every endpoint is GET. The token decides whose data is returned; no parameter names a user.
servers:
  - url: https://api.govital.app/v1
security:
  - accessToken: []

paths:
  /:
    get:
      summary: Version and endpoint list
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      version: { type: string, const: v1 }
                      endpoints: { type: array, items: { type: string } }
  /me:
    get:
      summary: Display name, goals, units and households
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data: { $ref: "#/components/schemas/Me" }
        default: { $ref: "#/components/responses/Error" }
  /diary/days:
    get:
      summary: Days, each with its meals, their items and the items' ingredients
      description: Pages by day, so a day is never split across pages. Only days with at least one entry appear.
      parameters:
        - { $ref: "#/components/parameters/fromDate" }
        - { $ref: "#/components/parameters/toDate" }
        - { $ref: "#/components/parameters/ingredients" }
        - name: limit
          in: query
          description: Days per page.
          schema: { type: integer, minimum: 1, maximum: 31, default: 7 }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200": { $ref: "#/components/responses/DayPage" }
        default: { $ref: "#/components/responses/Error" }
  /diary/entries:
    get:
      summary: Diary items, flat, ordered by last change (sync endpoint)
      parameters:
        - { $ref: "#/components/parameters/fromDate" }
        - { $ref: "#/components/parameters/toDate" }
        - { $ref: "#/components/parameters/updatedAfter" }
        - { $ref: "#/components/parameters/ingredients" }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK. `next_cursor` is returned on the last page too; store it and pass it later to get changes.
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/DiaryItem" } } }
        default: { $ref: "#/components/responses/Error" }
  /exercise-entries:
    get:
      summary: Logged exercise and daily step calories (sync endpoint)
      parameters:
        - { $ref: "#/components/parameters/fromDate" }
        - { $ref: "#/components/parameters/toDate" }
        - { $ref: "#/components/parameters/updatedAfter" }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/ExerciseEntry" } } }
        default: { $ref: "#/components/responses/Error" }
  /deletions:
    get:
      summary: Ids of deleted diary and exercise entries (sync endpoint)
      description: Records are kept 90 days. An older `since` or cursor is answered 410 `cursor_expired`.
      parameters:
        - name: since
          in: query
          description: Deletions after this instant.
          schema: { type: string, format: date-time }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/Deletion" } } }
        default: { $ref: "#/components/responses/Error" }
  /measurements:
    get:
      summary: Steps, active energy, weigh-ins, sleep and resting heart rate read from Apple Health / Health Connect (sync endpoint)
      parameters:
        - name: kind
          in: query
          schema: { type: string, enum: [steps, active_energy, body_weight, sleep, resting_heart_rate] }
        - { $ref: "#/components/parameters/fromDate" }
        - { $ref: "#/components/parameters/toDate" }
        - { $ref: "#/components/parameters/updatedAfter" }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/Measurement" } } }
        default: { $ref: "#/components/responses/Error" }
  /workouts:
    get:
      summary: Strength sessions with their sets
      parameters:
        - { $ref: "#/components/parameters/fromTime" }
        - { $ref: "#/components/parameters/toTime" }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/Workout" } } }
        default: { $ref: "#/components/responses/Error" }
  /cardio-sessions:
    get:
      summary: Runs, walks, rides and other cardio
      parameters:
        - { $ref: "#/components/parameters/fromTime" }
        - { $ref: "#/components/parameters/toTime" }
        - name: series
          in: query
          description: true adds `route` (GPS points) and `heart_rate_series`, in the app's own format.
          schema: { type: boolean, default: false }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/CardioSession" } } }
        default: { $ref: "#/components/responses/Error" }
  /recipes:
    get:
      summary: Recipes the person owns, with ingredients, matched foods and sides
      parameters: [{ $ref: "#/components/parameters/limit" }, { $ref: "#/components/parameters/cursor" }]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/Recipe" } } }
        default: { $ref: "#/components/responses/Error" }
  /saved-meals:
    get:
      summary: Saved meals with their items
      parameters: [{ $ref: "#/components/parameters/limit" }, { $ref: "#/components/parameters/cursor" }]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/SavedMeal" } } }
        default: { $ref: "#/components/responses/Error" }
  /meal-plan/entries:
    get:
      summary: Planned items by day
      parameters:
        - { $ref: "#/components/parameters/fromDate" }
        - { $ref: "#/components/parameters/toDate" }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/MealPlanEntry" } } }
        default: { $ref: "#/components/responses/Error" }
  /meal-plan/templates:
    get:
      summary: Weekly templates (the person's and their household's) with entries
      parameters: [{ $ref: "#/components/parameters/limit" }, { $ref: "#/components/parameters/cursor" }]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/MealPlanTemplate" } } }
        default: { $ref: "#/components/responses/Error" }
  /habits:
    get:
      summary: Habits
      parameters: [{ $ref: "#/components/parameters/limit" }, { $ref: "#/components/parameters/cursor" }]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/Habit" } } }
        default: { $ref: "#/components/responses/Error" }
  /habit-logs:
    get:
      summary: Each habit's record for each day
      parameters:
        - { $ref: "#/components/parameters/fromDate" }
        - { $ref: "#/components/parameters/toDate" }
        - { $ref: "#/components/parameters/limit" }
        - { $ref: "#/components/parameters/cursor" }
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/HabitLog" } } }
        default: { $ref: "#/components/responses/Error" }
  /custom-foods:
    get:
      summary: Foods the person created or corrected
      parameters: [{ $ref: "#/components/parameters/limit" }, { $ref: "#/components/parameters/cursor" }]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/CustomFood" } } }
        default: { $ref: "#/components/responses/Error" }
  /pantry/items:
    get:
      summary: The household pantry, each item with its stock
      parameters: [{ $ref: "#/components/parameters/limit" }, { $ref: "#/components/parameters/cursor" }]
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - { $ref: "#/components/schemas/Page" }
                  - properties: { data: { type: array, items: { $ref: "#/components/schemas/PantryItem" } } }
        default: { $ref: "#/components/responses/Error" }
  /fitness/plan:
    get:
      summary: Saved workouts, weekly set targets, day assignments and weekly activities
      description: One object, in the app's own row shapes (user ids removed). Weights are kg; durations are minutes.
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      workout_templates: { type: array, items: { type: object } }
                      weekly_set_targets: { type: array, items: { type: object } }
                      day_assignments: { type: array, items: { type: object } }
                      weekly_activities: { type: array, items: { type: object } }
        default: { $ref: "#/components/responses/Error" }

components:
  securitySchemes:
    accessToken:
      type: http
      scheme: bearer
      bearerFormat: vital_pat_ followed by 64 hex characters
      description: Created in Vital, Settings, Connected Apps. Shown once.

  parameters:
    fromDate:
      name: from
      in: query
      description: First local calendar day, inclusive.
      schema: { type: string, format: date }
    toDate:
      name: to
      in: query
      description: Last local calendar day, inclusive.
      schema: { type: string, format: date }
    fromTime:
      name: from
      in: query
      description: Sessions that started at or after this instant. Must include a timezone.
      schema: { type: string, format: date-time }
    toTime:
      name: to
      in: query
      description: Sessions that started before this instant.
      schema: { type: string, format: date-time }
    updatedAfter:
      name: updated_after
      in: query
      description: Rows changed after this instant. An alternative to a stored cursor.
      schema: { type: string, format: date-time }
    ingredients:
      name: ingredients
      in: query
      description: false skips the recipe lookup; recipe items then have `ingredients` null.
      schema: { type: boolean, default: true }
    limit:
      name: limit
      in: query
      schema: { type: integer, minimum: 1, maximum: 500, default: 100 }
    cursor:
      name: cursor
      in: query
      description: The `next_cursor` of the previous page from this same endpoint.
      schema: { type: string }

  responses:
    Error:
      description: |
        400 invalid_parameter / invalid_cursor · 401 invalid_token / token_revoked / token_expired ·
        404 not_found · 405 method_not_allowed · 410 cursor_expired · 429 rate_limited (with Retry-After) ·
        500 internal_error
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code: { type: string }
                  message: { type: string }
    DayPage:
      description: OK
      content:
        application/json:
          schema:
            allOf:
              - { $ref: "#/components/schemas/Page" }
              - properties: { data: { type: array, items: { $ref: "#/components/schemas/Day" } } }

  schemas:
    Page:
      type: object
      properties:
        data: { type: array, items: {} }
        has_more: { type: boolean }
        next_cursor: { type: [string, "null"] }

    Nutrition:
      type: object
      description: Totals for the amount described. null = the source never reported it (not zero).
      properties:
        calories_kcal: { type: [number, "null"] }
        protein_g: { type: [number, "null"] }
        carbs_g: { type: [number, "null"] }
        fat_g: { type: [number, "null"] }
        sat_fat_g: { type: [number, "null"] }
        trans_fat_g: { type: [number, "null"] }
        cholesterol_mg: { type: [number, "null"] }
        sugar_g: { type: [number, "null"] }
        added_sugar_g: { type: [number, "null"] }
        fiber_g: { type: [number, "null"] }
        sodium_mg: { type: [number, "null"] }
        potassium_mg: { type: [number, "null"] }
        calcium_mg: { type: [number, "null"] }
        iron_mg: { type: [number, "null"] }
        magnesium_mg: { type: [number, "null"] }
        zinc_mg: { type: [number, "null"] }
        vitamin_a_mcg: { type: [number, "null"] }
        vitamin_c_mg: { type: [number, "null"] }
        vitamin_d_mcg: { type: [number, "null"] }
        vitamin_e_mg: { type: [number, "null"] }
        vitamin_k_mcg: { type: [number, "null"] }
        vitamin_b12_mcg: { type: [number, "null"] }
        folate_mcg: { type: [number, "null"] }

    Macros:
      type: object
      properties:
        calories_kcal: { type: [number, "null"] }
        protein_g: { type: [number, "null"] }
        carbs_g: { type: [number, "null"] }
        fat_g: { type: [number, "null"] }

    Serving:
      type: object
      description: "`quantity` of `label`; one `label` is `unit_quantity` `unit` when known."
      properties:
        quantity: { type: [number, "null"] }
        label: { type: [string, "null"], examples: ["1 cup"] }
        unit: { type: [string, "null"], description: "g, ml, serving or meal" }
        unit_quantity: { type: [number, "null"] }

    Source:
      type: object
      properties:
        type: { type: [string, "null"], description: "usda, off, custom, community, recipe, photo, quick_add, pantry_item, fatsecret" }
        id: { type: [string, "null"] }

    Day:
      type: object
      properties:
        local_date: { type: string, format: date }
        nutrition_total: { $ref: "#/components/schemas/Nutrition" }
        meals: { type: array, items: { $ref: "#/components/schemas/Meal" } }

    Meal:
      type: object
      description: The items sharing a local date and a meal type. Vital stores no meal record.
      properties:
        id: { type: string, examples: ["2026-10-03:dinner"] }
        local_date: { type: string, format: date }
        meal_type: { type: string, description: "breakfast, lunch, dinner or snacks" }
        name: { type: "null", description: Reserved. }
        notes: { type: "null", description: Reserved. }
        eaten_at: { type: [string, "null"], format: date-time, description: Reserved; null today. }
        timezone: { type: [string, "null"], description: "IANA zone the phone was in when the first item was logged; null before the phone reported one." }
        first_logged_at: { type: [string, "null"], format: date-time }
        last_logged_at: { type: [string, "null"], format: date-time }
        nutrition_total: { $ref: "#/components/schemas/Nutrition" }
        items: { type: array, items: { $ref: "#/components/schemas/DiaryItem" } }

    DiaryItem:
      type: object
      properties:
        id: { type: string, format: uuid }
        meal_id: { type: string }
        local_date: { type: string, format: date, description: The calendar day on the person's phone. Group by this. }
        meal_type: { type: string }
        logged_at: { type: string, format: date-time, description: When the entry was written (UTC). Not when it was eaten. }
        updated_at: { type: [string, "null"], format: date-time }
        eaten_at: { type: [string, "null"], format: date-time, description: Reserved; null today. }
        timezone: { type: [string, "null"] }
        name: { type: [string, "null"] }
        brand: { type: [string, "null"] }
        source:
          allOf:
            - { $ref: "#/components/schemas/Source" }
            - properties: { barcode: { type: [string, "null"] } }
        serving: { $ref: "#/components/schemas/Serving" }
        nutrition: { $ref: "#/components/schemas/Nutrition" }
        meal_plan_entry_id: { type: [string, "null"], format: uuid }
        has_photo: { type: boolean }
        photo_description: { type: [string, "null"] }
        recipe:
          type: [object, "null"]
          properties:
            id: { type: [string, "null"], format: uuid }
            title: { type: [string, "null"] }
            version_no: { type: [integer, "null"] }
            servings: { type: [number, "null"] }
            fraction_eaten: { type: [number, "null"], description: Servings logged divided by servings the recipe makes. }
            deleted: { type: [boolean, "null"] }
            counted_ingredients: { type: [integer, "null"] }
            total_ingredients: { type: [integer, "null"] }
        ingredients_basis:
          type: string
          enum: [none, photo_estimate, recipe_version_stamped, recipe_version_inferred_by_date, recipe_version_earliest_known, recipe_unavailable, not_requested]
        ingredients:
          type: [array, "null"]
          items:
            oneOf:
              - { $ref: "#/components/schemas/RecipeIngredientEaten" }
              - { $ref: "#/components/schemas/PhotoIngredient" }

    RecipeIngredientEaten:
      type: object
      properties:
        index: { type: integer }
        name: { type: [string, "null"] }
        recipe_line:
          type: [object, "null"]
          properties:
            name: { type: [string, "null"] }
            quantity_text: { type: [string, "null"], description: Free text, as the recipe was written. }
        matched_food: { oneOf: [{ $ref: "#/components/schemas/Source" }, { type: "null" }] }
        counted: { type: boolean, description: false = no matched food; adds nothing to the numbers. }
        weight_estimated: { type: boolean, description: true = the gram weight is an AI estimate. }
        amount_in_recipe: { oneOf: [{ $ref: "#/components/schemas/Serving" }, { type: "null" }], description: In the whole recipe. }
        nutrition: { oneOf: [{ $ref: "#/components/schemas/Nutrition" }, { type: "null" }], description: The share eaten. }

    PhotoIngredient:
      type: object
      properties:
        index: { type: integer }
        name: { type: [string, "null"] }
        serving:
          type: object
          properties:
            quantity: { type: [number, "null"] }
            label: { type: [string, "null"] }
        nutrition: { $ref: "#/components/schemas/Nutrition" }
        confidence: { type: [number, "null"], minimum: 0, maximum: 1 }

    ExerciseEntry:
      type: object
      properties:
        id: { type: string, format: uuid }
        local_date: { type: string, format: date }
        name: { type: [string, "null"] }
        calories_burned_kcal: { type: [number, "null"] }
        duration_min: { type: [number, "null"] }
        source: { type: [string, "null"], description: "manual, apple_health, health_connect or steps" }
        logged_at: { type: string, format: date-time }
        updated_at: { type: [string, "null"], format: date-time }
        timezone: { type: [string, "null"] }

    Measurement:
      type: object
      properties:
        id: { type: string, format: uuid }
        kind: { type: string, enum: [steps, active_energy, body_weight, sleep, resting_heart_rate], description: "steps and active_energy are a local day's total; body_weight is one weigh-in; sleep is minutes asleep in the night ending that day; resting_heart_rate is the day's average." }
        local_date: { type: string, format: date }
        measured_at: { type: [string, "null"], format: date-time, description: The instant of a weigh-in; null for a daily total. }
        timezone: { type: [string, "null"] }
        value: { type: [number, "null"] }
        unit: { type: string, enum: [count, kcal, kg, min, bpm], description: The unit of `value`. }
        source: { type: string, enum: [apple_health, health_connect] }
        source_name: { type: [string, "null"], description: The device or app that recorded a weigh-in. }
        updated_at: { type: [string, "null"], format: date-time }

    Deletion:
      type: object
      properties:
        type: { type: string, enum: [diary_entry, exercise_entry] }
        id: { type: string, format: uuid }
        local_date: { type: string, format: date }
        deleted_at: { type: string, format: date-time }

    HeartRateZones:
      type: object
      description: Seconds in each zone.
      properties:
        z1: { type: integer }
        z2: { type: integer }
        z3: { type: integer }
        z4: { type: integer }
        z5: { type: integer }

    Workout:
      type: object
      properties:
        id: { type: string, format: uuid }
        started_at: { type: string, format: date-time }
        ended_at: { type: [string, "null"], format: date-time }
        duration_sec: { type: [integer, "null"] }
        timezone: { type: [string, "null"] }
        status: { type: [string, "null"] }
        title: { type: [string, "null"] }
        notes: { type: [string, "null"] }
        calories_burned_kcal: { type: [number, "null"] }
        avg_heart_rate_bpm: { type: [number, "null"] }
        max_heart_rate_bpm: { type: [number, "null"] }
        time_in_heart_rate_zone_sec: { $ref: "#/components/schemas/HeartRateZones" }
        heart_rate_device: { type: [string, "null"] }
        exercise_order: { type: [array, "null"], items: { type: string } }
        created_at: { type: string, format: date-time }
        sets:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid }
              exercise_id: { type: string, description: "A slug from Vital's exercise catalogue, e.g. bench-press." }
              set_index: { type: [integer, "null"] }
              weight_kg: { type: [number, "null"] }
              reps: { type: [integer, "null"] }
              rpe: { type: [number, "null"], description: Rate of perceived exertion, 1-10. }
              is_warmup: { type: boolean }
              completed_at: { type: [string, "null"], format: date-time }
              notes: { type: [string, "null"] }

    CardioSession:
      type: object
      properties:
        id: { type: string, format: uuid }
        started_at: { type: string, format: date-time }
        timezone: { type: [string, "null"] }
        kind: { type: [string, "null"], description: "run, walk, bike, swim, paddle, dance, ..." }
        source: { type: [string, "null"], description: "live, manual, apple_health or health_connect" }
        duration_sec: { type: [number, "null"] }
        distance_m: { type: [number, "null"] }
        calories_burned_kcal: { type: [number, "null"] }
        avg_heart_rate_bpm: { type: [number, "null"] }
        max_heart_rate_bpm: { type: [number, "null"] }
        time_in_heart_rate_zone_sec: { $ref: "#/components/schemas/HeartRateZones" }
        heart_rate_device: { type: [string, "null"] }
        created_at: { type: string, format: date-time }
        route: { description: Only with series=true. App-internal GPS points. }
        heart_rate_series: { description: Only with series=true. App-internal samples. }

    FoodLine:
      type: object
      description: A planned or saved food. Nutrition is the total for the serving.
      properties:
        name: { type: [string, "null"] }
        brand: { type: [string, "null"] }
        source: { $ref: "#/components/schemas/Source" }
        serving: { $ref: "#/components/schemas/Serving" }
        nutrition: { $ref: "#/components/schemas/Nutrition" }

    Recipe:
      type: object
      properties:
        id: { type: string, format: uuid }
        title: { type: [string, "null"] }
        description: { type: [string, "null"] }
        servings: { type: [number, "null"] }
        prep_time_min: { type: [number, "null"] }
        cook_time_min: { type: [number, "null"] }
        tags: { type: array, items: { type: string } }
        source_url: { type: [string, "null"] }
        source_name: { type: [string, "null"] }
        folder_id: { type: [string, "null"], format: uuid }
        current_version_no: { type: [integer, "null"] }
        created_at: { type: string, format: date-time }
        nutrition_per_serving: { $ref: "#/components/schemas/Macros" }
        ingredients:
          type: array
          items:
            type: object
            properties:
              index: { type: integer }
              name: { type: [string, "null"] }
              quantity_text: { type: [string, "null"] }
              matched_food:
                oneOf:
                  - allOf: [{ $ref: "#/components/schemas/Source" }, { properties: { name: { type: [string, "null"] } } }]
                  - { type: "null" }
              counted: { type: boolean }
              weight_estimated: { type: boolean }
              amount_in_recipe: { oneOf: [{ $ref: "#/components/schemas/Serving" }, { type: "null" }] }
              nutrition_in_recipe: { oneOf: [{ $ref: "#/components/schemas/Nutrition" }, { type: "null" }], description: For the whole recipe. }
        instructions: { type: array, items: { type: string } }
        sides:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid }
              name: { type: [string, "null"] }
              quantity_text: { type: [string, "null"] }
              source: { $ref: "#/components/schemas/Source" }
              nutrition: { $ref: "#/components/schemas/Macros" }

    SavedMeal:
      type: object
      properties:
        id: { type: string, format: uuid }
        name: { type: [string, "null"] }
        use_count: { type: [integer, "null"] }
        last_used_at: { type: [string, "null"], format: date-time }
        created_at: { type: string, format: date-time }
        updated_at: { type: [string, "null"], format: date-time }
        nutrition_total: { $ref: "#/components/schemas/Nutrition" }
        items:
          type: array
          items:
            allOf:
              - properties: { id: { type: string, format: uuid } }
              - { $ref: "#/components/schemas/FoodLine" }

    PlanLine:
      allOf:
        - { $ref: "#/components/schemas/FoodLine" }
        - type: object
          properties:
            id: { type: string, format: uuid }
            meal_type: { type: [string, "null"] }
            meal_type_label: { type: [string, "null"], description: The label of a custom slot. }
            position: { type: [integer, "null"] }
            recipe_id: { type: [string, "null"], format: uuid }
            recipe_servings: { type: [number, "null"] }
            meal_group_id: { type: [string, "null"], format: uuid }
            meal_group_name: { type: [string, "null"] }
            saved_meal_id: { type: [string, "null"], format: uuid }
            is_placeholder: { type: boolean }

    MealPlanEntry:
      allOf:
        - { $ref: "#/components/schemas/PlanLine" }
        - type: object
          properties:
            local_date: { type: string, format: date }
            recipe_version_no: { type: [integer, "null"] }
            from_template_id: { type: [string, "null"], format: uuid }
            created_at: { type: string, format: date-time }
            updated_at: { type: [string, "null"], format: date-time }

    MealPlanTemplate:
      type: object
      properties:
        id: { type: string, format: uuid }
        name: { type: [string, "null"] }
        scope: { type: string, enum: [household, personal] }
        created_at: { type: string, format: date-time }
        updated_at: { type: [string, "null"], format: date-time }
        entries:
          type: array
          items:
            allOf:
              - properties: { day_index: { type: [integer, "null"], description: "0-6, the position in the template's week." } }
              - { $ref: "#/components/schemas/PlanLine" }

    Habit:
      type: object
      properties:
        id: { type: string, format: uuid }
        name: { type: [string, "null"] }
        subtitle: { type: [string, "null"] }
        mode: { type: [string, "null"] }
        provider: { type: [string, "null"] }
        auto_source: { type: [string, "null"] }
        config: { type: object, description: App-internal; holds targets and the unit of `value`. }
        active_days: { type: [array, "null"], items: {} }
        archived: { type: boolean }
        sort_order: { type: [integer, "null"] }
        created_at: { type: string, format: date-time }
        updated_at: { type: [string, "null"], format: date-time }

    HabitLog:
      type: object
      properties:
        id: { type: string, format: uuid }
        habit_id: { type: string, format: uuid }
        local_date: { type: string, format: date }
        done: { type: [boolean, "null"] }
        count: { type: [integer, "null"] }
        value: { type: [number, "null"] }
        elapsed_sec: { type: [integer, "null"] }
        rating: { type: [integer, "null"] }
        created_at: { type: string, format: date-time }
        updated_at: { type: [string, "null"], format: date-time }

    CustomFood:
      type: object
      properties:
        source: { $ref: "#/components/schemas/Source" }
        name: { type: [string, "null"] }
        brand: { type: [string, "null"] }
        serving_size_text: { type: [string, "null"] }
        nutrition_per_serving: { $ref: "#/components/schemas/Nutrition" }
        created_at: { type: string, format: date-time }
        updated_at: { type: [string, "null"], format: date-time }

    PantryItem:
      type: object
      properties:
        id: { type: string, format: uuid }
        scope: { type: string, enum: [household, personal] }
        name: { type: [string, "null"] }
        brand: { type: [string, "null"] }
        size_text: { type: [string, "null"] }
        category: { type: [string, "null"] }
        barcode: { type: [string, "null"] }
        status: { type: [string, "null"] }
        desired_quantity_count: { type: [integer, "null"], description: Packages wanted on hand. }
        stores: { type: array, items: { type: string } }
        tracks_nutrition: { type: boolean }
        tracks_expiration: { type: boolean }
        does_not_expire: { type: boolean }
        estimated_shelf_life_days: { type: [integer, "null"] }
        matched_food: { $ref: "#/components/schemas/Source" }
        nutrition_basis:
          type: [object, "null"]
          properties:
            value: { type: number }
            unit: { type: [string, "null"] }
        nutrition_per_basis: { $ref: "#/components/schemas/Macros" }
        created_at: { type: string, format: date-time }
        stock:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid }
              quantity_count: { type: [integer, "null"], description: Packages in this lot. }
              expiration_date: { type: [string, "null"], format: date }
              expiration_is_estimated: { type: boolean }
              location: { type: [string, "null"] }
              added_at: { type: [string, "null"], format: date-time }

    Me:
      type: object
      properties:
        id: { type: [string, "null"], format: uuid }
        display_name: { type: [string, "null"] }
        created_at: { type: [string, "null"], format: date-time }
        timezone: { type: [string, "null"] }
        measurement_system: { type: [string, "null"], description: imperial or metric }
        goals:
          type: object
          properties:
            calories_kcal: { type: [number, "null"] }
            protein_g: { type: [number, "null"] }
            carbs_g: { type: [number, "null"] }
            fat_g: { type: [number, "null"] }
            other_nutrients: { type: object, additionalProperties: { type: number } }
            weight_goal_lb: { type: [number, "null"] }
        profile_inputs: { description: App-internal; what the person entered when setting goals. }
        households:
          type: array
          items:
            type: object
            properties:
              id: { type: string, format: uuid }
              name: { type: [string, "null"] }
