openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: NutriSnap API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: Auth description: Browser and mobile authentication endpoints. - name: profile description: User profile and onboarding - name: recipes description: Daily recipe generation and saved recipes - name: shopping description: Shopping list management - name: streaks description: Cooking streak tracking paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /capabilities: get: operationId: getCapabilities tags: [health] summary: Get server feature capabilities responses: "200": description: Feature flags supported by backend content: application/json: schema: $ref: "#/components/schemas/CapabilitiesResponse" /me: get: tags: [Auth] operationId: getCurrentUser summary: Get the currently authenticated user parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '200': description: Auth status resolved successfully. content: application/json: schema: $ref: '#/components/schemas/AuthUserEnvelope' /login: get: tags: [Auth] operationId: beginBrowserLogin summary: Start the browser OIDC login flow parameters: - name: returnTo in: query required: false schema: type: string responses: '302': description: Redirect to the OIDC authorization endpoint. /callback: get: tags: [Auth] operationId: handleBrowserLoginCallback summary: Complete the browser OIDC login flow parameters: - name: code in: query required: false schema: type: string - name: state in: query required: false schema: type: string - name: iss in: query required: false schema: type: string format: uri responses: '302': description: Redirect to returnTo path. /auth/logout: get: tags: [Auth] operationId: logoutBrowserSession summary: Clear the session and begin OIDC logout parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '302': description: Redirect to the OIDC provider logout URL. /mobile-auth/token-exchange: post: tags: [Auth] operationId: exchangeMobileAuthorizationCode summary: Exchange a mobile OIDC code for a session token requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/MobileTokenExchangeRequest' responses: '200': description: Session created successfully. content: application/json: schema: $ref: '#/components/schemas/MobileTokenExchangeSuccess' '400': description: Missing or invalid required fields. content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /mobile-auth/logout: post: tags: [Auth] operationId: logoutMobileSession summary: Delete a mobile session token parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' responses: '200': description: Logout processed. content: application/json: schema: $ref: '#/components/schemas/LogoutSuccess' /profile: get: tags: [profile] operationId: getProfile summary: Get current user profile parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '200': description: User profile content: application/json: schema: $ref: '#/components/schemas/UserProfileResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' put: tags: [profile] operationId: updateProfile summary: Create or update user profile (onboarding) parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateProfileRequest' responses: '200': description: Profile saved content: application/json: schema: $ref: '#/components/schemas/UserProfileResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /recipes/today: get: tags: [recipes] operationId: getTodayRecipes summary: Get today's 4 recipes (breakfast, lunch, dinner, treat) parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' - name: date in: query required: false schema: type: string format: date responses: '200': description: Daily recipes content: application/json: schema: $ref: '#/components/schemas/DailyRecipesResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /recipes/regenerate: post: tags: [recipes] operationId: regenerateRecipe summary: Regenerate a specific meal's recipe parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/RegenerateRecipeRequest' responses: '200': description: Regenerated recipe content: application/json: schema: $ref: '#/components/schemas/DailyRecipeItem' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /recipes/regenerate-menu: post: tags: [recipes] operationId: regenerateMenu summary: Regenerate the full menu for a date parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: false content: application/json: schema: $ref: '#/components/schemas/RegenerateMenuRequest' responses: '200': description: Regenerated daily recipes content: application/json: schema: $ref: '#/components/schemas/DailyRecipesResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /recipes/history: get: tags: [recipes] operationId: getRecipeHistory summary: Get generated meal history for recent days parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' - name: days in: query required: false schema: type: integer minimum: 1 maximum: 120 default: 30 responses: '200': description: Grouped meal history content: application/json: schema: $ref: '#/components/schemas/MealHistoryResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /saved-recipes: get: tags: [recipes] operationId: getSavedRecipes summary: Get all saved recipes parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '200': description: Saved recipes list content: application/json: schema: $ref: '#/components/schemas/SavedRecipesResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' post: tags: [recipes] operationId: saveRecipe summary: Save a recipe to favorites parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SaveRecipeRequest' responses: '201': description: Recipe saved content: application/json: schema: $ref: '#/components/schemas/SavedRecipeItem' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /saved-recipes/{id}: delete: tags: [recipes] operationId: deleteSavedRecipe summary: Remove a saved recipe parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' - name: id in: path required: true schema: type: string responses: '200': description: Recipe removed content: application/json: schema: $ref: '#/components/schemas/SuccessResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /shopping-list: get: tags: [shopping] operationId: getShoppingList summary: Get shopping list for a date parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' - name: date in: query required: false schema: type: string format: date responses: '200': description: Shopping list content: application/json: schema: $ref: '#/components/schemas/ShoppingListResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' put: tags: [shopping] operationId: upsertShoppingList summary: Create or replace shopping list for a date parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpsertShoppingListRequest' responses: '200': description: Shopping list saved content: application/json: schema: $ref: '#/components/schemas/ShoppingListResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /shopping-list/check: patch: tags: [shopping] operationId: toggleShoppingItem summary: Toggle an item checked/unchecked parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ToggleShoppingItemRequest' responses: '200': description: Updated shopping list content: application/json: schema: $ref: '#/components/schemas/ShoppingListResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /shopping-list/stores: get: tags: [shopping] operationId: getNearbyStores summary: Find nearby grocery stores parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' - name: lat in: query required: false schema: type: number description: Latitude. If omitted, backend falls back to saved profile location. - name: lng in: query required: false schema: type: number description: Longitude. If omitted, backend falls back to saved profile location. - name: radius in: query required: false schema: type: integer default: 3000 responses: '200': description: Nearby grocery stores content: application/json: schema: $ref: '#/components/schemas/NearbyStoresResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /streak: patch: tags: [streaks] operationId: updateStreak summary: Log a cooked meal and update streak (48-hour reset) parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateStreakRequest' responses: '200': description: Updated streak content: application/json: schema: $ref: '#/components/schemas/StreakResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' get: tags: [streaks] operationId: getStreak summary: Get current streak data parameters: - $ref: '#/components/parameters/AuthorizationSessionHeader' - $ref: '#/components/parameters/SessionCookie' responses: '200': description: Streak info content: application/json: schema: $ref: '#/components/schemas/StreakResponse' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /api/billing/status: get: operationId: getBillingStatus summary: Get current plan and trial status security: - BearerAuth: [] responses: '200': description: Billing status content: application/json: schema: $ref: '#/components/schemas/BillingStatus' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' /api/billing/checkout: post: operationId: createBillingCheckout summary: Create a Stripe Checkout session security: - BearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/BillingCheckoutBody' responses: '200': description: Checkout URL content: application/json: schema: $ref: '#/components/schemas/BillingCheckoutResponse' '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorEnvelope' components: parameters: AuthorizationSessionHeader: name: Authorization in: header required: false description: Opaque session token — `Bearer `. schema: type: string SessionCookie: name: sid in: cookie required: false description: Browser session cookie. schema: type: string schemas: BillingStatus: type: object required: [plan, trialActive, trialHoursLeft, upgradeRequired] properties: plan: type: string enum: [free, lifetime] trialActive: type: boolean trialHoursLeft: type: number upgradeRequired: type: boolean BillingCheckoutBody: type: object required: [type] properties: type: type: string enum: [full, split_first] BillingCheckoutResponse: type: object required: [url] properties: url: type: string HealthStatus: type: object properties: status: type: string required: - status CapabilitiesResponse: type: object required: [features] properties: features: type: object required: [mealHistory] properties: mealHistory: type: boolean AuthUser: type: object required: [id, email, firstName, lastName, profileImageUrl] properties: id: type: string email: type: [string, 'null'] format: email firstName: type: [string, 'null'] lastName: type: [string, 'null'] profileImageUrl: type: [string, 'null'] AuthUserEnvelope: type: object required: [user] properties: user: oneOf: - $ref: '#/components/schemas/AuthUser' - type: 'null' MobileTokenExchangeRequest: type: object required: [code, code_verifier, redirect_uri, state] properties: code: type: string minLength: 1 code_verifier: type: string minLength: 1 redirect_uri: type: string minLength: 1 format: uri state: type: string minLength: 1 nonce: type: string minLength: 1 MobileTokenExchangeSuccess: type: object required: [token] properties: token: type: string LogoutSuccess: type: object required: [success] properties: success: type: boolean const: true ErrorEnvelope: type: object required: [error] properties: error: type: string SuccessResponse: type: object required: [success] properties: success: type: boolean UpdateProfileRequest: type: object properties: dietType: type: string allergies: type: array items: type: string healthGoal: type: string skillLevel: type: string caloriesTarget: type: integer city: type: string country: type: string lat: type: number lng: type: number UserProfileData: type: object required: [userId] properties: userId: type: string dietType: type: [string, 'null'] allergies: type: array items: type: string healthGoal: type: [string, 'null'] skillLevel: type: [string, 'null'] caloriesTarget: type: [integer, 'null'] city: type: [string, 'null'] country: type: [string, 'null'] lat: type: [number, 'null'] lng: type: [number, 'null'] createdAt: type: string format: date-time updatedAt: type: string format: date-time UserProfileResponse: type: object required: [profile] properties: profile: oneOf: - $ref: '#/components/schemas/UserProfileData' - type: 'null' RecipeObject: type: object properties: meal: type: string title: type: string emoji: type: string description: type: string prepTime: type: integer cookTime: type: integer servings: type: integer healthScore: type: integer goalAlignment: type: string macros: type: object properties: calories: type: integer protein: type: integer carbs: type: integer fat: type: integer calories: type: integer protein: type: integer carbs: type: integer fat: type: integer ingredients: type: array items: type: object properties: name: type: string amount: type: string unit: type: string isKeyIngredient: type: boolean steps: type: array items: type: string healthBenefits: type: array items: type: string swapSuggestion: type: string tags: type: array items: type: string imageUrl: type: [string, 'null'] DailyRecipeItem: type: object required: [id, mealType, recipe, date] properties: id: type: string mealType: type: string recipe: $ref: '#/components/schemas/RecipeObject' date: type: string format: date wasRegenerated: type: boolean DailyRecipesResponse: type: object required: [recipes, date] properties: recipes: type: array items: $ref: '#/components/schemas/DailyRecipeItem' date: type: string format: date MealHistoryRecipe: type: object required: [id, mealType, recipe, date, wasRegenerated] properties: id: type: string mealType: type: string recipe: $ref: '#/components/schemas/RecipeObject' date: type: string format: date wasRegenerated: type: boolean MealHistoryDay: type: object required: [date, recipes] properties: date: type: string format: date recipes: type: array items: $ref: '#/components/schemas/MealHistoryRecipe' MealHistoryResponse: type: object required: [days, totalMeals] properties: days: type: array items: $ref: '#/components/schemas/MealHistoryDay' totalMeals: type: integer RegenerateRecipeRequest: type: object required: [mealType] properties: mealType: type: string description: The meal slot to regenerate (breakfast, lunch, dinner, treat) date: type: string format: date RegenerateMenuRequest: type: object properties: date: type: string format: date SaveRecipeRequest: type: object required: [recipeJson] properties: recipeJson: $ref: '#/components/schemas/RecipeObject' SavedRecipeItem: type: object required: [id, recipe, savedAt] properties: id: type: string recipe: $ref: '#/components/schemas/RecipeObject' savedAt: type: string format: date-time SavedRecipesResponse: type: object required: [recipes] properties: recipes: type: array items: $ref: '#/components/schemas/SavedRecipeItem' ShoppingListItem: type: object required: [name, amount, unit, category] properties: name: type: string amount: type: string unit: type: string category: type: string checked: type: boolean ShoppingListResponse: type: object required: [items, date] properties: items: type: array items: $ref: '#/components/schemas/ShoppingListItem' date: type: string format: date id: type: [string, 'null'] UpsertShoppingListRequest: type: object required: [date, items] properties: date: type: string format: date items: type: array items: $ref: '#/components/schemas/ShoppingListItem' ToggleShoppingItemRequest: type: object required: [date, itemName, checked] properties: date: type: string format: date itemName: type: string checked: type: boolean StreakResponse: type: object required: [currentStreak, longestStreak] properties: currentStreak: type: integer longestStreak: type: integer lastCookedAt: type: [string, 'null'] format: date-time NearbyStore: type: object required: [name, address, distance, mapsLink] properties: name: type: string address: type: string distance: type: number openNow: type: [boolean, 'null'] mapsLink: type: string rating: type: [number, 'null'] NearbyStoresResponse: type: object required: [stores] properties: stores: type: array items: $ref: '#/components/schemas/NearbyStore' UpdateStreakRequest: type: object required: [recipeId] properties: recipeId: type: string