Endpoint
POST
/functions/v1/draftContract
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-keyrequired - Server-side API key for your integration.mymolecules-api-versionrequired2026-07-10- Use the latest stable API version: 2026-07-10.Content-Typerequiredapplication/json- Required for JSON request bodies.
Response
x-request-idrequired - Request identifier. Log this value when contacting support.mymolecules-api-versionrequired2026-07-10- The API contract version used for the response.x-ratelimit-limitoptional - Quota limit for the current key and window when quota data is available.x-ratelimit-remainingoptional - Remaining requests in the current quota window when quota data is available.x-ratelimit-resetoptional - ISO timestamp for the current quota window reset when quota data is available.retry-afteroptional - 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_keyinvalid_api_keyscope_not_allowedquota_exceededinvalid_jsoninvalid_requestvalidation_errormethod_not_allowedunsupported_api_versionjob_not_foundbacklog_highupstream_timeoutupstream_errorinternal_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"}'


