mymolecules

Endpoint

POST/functions/v1/design

Create recipes or meal plans from text, voice or structured requirements, tailored to dietary needs and preferences.

2026-09-29 is the newest public version. Send it in mymolecules-api-version when submitting and polling. Without the header, Design uses a legacy response format. An unsupported version returns HTTP 400 (unsupported_api_version).

For API-key setup and secure storage, see Authentication.

Choose an input mode

Both modes produce the same kind of result. Choose based on whether your application already has structured requirements or receives them as text or voice. Your API key must allow the selected mode; otherwise, Design returns HTTP 403 (design_input_mode_not_allowed).

ModeWhen to use itWhat to send
StructuredYour application already has explicit recipe or plan requirements.Send input_mode: structured, type and the supported fields below. Do not include request_text or request_voice.
UnstructuredThe person describes the desired recipe or plan in natural language.Send input_mode: unstructured and type with request_text, request_voice, or both. Describe your recipe or meal-plan requirements in the text or recording. You can send technical options separately, such as image delivery, nutrient analysis, whether to use existing recipes and completion callbacks.

Request fields

Common fields

FieldTypeDescription
input_modestringRequired for new jobs. structured or unstructured. Your API key must allow the selected mode; otherwise, HTTP 403 (design_input_mode_not_allowed). A missing, unknown or conflicting mode returns HTTP 400 (invalid_request) before a job is created. Polling does not require this field.
typestringRequired. recipe or meal_plan.
image_deliverystringOptional: none (default), signed_url. Image generation is part of job completion when requested.
image_target_sizestringOptional image dimensions as WIDTHxHEIGHT; each dimension must be 50–2048 pixels.
image_fitstringOptional image fit: cover, contain or stretch.
include_nutrient_analysisbooleanOptional. Default false; when true, include energy, carbohydrates, fat and protein for each recipe.
callback_urlstringOptional. HTTPS endpoint configured for this API key. Its URL must match the key’s callback configuration; public DNS is required. A registered callback is acknowledged in the accepted response.
skip_stored_recipesbooleanOptional. Default false. Set true to generate new recipes instead of using matching existing recipes.

Text and voice input

FieldTypeDescription
request_textstringRequired unless request_voice is supplied; both can be combined. Must contain non-whitespace text, at most 16,000 characters. For a meal plan, describe the number of days and meals per day.
request_voicestringRequired unless request_text is supplied; both can be combined. Inline base64 audio data URL, at most 25 MiB decoded. Supported MIME types: audio/mpeg, audio/mp3, audio/mp4, audio/x-m4a, audio/m4a, audio/wav, audio/x-wav, audio/webm, video/mp4. Remote URLs are not accepted.

Structured recipe

FieldTypeDescription
recipe_countintegerOptional. Number of distinct recipes, 1–10; default 1.
meal_typestringOptional: breakfast, lunch, dinner or snack.
dietstringOptional: vegan, vegetarian, fish, seafood or meat.

Structured meal plan

FieldTypeDescription
plan_daysintegerRequired. Number of days, 1–7.
meals_per_dayobjectRequired. breakfast, lunch, dinner and snack each accept 0–2; omitted categories count as zero. At least one meal per day and no more than 56 meals total.
diet_patternstringOptional: vegan, vegetarian, pescatarian, omnivore or flexitarian. Guides the mix of lunch and dinner diets across the plan.
excluded_dietsstring[]Optional. Exclude any of vegan, vegetarian, fish, seafood or meat. At least one diet must remain available.

Structured preferences and constraints

FieldTypeDescription
languagestringOptional. German is the only supported value and the current output language, even when omitted.
genderstringOptional: male or female. Supply when condition-specific nutrition rules require it.
difficultystringOptional: easy, medium or hard.
max_total_time_minintegerOptional. Positive maximum preparation plus cooking time in minutes.
pricestringOptional recipe price category in euros: <5€, 5-10€ or >10€. This is a selection preference, not a guaranteed shopping price.
cleanbooleanOptional. Set true to prefer high-fiber, predominantly plant-based recipes with unprocessed or minimally processed ingredients, without emulsifiers or additives. Meat is not automatically excluded.
excluded_allergensstring[] | "all"Optional. Use all or an array of: gluten_containing_cereals, crustaceans, eggs, fish, peanuts, soybeans, milk, nuts, celery, mustard, sesame, sulphur_dioxide_and_sulphites, lupin, molluscs.
tastestring[]Optional: sweet, salty, bitter, sour, umami.
aromastring[]Optional: Fruity, Citrus, Floral, Herbaceous, Spicy, Vanilla, Nutty, Roasted, Smoky, Cooling, Meaty, Fermented, Earthy, Fishy, Oily.
texturestring[]Optional: hard, adhesive, viscose, cohesive, crispy, crunchy, elastic, grainy.
sensory_profilestring[]Optional: fresh-vibrant, sweet-gentle, savory-hearty, toasted-crunchy, exotic-aromatic. Do not combine with taste, aroma or texture.
conditionstring | string[]Optional. Use exact names from Supported conditions below, not free-text diagnoses. Unknown names are rejected. Some condition-specific rules require gender or daily energy bounds; a matching result is not guaranteed.
preferred_foodsstringOptional. Non-empty food preference, at most 1,000 characters.
avoided_foodsstringOptional. Non-empty foods to avoid, at most 1,000 characters.
exclusive_ingredientsstring | string[]Optional. Restrict ingredients to the supplied non-empty list; joined length at most 1,000 characters.
compound_filtersobject[]Optional. Each entry requires compound (case-insensitive name) or positive integer compound_id, operator (<= or >=), finite numeric threshold and unit. When both identifiers are supplied, they must name the same compound. Use kcal for Energy (7744), g or mg for other compounds. Recipes require scope: portion; plans accept portion or day, with portion as the default.
daily_energy_kcal_minnumberOptional positive daily minimum in kcal. Requires daily_energy_kcal_max and must not exceed it. For a recipe, meal_type and meal_energy_distribution are also required.
daily_energy_kcal_maxnumberOptional positive daily maximum in kcal. Requires daily_energy_kcal_min and must not be below it. For a recipe, meal_type and meal_energy_distribution are also required.
meal_energy_distributionobject[]Optional only with the daily energy pair. Entries use meal_type and a positive share: up to 1 is a fraction (0.3 = 30%, 1 = 100%); above 1 is a percentage (30 = 30%), at most 100. Zero is invalid. A recipe needs exactly one entry matching meal_type. A plan allows up to four distinct active meal types; normalized shares must total at most 1, or exactly 1 when every active type is specified.
Supported conditions 14
  • calorie_restriction_level_1
  • calorie_restriction_level_2
  • calorie_restriction_level_3
  • calorie_restriction_level_4
  • fructose_restriction_low
  • fructose_restriction_moderate
  • fructose_restriction_strict
  • gluten_restriction
  • histamine_restriction_moderate
  • histamine_restriction_strict
  • lactose_restriction_moderate
  • lactose_restriction_strict
  • sodium_restriction_moderate
  • sodium_restriction_strict

Use only one calorie restriction level at a time and supply both daily energy bounds for it. Condition names select nutrition constraints; they are not diagnoses or a guarantee of suitability.

Request examples

Text request

{
  "input_mode": "unstructured",
  "type": "recipe",
  "request_text": "Create two vegetarian high-protein dinners with no peanuts."
}

Structured recipe

{
  "input_mode": "structured",
  "type": "recipe",
  "recipe_count": 2,
  "meal_type": "dinner",
  "diet": "vegetarian",
  "excluded_allergens": [
    "peanuts"
  ],
  "max_total_time_min": 30,
  "include_nutrient_analysis": true
}

Structured meal plan

{
  "input_mode": "structured",
  "type": "meal_plan",
  "plan_days": 3,
  "meals_per_day": {
    "breakfast": 1,
    "lunch": 1,
    "dinner": 1
  },
  "diet_pattern": "pescatarian",
  "excluded_allergens": [
    "peanuts"
  ]
}

Submit and poll a job

POST returns HTTP 202 with job_id and status_url. GET that URL with the same key and version header until completed or failed. A found failed job still returns HTTP 200.

Accepted POST · HTTP 202

{
  "data": {
    "job_id": "d72f91f9-06a4-472f-b718-87c3513e9682",
    "status": "queued",
    "status_url": "<STATUS_URL_FROM_RESPONSE>"
  },
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-09-29"
  }
}

Completed poll · HTTP 200

{
  "data": {
    "job_id": "d72f91f9-06a4-472f-b718-87c3513e9682",
    "status": "completed",
    "result": {
      "recipes": [
        {
          "title": "Chickpea and spinach skillet",
          "prep_time_min": 10,
          "cook_time_min": 15,
          "total_time_min": 25,
          "difficulty": "easy",
          "ingredients": [
            {
              "name": "chickpeas",
              "quantity": 150,
              "unit": "g"
            },
            {
              "name": "spinach",
              "quantity": 80,
              "unit": "g"
            }
          ],
          "steps": [
            "Cook the ingredients until tender."
          ]
        }
      ]
    },
    "error": null
  },
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-09-29"
  }
}

Poll with cURL

Save the returned status_url as STATUS_URL.

curl "$STATUS_URL" \
  -H "x-api-key: $MYMOLECULES_API_KEY" \
  -H "mymolecules-api-version: 2026-09-29"
  • Wait a few seconds between polls and set your own maximum waiting time. queued and processing are not final states; data.error stays null while the job is running.
  • If you reach your waiting limit, save job_id and check the same job later rather than submitting it again. No fixed processing time is guaranteed.
  • Save results you need in your own system. Completed and failed jobs are currently removed more than 30 days after completion; this is not a guaranteed retention period. Image links can expire sooner: check image.expires_at and poll again for a fresh link while the job is available.

Job response fields

FieldTypeDescription
data.job_idstringUUID identifying the job. Save it or the status_url returned by POST.
data.statusstringqueued, processing, completed or failed. A found job returns HTTP 200 even when status is failed.
data.status_urlstringPOST only. URL to GET with the same API key and version header.
data.resultobject | nullGET only. Present when completed; otherwise null.
data.errorobject | nullGET only. Job failure code and message when failed; otherwise null.
meta.request_idstringRequest identifier for logs and support.
meta.api_versionstring2026-09-29 for this contract.
meta.callback_registeredbooleanPOST only when a callback_url was accepted; true means completion delivery was registered.

Result fields

Fields inside data.result.

FieldTypeDescription
recipesobject[]Recipe jobs only. Contains exactly recipe_count recipes on success.
meal_planobjectMeal-plan jobs only. Contains the complete plan.
meal_plan.daysobject[]One entry for each requested day, in order.
meal_plan.days[].dayintegerDay number, starting at 1.
meal_plan.days[].mealsobject[]The requested meals for this day.
meal_plan.days[].meals[].meal_typestringbreakfast, lunch, dinner or snack.
meal_plan.days[].meals[].recipeobjectOne-portion recipe with the fields below.

Recipe fields

Fields inside each entry of data.result.recipes[] or data.result.meal_plan.days[].meals[].recipe.

  • Design currently returns recipe titles, ingredients and instructions in German. Each recipe is one portion, including recipes within a meal plan.
  • Nutrient values for newly generated recipes are estimates, not measured food composition. Values are per recipe portion: energy in kcal, carbohydrates, fat and protein in mg.
FieldTypeDescription
titlestringRecipe title.
prep_time_minnumberPreparation time in minutes.
cook_time_minnumberCooking time in minutes.
total_time_minnumberTotal preparation and cooking time in minutes.
difficultystringeasy, medium or hard.
ingredientsobject[]Ingredients and amounts for one recipe portion.
ingredients[].namestringIngredient name.
ingredients[].quantitynumberIngredient amount in the supplied unit.
ingredients[].unitstringDisplay unit, such as g or ml.
stepsstring[]Preparation instructions in order.
nutrient_analysisobjectPresent when include_nutrient_analysis is true. Values describe one recipe portion.
nutrient_analysis.energyobjectEnergy in kcal.
nutrient_analysis.energy.namestringNutrient display name.
nutrient_analysis.energy.valuenumberAmount per recipe portion.
nutrient_analysis.energy.unitstringkcal.
nutrient_analysis.carbohydratesobjectCarbohydrates in mg.
nutrient_analysis.carbohydrates.namestringNutrient display name.
nutrient_analysis.carbohydrates.valuenumberAmount per recipe portion.
nutrient_analysis.carbohydrates.unitstringmg (not g).
nutrient_analysis.fatobjectFat in mg.
nutrient_analysis.fat.namestringNutrient display name.
nutrient_analysis.fat.valuenumberAmount per recipe portion.
nutrient_analysis.fat.unitstringmg (not g).
nutrient_analysis.proteinobjectProtein in mg.
nutrient_analysis.protein.namestringNutrient display name.
nutrient_analysis.protein.valuenumberAmount per recipe portion.
nutrient_analysis.protein.unitstringmg (not g).
imageobjectPresent when image_delivery is signed_url.
image.deliverystringsigned_url.
image.mime_typestringImage MIME type.
image.widthintegerImage width in pixels.
image.heightintegerImage height in pixels.
image.urlstringsigned_url only. Temporary URL for downloading the image.
image.expires_atstringsigned_url only. URL expiry as an ISO 8601 timestamp; this is not the job expiry.

Completion callbacks

Contact us to enable callbacks for your API key, register your HTTPS endpoint and obtain a separate callback signing secret. This secret is not your API key; keep both server-side.

If callbacks are enabled for your API key, send its configured HTTPS callback_url. The accepted POST then contains meta.callback_registered: true. Design POSTs an event when the job completes or fails. Return any 2xx response to acknowledge it; delivery is attempted up to eight times total. Deduplicate by delivery_id, then GET status_url with the same API key for the result.

Callback body

{
  "event": "job_done",
  "job_id": "d72f91f9-06a4-472f-b718-87c3513e9682",
  "status": "completed",
  "status_url": "https://api.mymolecules.de/functions/v1/design?job_id=d72f91f9-06a4-472f-b718-87c3513e9682",
  "occurred_at": "2026-10-01T10:00:00Z",
  "delivery_id": "<DELIVERY_ID>"
}

X-Design-Event is job_done; X-Design-Delivery-Id matches delivery_id. X-Design-Signature has the form t=<Unix seconds>,v1=<hex HMAC-SHA256>. Verify the HMAC-SHA256 signature over the exact UTF-8 bytes of the timestamp, a dot and the raw request body. Verify before parsing or processing the event and reject stale timestamps.

Verify the signature (Node.js)

import { createHmac, timingSafeEqual } from 'node:crypto'

// rawBody is the exact request body received by your HTTPS handler.
const signatureHeader = request.headers['x-design-signature']
const match = /^t=(\d+),v1=([a-f0-9]{64})$/.exec(signatureHeader ?? '')
if (!match) throw new Error('Invalid signature header')
const [, timestamp, suppliedHex] = match
const expected = createHmac('sha256', process.env.DESIGN_CALLBACK_SECRET)
  .update(timestamp + '.' + rawBody).digest()
const supplied = Buffer.from(suppliedHex, 'hex')
if (!timingSafeEqual(expected, supplied)) throw new Error('Invalid signature')
// Also reject timestamps outside your permitted clock-skew window.
// Deduplicate on delivery_id, then GET status_url with your Design API key.

Handle errors

If a request fails, check error.code. Polling a found failed job still returns HTTP 200: check data.status and read data.error when it is failed.

Request errors

CodeHTTP statusDescription
invalid_request400 or 405Correct missing, unsupported or conflicting fields, invalid JSON or an invalid callback URL; then submit again.
unsupported_api_version400Use a version listed in the version selector.
idempotency_conflict409This Idempotency-Key was already used for a different request. Retry the original request unchanged, or use a new key for a new job.
unauthorized401 or 403Supply an active x-api-key with Design access. Use the same key when polling. For callback requests, confirm callbacks are enabled for the key.
design_input_mode_not_allowed403Your API key does not allow the selected input mode. Use an allowed mode or contact us to change the key’s permissions. No job is created. Existing jobs can still be polled with the same key.
quota_exceeded429Your key’s quota does not allow this request. Wait for the quota to reset or contact us; repeated retries will not help.
service_busy429Temporary capacity limit. Retry after the indicated delay, if supplied.
job_creation_failed503The job could not be started. Follow the safe POST retry guidance below; contact support with the request ID if it persists.
job_not_found404Check the ID and use the same API key. The job may have expired; see the result availability note above.
technical_generation_error500/503Generation, result retrieval or callback configuration failed. Retry a job only if the cause is transient; contact support with the request ID for persistent failures.

Job errors

CodeHTTP statusDescription
invalid_request200 (failed job)Correct missing, unsupported or conflicting fields, invalid JSON or an invalid callback URL; then submit again.
quota_exceeded200 (failed job)Your key’s quota does not allow this request. Wait for the quota to reset or contact us; repeated retries will not help.
no_recipe_found200 (failed job)Job failure: a complete set of matching recipes could not be produced. Relax constraints or reduce recipe_count.
no_meal_plan_found200 (failed job)Job failure: a complete plan could not be produced. Relax constraints or request fewer meals.
job_deadline_exceeded200 (failed job)Job failure: the plan did not finish in time. Submit a smaller or less restrictive request.
conflicting_requirements200 (failed job)Job failure: text and voice specified conflicting requirements. Resolve them and resubmit.
voice_transcription_empty200 (failed job)Job failure: the recording did not contain understandable speech. Re-record or send text.
invalid_normalized_request200 (failed job)Job failure: interpreted requirements were incomplete or invalid. State the missing details explicitly.
technical_generation_error200 (failed job)Generation, result retrieval or callback configuration failed. Retry a job only if the cause is transient; contact support with the request ID for persistent failures.

Retry safely

  • GET: retry polling after a network error or temporary server failure, with increasing delays. Follow Retry-After when supplied.
  • POST: send an optional Idempotency-Key to avoid duplicate jobs if the response is lost. Generate a unique key for each new request, save it with the request and reuse it only with the same API key, body and version when retrying. Use 1–128 printable ASCII characters without spaces.
  • Repeating that request returns HTTP 202 with the existing job_id and status_url; it does not restart the job. Poll for its current status. Reusing the key for a different request returns HTTP 409 (idempotency_conflict). Use a new key when you intentionally create a new job, including after a failed job.
  • Without Idempotency-Key, another POST can create another job. x-request-id does not prevent duplicates. Do not retry blindly when it is unclear whether your request was accepted.

See the Errors & rate limits guide for the shared error envelope.

Code examples

curl -X POST 'https://api.mymolecules.de/functions/v1/design' \
  -H "x-api-key: $MYMOLECULES_API_KEY" \
  -H 'mymolecules-api-version: 2026-09-29' \
  -H 'Content-Type: application/json' \
  --data '{
  "input_mode": "unstructured",
  "type": "recipe",
  "request_text": "Create a high-protein vegetarian dinner without peanuts"
}'

Use the examples on your server and set MYMOLECULES_API_KEY in its environment. Python requires the requests package (pip install requests). Set network timeouts in your application.

For generated types and every response schema, use the OpenAPI specification.