How a device receives a cookbook sync from Things5: the request, the two ways to get the recipes, and the answer.
A cookbook is a set of recipe templates prepared in Things5 for a machine model; a cookbook sync sends it to devices of that model. If you are new to these terms, start from the guide Cookbooks and recipe templates.
When a user sends a cookbook to a device, Things5 asks the device to replace its recipes with the recipe templates of that cookbook. Things5 only sends the request and makes the recipes available: writing them on the machine is up to the device, which then tells Things5 how it went. This page describes the device side of a sync: which messages arrive, how the device gets the recipes and how it answers.

One sync, several topics
A single sync uses several MQTT topics. This is expected:
- Things5 sends the command
cmd/sync_recipe_templates_v2_req, with the id of the sync and a link (manifest_url) to the cookbook files. - The device gets the recipes in one of two ways: over HTTPS from the links, or with an MQTT pull: one request/response pair for the manifest and one per recipe, on the
req/topics. - The device answers once on
cmd/sync_recipe_templates_res.
So in the MQTT log of a device that uses the MQTT pull you see, for a cookbook of 3 recipes: the command from Things5, 1 manifest request and its answer, 3 recipe requests and their answers, and the final answer of the device: 10 messages. See A real sync, message by message.
| Topic | Direction | Used by |
|---|---|---|
things5-production/v1/devices/{device_id}/cmd/sync_recipe_templates_v2_req | Things5 → device | HTTPS and MQTT pull |
things5-production/v1/devices/{device_id}/req/get_sync_manifest_req | Device → Things5 | MQTT pull |
things5-production/v1/devices/{device_id}/req/get_sync_manifest_res | Things5 → device | MQTT pull |
things5-production/v1/devices/{device_id}/req/get_sync_recipe_req | Device → Things5 | MQTT pull |
things5-production/v1/devices/{device_id}/req/get_sync_recipe_res | Things5 → device | MQTT pull |
things5-production/v1/devices/{device_id}/cmd/sync_recipe_templates_res | Device → Things5 | HTTPS and MQTT pull |
Which transport to choose
| HTTPS download | MQTT pull | |
|---|---|---|
| Status | Standard, recommended | Alternative |
| The device needs | an HTTPS client (TLS, trusted CA certificates) | only the MQTT connection it already has |
| Cookbook size | any | any, but one round trip per recipe: best for small and medium cookbooks |
| Memory on the device | one file at a time | one recipe at a time |
Skip unchanged recipes (hash) | yes | yes |
| Speed | fastest (downloads can run in parallel) | one request at a time |
No configuration is needed on Things5: the device decides at every sync which transport to use. The content is the same either way: same recipes, same order (index), the same JSON byte for byte with the same hash.
When a cookbook is sent to many devices, Things5 sends the command to a few devices at a time and moves on when a device answers. Answer on cmd/sync_recipe_templates_res as soon as the sync is done or has failed.
Things5 → device: cmd/sync_recipe_templates_v2_req
cmd/sync_recipe_templates_v2_reqThis command asks the device to replace all its recipes with the recipe templates of the cookbook. How the recipes are written on the machine is up to the device: Things5 only waits for its answer.
things5-production/v1/devices/<device-id>/cmd/sync_recipe_templates_v2_req
Payload
{
"request_id": "4f0437f1-d038-4a54-96e6-f353caa1223e",
"cookbook_sync_log_id": "3980d532-3174-4c03-8ab9-eee7a87b7ad6",
"manifest_url": "https://downloads.example.com/cookbook-syncs/182683fe-44d5-4315-b9ee-65d6e89d05bf/manifest.json?X-Amz-Algorithm=...&X-Amz-Signature=...",
"expires_at": 1795089000000
}
Payload Parameters
| name | description |
|---|---|
| request_id | id of this command: send it back in cmd/sync_recipe_templates_res |
| cookbook_sync_log_id | id of this sync on this device: send it back in the answer and use it in the MQTT pull requests |
| manifest_url | pre-signed HTTPS URL of the manifest (HTTPS transport only) |
| expires_at | Unix time in milliseconds after which manifest_url and the recipe URLs no longer work (HTTPS transport only) |
Transport 1 (standard): HTTPS download

- Download the manifest from
manifest_urlwith a plain HTTPSGET. The URL is pre-signed: send it exactly as received, with no extra headers or credentials. - For each entry of
recipes[], comparehashwith the recipe already on the device and downloadurlonly when it changed (see Skipping unchanged recipes). - Replace the recipes on the machine.
- Answer on
cmd/sync_recipe_templates_res.
Download before
expires_atThe links stop working at
expires_at. If they expired before the device could download the files, answer with an error: the user can send the sync again from Things5 and the device gets new links.
Manifest
The manifest lists every recipe of the cookbook.
{
"manifest_version": 1,
"cookbook_sync_id": "182683fe-44d5-4315-b9ee-65d6e89d05bf",
"cookbook_metadata": {
"example_key": "example_value"
},
"recipes": [
{
"index": 0,
"id": "ff34e06c-09bd-4b93-8701-96aa82fcfb25",
"hash": "67076c3831e3bb8fe9c9368a8bb0721558f4b0335b51fed9c52a8ba8a7b5bc2c",
"hash_version": 1,
"url": "https://downloads.example.com/cookbook-syncs/182683fe-44d5-4315-b9ee-65d6e89d05bf/recipes/0.json?X-Amz-Signature=..."
}
]
}
| name | description | example |
|---|---|---|
| manifest_version | version of the manifest format | 1 |
| cookbook_sync_id | id of this sync (the same for every device of the sync) | |
| cookbook_metadata | cookbook-level metadata, applied during the sync (arbitrary JSON object defined by the cookbook) | |
| recipes | array of recipe entries, in cookbook order | |
| recipes[].index | position of the recipe in the cookbook | 0 |
| recipes[].id | recipe template id | |
| recipes[].hash | content fingerprint of the recipe (lowercase hex SHA-256) | |
| recipes[].hash_version | algorithm version of hash | 1 |
| recipes[].url | HTTPS URL of the recipe template (not present over MQTT pull) |
Skipping unchanged recipes
hash is a content fingerprint of the recipe. Before downloading a recipe, compare it with the recipe already stored on the device:
- same
hash→ the recipe is unchanged, skip it; - different or missing
hash→ download it; hash_versionthe device does not implement → treat the recipe as changed and download it.
Only name, description, machine_model_id, phases and metadata contribute to the hash: editing who last changed a recipe, or when, does not change it. A device that keeps no hashes simply downloads every recipe.
Recipe template
Each recipe file contains one recipe template of the cookbook.
{
"id": "ff34e06c-09bd-4b93-8701-96aa82fcfb25",
"index": 0,
"name": "Brioche",
"description": "Recipe description",
"machine_model_id": "0f7b403b-1748-437a-9cf7-3f79abd33083",
"hash": "67076c3831e3bb8fe9c9368a8bb0721558f4b0335b51fed9c52a8ba8a7b5bc2c",
"hash_version": 1,
"phases": [
{
"dosages": [
[
{
"name": "yeast",
"quantity": "5.5",
"metadata": [
{ "name": "type", "value": "1", "type": "integer" }
]
}
]
],
"values": [
{ "name": "cell_temperature", "value": "260", "type": "integer" },
{ "name": "time", "value": "90", "type": "integer" }
]
}
],
"metadata": [
{ "name": "image_path", "value": "../images/brioche.jpg", "type": "string" }
]
}
| name | description | example |
|---|---|---|
| id | recipe template id | |
| index | position of the recipe in the cookbook | 0 |
| name | recipe name | Brioche |
| description | recipe description | |
| machine_model_id | machine model the recipe targets | |
| hash | content fingerprint (lowercase hex SHA-256) | |
| hash_version | algorithm version of hash | 1 |
| phases | the program: for each phase, values (name, value, type) and optional dosages | |
| metadata | arbitrary recipe metadata (name, value, type) |
Transport 2 (alternative): MQTT pull
For constrained devices without an HTTPS client, or without the memory to hold the manifest and its recipes. The device ignores manifest_url and expires_at and asks Things5 for the manifest and then for each recipe it needs, over the MQTT connection it already has.

The requests use the device-initiated req/ topics: the device chooses a new request_id for every request, and Things5 answers on the matching _res topic with the same request_id.
One request at a time
Send the next request only after the answer to the previous one. A request sent while another request of the same device is still waiting for its answer gets the
busyerror. If no answer arrives within 15 seconds, send the request again with a newrequest_id(within those 15 seconds a lost request still counts as in flight, so an early retry getsbusy).
Device → Things5: req/get_sync_manifest_req
req/get_sync_manifest_reqthings5-production/v1/devices/<device-id>/req/get_sync_manifest_req
{
"request_id": "238c53bd-03ef-4e42-b8af-fef3aefbf2cb",
"cookbook_sync_log_id": "3980d532-3174-4c03-8ab9-eee7a87b7ad6"
}
| name | description |
|---|---|
| request_id | chosen by the device, sent back in the answer |
| cookbook_sync_log_id | the cookbook_sync_log_id of cmd/sync_recipe_templates_v2_req |
Things5 → device: req/get_sync_manifest_res
req/get_sync_manifest_resthings5-production/v1/devices/<device-id>/req/get_sync_manifest_res
{
"request_id": "238c53bd-03ef-4e42-b8af-fef3aefbf2cb",
"cookbook_sync_log_id": "3980d532-3174-4c03-8ab9-eee7a87b7ad6",
"errors": [],
"manifest": {
"manifest_version": 1,
"cookbook_sync_id": "182683fe-44d5-4315-b9ee-65d6e89d05bf",
"cookbook_metadata": {},
"recipes": [
{ "index": 0, "id": "ff34e06c-09bd-4b93-8701-96aa82fcfb25", "hash": "67076c3831e3bb8fe9c9368a8bb0721558f4b0335b51fed9c52a8ba8a7b5bc2c", "hash_version": 1 },
{ "index": 1, "id": "4ce79aab-88b4-4a7e-97e3-7dbe7423fbf0", "hash": "269525538c16cfe0f946300081b56f5a6365e4ecd7c73ff89067c5b748aae46b", "hash_version": 1 },
{ "index": 2, "id": "e041ef0b-547f-4d53-9f22-07c53cb83561", "hash": "b40b8b340c4eb352159233da0c5ae1177396c7440720ff8c01ce704a17b91621", "hash_version": 1 }
]
}
}
manifest is the manifest without recipes[].url. It is missing when errors is not empty.
Device → Things5: req/get_sync_recipe_req
req/get_sync_recipe_reqthings5-production/v1/devices/<device-id>/req/get_sync_recipe_req
{
"request_id": "e9275c0f-8e73-4508-b900-ed4391ab52e2",
"cookbook_sync_log_id": "3980d532-3174-4c03-8ab9-eee7a87b7ad6",
"index": 0
}
| name | description |
|---|---|
| request_id | chosen by the device, sent back in the answer |
| cookbook_sync_log_id | as above |
| index | recipes[].index of the recipe in the manifest |
As over HTTPS, the device can compare hash with the recipe it already has and skip the request for unchanged recipes.
Things5 → device: req/get_sync_recipe_res
req/get_sync_recipe_resthings5-production/v1/devices/<device-id>/req/get_sync_recipe_res
{
"request_id": "e9275c0f-8e73-4508-b900-ed4391ab52e2",
"cookbook_sync_log_id": "3980d532-3174-4c03-8ab9-eee7a87b7ad6",
"index": 0,
"errors": [],
"recipe": {
"id": "ff34e06c-09bd-4b93-8701-96aa82fcfb25",
"index": 0,
"name": "Brioche",
"description": "Recipe description",
"machine_model_id": "0f7b403b-1748-437a-9cf7-3f79abd33083",
"hash": "67076c3831e3bb8fe9c9368a8bb0721558f4b0335b51fed9c52a8ba8a7b5bc2c",
"hash_version": 1,
"phases": [
{
"dosages": [],
"values": [
{ "name": "cell_temperature", "type": "integer", "value": "260" },
{ "name": "time", "type": "integer", "value": "90" }
]
}
],
"metadata": [
{ "name": "image_path", "type": "string", "value": "../images/brioche.jpg" }
]
}
}
recipe is the recipe template, identical to the file of the HTTPS transport. It is missing when errors is not empty.
Errors
| error | meaning | what to do |
|---|---|---|
busy | another request of this device is still waiting for its answer | wait for that answer (or 15 seconds), then retry |
invalid_request | request_id, cookbook_sync_log_id or index missing or not valid | fix the request |
sync_not_found | unknown cookbook_sync_log_id, or one of another device | stop: answer the sync with an error |
sync_closed | the sync was already answered or cancelled | stop: nothing to do |
sync_expired | the sync was sent more than 24 hours ago | stop: answer the sync with an error |
index_not_found | no recipe with this index in the cookbook | check the index against the manifest |
too_large | the answer does not fit in one MQTT message | stop: answer the sync with an error; use HTTPS for this cookbook |
internal | error on the Things5 side | retry later |
Timing
- The device can pull a sync for 24 hours after Things5 sent it; after that every request gets
sync_expired. - Each request counts as activity on the sync. If a device makes no requests and does not answer for 3 minutes, Things5 stops waiting for it and moves on to the next devices of the same sync; the sync stays open on the device, and a later answer still completes it.
When the device has every recipe it needs, it answers the sync as usual.
Device → Things5: cmd/sync_recipe_templates_res
cmd/sync_recipe_templates_resPublish on this topic once, when the sync is done or has failed, whatever transport the device used.
things5-production/v1/devices/<device-id>/cmd/sync_recipe_templates_res
{
"request_id": "4f0437f1-d038-4a54-96e6-f353caa1223e",
"cookbook_sync_log_id": "3980d532-3174-4c03-8ab9-eee7a87b7ad6",
"errors": [],
"synced_at": 1795086266936
}
| name | description |
|---|---|
| request_id | the request_id of cmd/sync_recipe_templates_v2_req |
| cookbook_sync_log_id | the same cookbook_sync_log_id sent in the command |
| errors | empty when the sync succeeded; otherwise one or more error messages. The first one is shown to the user as the result of the sync on this device |
| synced_at | Unix time in milliseconds when the recipes were written |
A real sync, message by message
The messages of a sync of a 3-recipe cookbook to a device that uses the MQTT pull, as they appear in the device's MQTT log in Things5 (payloads shortened, topic prefix …/v1/devices/{device_id}/ omitted). The whole sync took about 1.5 seconds.
| # | Topic | Direction | Payload |
|---|---|---|---|
| 1 | cmd/sync_recipe_templates_v2_req | Things5 → device | request_id: "4f0437f1…", cookbook_sync_log_id: "3980d532…", manifest_url, expires_at |
| 2 | req/get_sync_manifest_req | Device → Things5 | request_id: "238c53bd…", cookbook_sync_log_id: "3980d532…" |
| 3 | req/get_sync_manifest_res | Things5 → device | request_id: "238c53bd…", manifest: {recipes: [index 0, 1, 2]}, errors: [] |
| 4 | req/get_sync_recipe_req | Device → Things5 | request_id: "e9275c0f…", index: 0 |
| 5 | req/get_sync_recipe_res | Things5 → device | request_id: "e9275c0f…", index: 0, recipe: {…}, errors: [] |
| 6 | req/get_sync_recipe_req | Device → Things5 | request_id: "209c75f3…", index: 1 |
| 7 | req/get_sync_recipe_res | Things5 → device | request_id: "209c75f3…", index: 1, recipe: {…}, errors: [] |
| 8 | req/get_sync_recipe_req | Device → Things5 | request_id: "00179b94…", index: 2 |
| 9 | req/get_sync_recipe_res | Things5 → device | request_id: "00179b94…", index: 2, recipe: {…}, errors: [] |
| 10 | cmd/sync_recipe_templates_res | Device → Things5 | request_id: "4f0437f1…" (the command), cookbook_sync_log_id: "3980d532…", errors: [], synced_at |
Reading the MQTT log
The MQTT log shows messages in the order Things5 received or sent them, which can differ by a few milliseconds from the order on the device: an answer may appear just before its request, or the final answer before the last recipe answer. Match requests and answers by
request_id.
A device that uses HTTPS shows only messages 1 and 10: the downloads do not go through MQTT.
