Endpoint
POST
/functions/v1/decodeContract
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
- input_mode: unstructured, structured or decode_id
- Unstructured input with foodText, foodImage, foodVoice, foodImageRemaining or attachments; media fields accept data URLs or HTTP(S) URLs
- Structured input with a non-empty items array
- decode_id input with decode_food_id
Returns
- 202 queued response with job_id and status_url
- Status response with queued, processing, completed or failed
- Completed food_detected result with recognized foods, reusable decode_food_id values and molecular measurements
- Completed no_food_detected result with an empty items array when the input contains no food
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
- Use exactly one input mode. Do not mix decode_food_id with food text, images, voice or structured items.
- Describe textual remaining information in foodText. Use foodImageRemaining only for a separate photo of what remained.
- Optional compound_identifier_names or compound_identifier_ids can narrow molecular output to selected compounds.
- Set include_compound_identifier_value or include_measurement_min_max only when those additional fields are needed.
Response details
- Poll GET /functions/v1/decode?job_id=... until status is completed or failed.
- Status polling returns result when available and error when a job fails.
- Every completed result has type: food_detected or type: no_food_detected. No-food is a completed domain result, not a failed job.
- no_food_detected always returns items: [] and error: null.
- Molecular measurements include measurement_unit and matrix_unit; matrix_unit is an array because an aggregated result can use more than one food basis.
- Use include_result=false or result=none on status requests when you only need the job state.
Operational notes
- Requires x-api-key with the edge:decode scope.
- POST usage is counted and rate-limit headers are returned when quota data is available.
- Large media payloads should be sent only when needed; URLs or attachments are preferable for repeated workflows.
Examples
Request JSON
{
"input_mode": "unstructured",
"foodText": "Greek yogurt with blueberries, walnuts and honey"
}Response JSON
{
"data": {
"job_id": "8a93f4...",
"status": "queued",
"status_url": "https://api.mymolecules.de/functions/v1/decode?job_id=8a93f4..."
},
"meta": {
"request_id": "req_...",
"api_version": "2026-07-10"
}
}Code examples
curl -X POST 'https://api.mymolecules.de/functions/v1/decode' \
-H 'x-api-key: $MYMOLECULES_API_KEY' \
-H 'mymolecules-api-version: 2026-07-10' \
-H 'Content-Type: application/json' \
--data '{ "input_mode": "unstructured", "foodText": "Greek yogurt with blueberries, walnuts and honey"}'


