Technical Docs
  • Introduction
  • Guides
    • Getting Started
    • Attribution Guidelines
    • Core Concepts
      • Adherence Score
      • Programs, Diets, and Rulesets
      • User Profile
      • Datasets
    • Tutorials and Walkthroughs
      • Creating a Meal Plan
      • Food Log Guide
      • Pagination
      • Executing Multiple Mutations
  • Knowledge Base
    • How-to guides
      • How to add desserts to your meal plan
      • How to log your custom recipe
      • How to generate a Meal Plan based on a template
    • Common errors
      • Meal Plan generation
    • FAQs
      • Getting Started on Suggestic
      • API and Authentication
      • Device Compatibility
      • Meal Plan
      • Nutrition
      • Programs
      • Recipes
  • HELPFUL RESOURCES
    • Deprecated Features
    • Glossary
    • Integrations
      • Building a No-code Meal Planning Application
        • Step 1: Creating the Integromat Scenario and Google Forms Connection
        • Step 2: Creating a User, Generating a Meal Plan, and Retrieving It
        • Step 3: Crafting Our PDF and Connecting PDFMonkey
        • Step 4: Sending The Document to Our User
  • Packages and SDKs
    • Node Package (NPM)
  • GraphQL
    • GraphQL Overview
    • Authentication
    • Calling GraphQL
    • GraphQL Playground
  • Changelog
    • 2025
      • March
  • Suggestic API Reference
    • Search
      • Food Log
        • Branded Foods Search
        • Common Foods Search
        • My Branded Food Search
        • My Common Foods Search
        • Food Search
        • Legacy
          • Autocomplete
          • Barcode Search
      • Recipe Search
        • Recipe Search
        • Recipe Search by Name or Ingredients
        • Recipe Search by Ingredients
      • Meal Plan Template Search
      • Profile Search
      • Restaurant Search
        • Restaurant Search by Location
        • Restaurant Search
    • Queries
      • Appointments
        • Upcoming Appointments
        • Past Appointments
        • Appointments Types
      • Assessments
        • Assessment Answers
        • Display Assessments
        • Supplement Recommendations
        • User Assessments
      • Content
        • Content Library
        • Content Categories
        • Content Tags
        • Journey
      • Food Log
        • Frequently Logged
        • Food Log Entries
        • Macros Aggregation
        • Micronutrients Aggregation
        • Macro Goals
        • Recently Logged
        • User's Foods and Recipes
          • User's Recipes
        • Legacy
          • Food Log Entries (Legacy)
          • Own Food Items
          • Own Food Item
          • Own Food Item by Id
          • Own Items
          • Own Recipe
          • Own Recipes
      • Lab Tests
        • Biomarker Categories
        • Biomarker Units
        • Biomarker Catalog
        • Biomarkers
        • Biomarker Results
        • Historical Biomarker Results
        • Historical Results by Biomarker
        • Lab Test Reports
        • Recommended Supplements
        • Recommended Articles
      • Meal Plan
        • Meal Plan
        • Custom Meal Plan
        • Simplified Meal Tracking
          • Meal Tracker
        • Meal Plan Config
        • Meal Planner (deprecated)
      • Program
        • All Programs
        • Program Details
      • Recipes
        • Equivalent Recipes (Macros)
        • Equivalent Recipes (Calories)
        • Recipe by Id
        • Recipes By MealTime
        • Recipes By Tag
        • Recipe Swap Options
        • Popular Recipes
        • Favorite Recipes
        • Premium Program Recipes
      • Restaurants
        • Restaurant By Id
        • Menu Items
        • Menu Item By Id
        • Menu Item by Program
        • Recommend Menu Items
      • Restrictions
        • Restrictions
        • Restriction by ID
      • Shopping List
        • Shopping List by Aisle
        • Shopping List by Recipes
      • Subscriptions
        • Subscription List
      • Supplement Plans
        • Supplement plan list
        • Supplement list
      • Tracking
        • Activity and Exercise
        • Checklists
          • Intake Checklist
        • Daily Recap
          • Get Daily Recap
          • Get Daily Recaps
          • Get Daily Recap Questions
          • Get Daily Mood Summary
        • Inisghts
        • Wellness Score
        • Sleep
          • Sleep Time
          • Sleep Quality Score
        • Steps
        • Water and Hydration
        • Heart Rate
        • HRV
        • Weight Tracker
      • USDA Food
      • Users
        • Users
        • User Profile
      • WGPT
        • Assistants
        • Journey
        • Guardrails
    • Mutations
      • Appointments
        • Update Appointment Credits
      • Assessments
        • New User Assessments
        • Set User Answers
      • Content
        • Mark Content as Read
      • Feedback
      • Food Log
        • Log Entries
          • Food Log
            • Add a Food Log Entry
            • Delete a Food Log Entry
          • Meal Log (Legacy)
            • Create Log Entry
            • Update Log Entry
            • Remove Log Entry
        • User's Foods and Recipes
          • Create a User Recipe
          • Create my Branded Food
          • Create my Common Foods
          • Update a User Recipe
          • Delete a User Recipe
          • Legacy: "Own" Recipe
            • Create "Own" Recipe
            • Update "Own" Recipe
            • Remove "Own" Recipe
        • AI Food Log
          • Process Ai Food
        • Legacy (ownFoods and ownRecipes)
          • Create "own" Food Item
          • Update "own Food"
          • Remove "own" Food Item
      • Journey Status
        • Start Journeys
        • Journey Status
        • Toggle Task Completed
      • Lab Tests
        • Add Biomarker
        • Update Biomarker
        • Add Biomarker Result
        • Add Biomarker Category
        • Update Biomarker Category
        • Remove Biomarker Category
        • Add Lab Test Report
        • Delete Lab Test Report
        • Update Lab Test Report
        • Create Recommended Supplement
        • Update Recommended Supplement
        • Remove Recommended Supplement
        • Create Recommended Article
        • Update Recommended Article
        • Remove Recommended Supplement
      • Meal Plan
        • Create Meal Plan Template
          • Custom Options
          • From Days
          • From Scratch
        • Assign a Meal Plan Template to a User
        • Generate Simple Meal Plan
        • Generate Meal Plan
        • Start Over Meal Plan
        • Swap Meals
        • Simplified Meal Tracking
          • Create a Meal Tracker Entry
        • Remove Meal Plan
        • Remove Meal Plan Recipe
      • Recipes
        • Add new recipe
        • Add Favorite Recipe
      • Shopping List
        • Add Multiple Recipes to the Shopping List
        • Add a Recipe to the Shopping List
        • Bulk Check/Uncheck Items
        • Check/Uncheck an Item
        • Clear Checked Items
        • Clear Shopping List
        • Remove Recipe
        • Update Serving Number
      • Subscriptions
        • Update Subscription
      • Supplement Plans
        • Create supplement plan for user
        • Update user supplement plan
        • Add Supplement
        • Update Supplement
      • Tracking
        • Activity and Exercise
          • Add Exercise Entry
          • Delete Exercise Entry
        • Checklists
          • Create my Checklist Item
          • Delete my Checklist Item
        • Daily Recap
          • Create a daily recap question
          • Select Daily Recap Questions
          • Delete a Daily Recap Question
        • Sleep
          • Add Sleep Time
          • Add Sleep Quality Score
        • Steps
          • Add Steps Count
          • Delete Steps Count
        • Heart Rate
          • Add Heart Rate
          • Delete Heart Rate
        • HRV
          • Add HRV
          • Delete HRV
        • Water and Hydration
        • Weight
          • Add Weight Entry
          • Remove Weight Entry
        • User Tracker Goals
          • Create User Goal
          • Update User Goal
          • Remove User Goal
      • Users
        • Authenticate using a Magic Link
        • Create User
        • Custom Attributes
        • Delete a User Account
        • Login User
        • Merge User Accounts
        • Request Reset Password
        • Reset Password
        • Request Password Reset email
        • Sensitive Profile Attributes
        • Update Profile
        • Update User's Program
        • User's Restrictions
        • Update Meal Plan Settings
        • User's Goals
        • Legacy User Mutations
          • Legacy | User's Biomarkers
          • User's Meal Plan Settings (deprecated)
      • WGPT
        • Add user to journey
  • Objects
    • Appointments
      • Appointment
      • Appointment Type
      • Appointment Credit
      • Attendee
      • Coach
    • Common
      • User
      • Adherence
      • Aisle Name
      • CPC
      • CPCIngredientGroup
      • Meal Times
      • Menu Item
      • Own Serving
      • Own Nutrients
      • MacroNutrientsRangeInput
      • Range
      • Tracker
      • Restaurant
    • Food Logs
      • Food Filter
      • Ingredient Amount
      • Ingredients
      • Own Recipe Ingredient
      • Meal Type
      • Nutrients
        • Nutrient Enum
      • Portions
      • Servings
      • AI Food Log
        • Food Analysis
    • Meal Plan
      • Debug Meal Plan Conditions
      • Meal
      • Meal Plan Day
      • Maximum Time per Meal
      • Maximum Ingredient Count
      • Meal Plan Template
      • Simple Meal Plan Filters
    • Recipe
      • Recipe
        • Tags
        • Cuisines
      • Recipe Swap Options
      • Parsed Ingredient Lines
      • Nutritional Info
      • Nutrients Per Serving
      • Calories Per Serving
      • Relative Calories
      • Source
      • Ingredients
      • Units of Measurement
    • Lab Tests
      • Article
      • Biomarker
    • Supplement
    • Assessments
      • Question
      • Answer
    • Content
      • Content Library
      • Content Categories
      • Content Tag
    • WGPT
      • Journey
      • dayJourney
      • Interaction
  • Case Studies
    • Reverse Health Case Study
Powered by GitBook
On this page
  • How to Use
  • First Request
  • Generating a New Meal Plan
  • Generate a meal plan based on a created template
  • Generating a meal plan with a predefined calorie distribution
  • Couldn't generate a meal plan?
  • Arguments
  • Available fields
  • Examples
  • Create a new meal plan week for the user:
  • Append a meal plan week to the current meal plan in progress:
  • Add days to the meal plan
  • Repeat a week
  • Set the maximum preparation times and the maximum ingredients
  • Define a low variety of recipes
  • Generate a Meal Plan based on a Meal Plan Template
  • Add days from a meal plan to the current meal plan

Was this helpful?

  1. Suggestic API Reference
  2. Mutations
  3. Meal Plan

Generate Meal Plan

PreviousGenerate Simple Meal PlanNextStart Over Meal Plan

Last updated 11 months ago

Was this helpful?

Use the generateMealPlan mutation to create a new meal plan week for the user.

By default, the meal plan is generated based on the user's , but you have the ability to overwrite the default settings by using the mutation.

How to Use

First Request

The first time a user requests generateMealPlan the request will immediately return success = true and mealPlan will be ready to be queried.

Generating a New Meal Plan

If Settings Haven't Changed

If the user's meal plan settings or goals have not changed since the previous meal plan was created then it will not be possible to generate a new meal plan until the last date in the current one has passed. This means that a user cannot generate a new meal plan if the last one is still running.

The mutation will return success=false when the user still has days left in their current meal plan.

You can force the generation of a new meal plan while the last day in the current one is still running passing the parameter addDays = true to the mutation. This is only available for the last day of the current meal plan, and it will append the new week to start the next day.

If Settings Did Change

If the user's meal plan settings (or goals) have changed since the previous meal plan was created then the process will resemble a first-time generation.

Please note that a meal plan is not automatically generated when the user's meal plan settings or goals change.

Deleting and generating a meal plan again

Delete a meal plan only if it hasn't started yet.

If you delete and generate a meal plan again without changing the user's goals or settings, the recipes displayed will remain the same. This occurs because the process will always look for the ideal initial combination according to the given user's goals.

Repeating a meal plan

The mutation accepts a repeat datetime parameter to repeat a past meal plan. The mutation will select the first 7 days in the user's history with a date greater than or equal to repeat. These days will be duplicated and set as the new meal plan.

Because the selected days are sorted and selected only by their date, they may have been generated from meal plans with different settings or have gaps in their original dates.

The mutation will return success=false when the user doesn't have at least 7 days with a date greater than or equal to repeat.

Defining the variety of recipes

There are 3 levels of variety:

  • LOW: Generate three different meals in the week. For example, the meal plan generates three breakfasts, three lunches, three dinners, and three snacks distributed across the week.

  • MEDIUM: Generate 5 different meals in the week.

  • HIGH: All generated meals are different. This is the current behavior of the meal plan.

This is not a required argument, so if it is not defined, the high variety is set as default.

Get the information of the meal plan generated

Use this information to debug your meal plan or when the meal plan is generated quickly.

This is not recommended to be used in the Apps because of a timeout of 50 seconds.

Generate a meal plan based on a created template

Generating a meal plan with a predefined calorie distribution

You may use the distribution arguments to generate a meal plan with a predefined distribution of calories per meal. For example, you may want that breakfast doesn't exceed 30% of total daily calories and dinner doesn't exceed 25%. The request for this example would look as follows:

mutation {
    generateMealPlan(
        breakfastDistribution: 0.3
        dinnerDistribution: 0.25
    ) {
        success
        message
    }
}

It's important to notice that these percentages are per meal and not per meal tag, so if your meal plan's format contains 2 breakfasts, the generator will try to pick two breakfast recipes with calories equal to 30% each, this means that your 2 breakfasts will represent 60% of the daily caloric goal!

Couldn't generate a meal plan?

Arguments

Argument Name

Type

Description

addDays

Boolean

True to allow generating a new meal plan if a user is on her last meal plan day. This field is ignored if ignoreLock is true. Default is false. If the fromTemplate argument is used and the addDays is true, the template days are added to the current meal plan, instead of replacing the running days.

isAppend

Boolean

True to add an additional week worth of meal plan (7 days) to the end of the current meal plan each time is executed. (Default is false.)

appendDays

Int

After setting isAppend to True use appendDays to define the amount of days to append. (max 7)

fromTemplate

ID

ignoreLock

Boolean

True to allow generating a new meal plan any time, overwriting any pending days in the current plan. Default is false.

includeFavorites

Boolean

True to include 2 random recipes, extracted from the user's favorites, within the generated meal plan.

False no actions are executed and the number of generated days is still 7.

repeat

Datetime

Create a new meal plan repeating the 7 dates after repeat

in user's history. Default to null.

kcalLimit

Float

Sets an upper kcal limit per meal in the meal plan as a percentage of the daily goal. Default is 0.50.

maxNumOfServings

Int

A maximum number of servings per meal is allowed in the meal plan. Must be between 1 and 15. Default is 15.

maxServingWeight

Int

Maximum serving weight in grams per meal. Default is 600.

minServingWeight

Int

Minimum serving weight in grams per meal. Default is 100.

breakfastDistribution

Float

Percentage of the daily calories goal that each breakfast covers.

lunchDistribution

Float

Percentage of the daily calories goal that each lunch covers.

dinnerDistribution

Float

Percentage of the daily calories goal that each dinner covers.

snackDistribution

Float

Percentage of the daily calories goal that each snack covers.

maxTimeMinutes

Object that returns the maximum values for each meal. Expressed in minutes.

For example, maximum preparation time for the following meals:

  • breakfast: 15

  • lunch: 30

  • dinner: 40

  • snack: 30

maxIngredientsCount

Object that returns the maximum values for each meal. Expressed in minutes.

For example, maximum ingredient count for the following meals:

  • breakfast: 7

  • lunch: 5

  • dinner: 5

  • snack: 6

variety

MPVariety

Define the variety of the recipes generated in the meal plan. Possible Values: LOW, MEDIUM, or HIGH

startDate

Date

Set starting date for the Meal Plan. (YYYY-MM-DD )

Available fields

The following field will be part of the response.

Field name

Type

Description

success

Boolean

True if the meal plan template has been created. Otherwise, it displays False

message

String

Description of the result

mealPlan

Returns the information of the meal plan generated.

Examples

Create a new meal plan week for the user:

mutation {
  generateMealPlan {
    success
    message
  }
}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

Append a meal plan week to the current meal plan in progress:

mutation{ generateMealPlan(isAppend:true  appendDays:7){
  success
  message
}}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

Add days to the meal plan

Create another week when the last day from the last meal plan is still running:

mutation {
  generateMealPlan(addDays: true) {
    success
    message
  }
}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

Repeat a week

Repeat the week from 2020-05-20 to 2020-05-27. Remember that repeat has to be a DateTime in UTC timezone.

mutation {
  generateMealPlan(repeat: "2020-05-20T10:25:14.120000Z") {
    success
    message
  }
}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

Set the maximum preparation times and the maximum ingredients

Set the maximum preparation times and the maximum ingredients for the breakfast, lunch, dinner, and snack meals

mutation {
  generateMealPlan (
     maxTimeMinutes:{
      breakfast:10,
      dinner:5,
      snack:200,
      lunch:3
    }
    maxIngredientsCount:
    {
      breakfast:7,
      dinner:5,
      snack:5,
      lunch:3
    }
  ) 
    {
    success
    message
  }
}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

Define a low variety of recipes

mutation {
  generateMealPlan(variety: LOW) {
    success
    message
  }
}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

Generate a Meal Plan based on a Meal Plan Template

The following example describes how to generate a meal plan based on a given template ID

mutation {
  generateMealPlan(
    fromTemplate: "TWVhbFBsYW5UZW1wbGF0ZTphNjc5NGIwYy1lN2Y4LTQ5ZDYtOWIxZC04M2ExZTY0MDExZmE="
  ) {
    success
    message
    mealPlan {
      day
      date
    }
  }
}

{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated.",
      "mealPlan": [
        {
          "day": 2,
          "date": "2022-01-15 02:00:00+00:00"
        },
        {
          "day": 1,
          "date": "2022-01-14 02:00:00+00:00"
        }
      ]
    }
  }
}

As follows find a step by step explanation of how to get the template ID and use it to generate a meal plan:

Add days from a meal plan to the current meal plan

The following example adds the days created in a meal plan template to the meal plan currently active.

mutation {
  generateMealPlan(
    fromTemplate: "TWVhbFBsYW5UZW1wbGF0ZToyYTVmY2Q3Zi0wNzJlLTRiMjYtOGE3ZC1iYTgxNDZhMmY3ZTQ="
    addDays: true
  ) {
    success
    message
  }
}
{
  "data": {
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}

In the following example, 5 days from the meal plan template is added to the current meal plan:

UI/UX example

In the same way, we have code examples, this is an implementation example in which see results of the API execution in the Suggestic App.

Login to the App, tap on the Meal Plan option, and the 7-day meal plan is listed. The information is separated per day and per meal type:

Use the argument to generate a meal plan with less variety of recipes; therefore, this allows recipes repeated in the meal plan.

Instead of executing the query separately, include the mealPlan field in the response of the generateMealPlan mutation to retrieve the information of the generated meal plan.

Generate custom meal plans by using a meal plan template previously created. In addition, if you have a running meal plan, you can add the days from the meal plan template by using the addDays argument as true. For more information, refer to .

First, the user creates the according to what best fits him and then uses the to pass as an argument in this mutation.

For more information, refer to .

If you get the Couldn't generate a meal plan with the current settings message, check the meal plan settings by executing the query. For more information to know the causes and get the solution, see

Use the from which the meal plan will be generated.

Execute the query to check the generated recipes.

goals
profileMealPlanSettings
mealPlan
meal plan template
template ID
debugMealPlanVariables
this document.
mealPlan
variety
this example
this example
meal plan template ID
maxTimeMinutes
maxIngredientsCount
mealPlanDay