Core API

Draft API

Available

Draft takes an existing recipe or meal idea and creates controlled substitutions or edits while respecting preferences, restrictions and sensory goals.

Endpoint

POST/functions/v1/draft

Contract

Send mymolecules-api-version with 2026-07-10 to use the documented response contract.

{
  "data": {},
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-07-10"
  }
}

Headers

Request

  • x-api-key required - Server-side API key for your integration.
  • mymolecules-api-version required 2026-07-10 - Use the latest stable API version: 2026-07-10.
  • Content-Type required application/json - Required for JSON request bodies.

Response

  • x-request-id required - Request identifier. Log this value when contacting support.
  • mymolecules-api-version required 2026-07-10 - The API contract version used for the response.
  • x-ratelimit-limit optional - Quota limit for the current key and window when quota data is available.
  • x-ratelimit-remaining optional - Remaining requests in the current quota window when quota data is available.
  • x-ratelimit-reset optional - ISO timestamp for the current quota window reset when quota data is available.
  • retry-after optional - Seconds to wait before retrying when the request is rate-limited or temporarily unavailable.

Inputs

  • One hybrid request with optional request_text and structured controls
  • For a complete structured source, recipe_title and ingredients; steps are optional
  • Without a complete structured source, request_text must describe the source recipe
  • Optional preferences, restrictions and compound filters

Returns

  • 202 queued response with job_id and status_url
  • Completed result with recipe diffs, substitutions and warnings
  • Optional final-recipe image when requested
  • Validation issues when the source recipe or constraints are incomplete

Async pattern

Create the job with POST, then poll the same endpoint with job_id until the status is completed or failed.

  • Poll parameter: job_id
  • Status values: queued, processing, completed, failed

Error codes

  • missing_api_key
  • invalid_api_key
  • scope_not_allowed
  • quota_exceeded
  • invalid_json
  • invalid_request
  • validation_error
  • method_not_allowed
  • unsupported_api_version
  • job_not_found
  • backlog_high
  • upstream_timeout
  • upstream_error
  • internal_error

Request details

  • request_text contains the complete free-form source context and requested changes.
  • Structured fields such as ingredients, steps, diet, condition and avoided_foods override conflicting request text.
  • steps and cooking_steps are accepted aliases; avoided_foods is the canonical public field.
  • image_delivery can be base64, signed_url or none. Omit it when images are not needed.

Response details

  • Poll GET /functions/v1/draft?job_id=... until status is completed or failed.
  • Completed results normalize the generated draft before returning it.
  • Image failures never fail the recipe; meta.image_status becomes failed and meta.warnings includes image_generation_failed.
  • The meta object includes attempts and job timestamps when available.

Operational notes

  • Requires x-api-key with the edge:draft scope.
  • POST usage is counted and rate-limit headers are returned when quota data is available.

Examples

Request JSON

{
  "request_text": "Make this tomato pasta higher protein and lactose-free.",
  "recipe_title": "Tomato pasta",
  "ingredients": ["pasta", "tomato sauce", "parmesan"],
  "steps": ["Cook pasta", "Warm sauce", "Serve with parmesan"],
  "language": "English"
}

Response JSON

{
  "data": {
    "job_id": "f13e52...",
    "status": "queued",
    "status_url": "https://api.mymolecules.de/functions/v1/draft?job_id=f13e52..."
  },
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-07-10"
  }
}

Code examples

curl -X POST 'https://api.mymolecules.de/functions/v1/draft' \
  -H 'x-api-key: $MYMOLECULES_API_KEY' \
  -H 'mymolecules-api-version: 2026-07-10' \
  -H 'Content-Type: application/json' \
  --data '{  "request_text": "Make this tomato pasta higher protein and lactose-free.",  "recipe_title": "Tomato pasta",  "ingredients": ["pasta", "tomato sauce", "parmesan"],  "steps": ["Cook pasta", "Warm sauce", "Serve with parmesan"],  "language": "English"}'