Skip to main content

Integration workflows

The paths on this page are relative to /api/v1/workspaces/{workspaceId}. All the shell examples use cm_api, workspace_api and cocktail_id from the quickstart. Use a test workspace: the queue example creates a real order and a real statistic.

Send an order to the bar and record it as made​

Use a dedicated key with COCKTAILS_READ, QUEUE_CREATE, QUEUE_READ, QUEUE_UPDATE, QUEUE_DELETE and STATISTICS_CREATE for the complete flow below. Omit QUEUE_DELETE if the client never cancels a queued item. For a multi-client setup, grant each client only the steps it performs. Add STATISTICS_READ only if the client also needs to read the statistic logs.

StepRequestPermission
Find a recipe and read its detailsGET /cocktails, GET /cocktails/{cocktailId}COCKTAILS_READ
Add itemsPOST /queue/addQUEUE_CREATE
Read the bar queueGET /queueQUEUE_READ
Mark one item in progressPUT /queue/{queueItemId}QUEUE_UPDATE
Record one preparation and reconcile the queuePOST /statistics/cocktails/addSTATISTICS_CREATE
Cancel a queued item without logging it as madePOST /queue/removeQUEUE_DELETE

Use the recipe id from the list or detail read. For this example, choose a note unique to the test order. Add returns an array of items in data even when amount is one. Each item has its own id, a cocktail reference with id and name, nullable notes, inProgress, and createdAt.

note='Integration test order 01' # Change for each test order
order_body=$(jq -nc --arg id "$cocktail_id" --arg note "$note" \
'{cocktailId: $id, notes: $note, amount: 1}')
order=$(cm_api "$workspace_api/queue/add" \
--header 'Content-Type: application/json' --data-binary "$order_body")
queue_item_id=$(jq -er '.data[0].id | select(type == "string")' <<<"$order")

Run the steps in order and stop if any command fails. amount defaults to one and accepts an integer from 1 to 50; notes are limited to 500 characters. Add and remove trim notes and treat blank or "-" as no note.

Read the queue to confirm the order, then update the queue item ID, not the recipe ID:

cm_api "$workspace_api/queue" |
jq -e --arg id "$queue_item_id" '.data[] | select(.id == $id)'

cm_api --request PUT "$workspace_api/queue/$queue_item_id" \
--header 'Content-Type: application/json' \
--data-binary '{"inProgress":true}' | jq -e '.data'

When the drink is actually made, log it using the exact stored note:

made_body=$(jq -nc --arg id "$cocktail_id" --arg note "$note" \
'{cocktailId: $id, notes: $note, actionSource: "integration-test"}')
cm_api "$workspace_api/statistics/cocktails/add" \
--header 'Content-Type: application/json' --data-binary "$made_body" |
jq -e '.data | {id, date, cocktail, actionSource}'

The statistic write and queue reconciliation are in one transaction. Completion matches the oldest queue item with that cocktail and note; it does not accept a queue item ID and does not prioritize inProgress. With notes: "-", it targets an item with no note. Without a note selector, if noted items for that cocktail exist, the server reports 400 STATISTIC_QUEUE_AMBIGUOUS rather than choosing one for you. A statistic can still be recorded if there is no matching item, so a successful statistic response is not proof that a specific order was removed. ignoreQueue: true deliberately records a statistic without changing the queue. Check GET /queue after completion if you need to confirm removal.

For a cancellation, use POST /queue/remove with {"cocktailId":"…","notes":"…"} instead. It removes the oldest matching item, returns it in data, and returns 404 if none matches. It does not log a preparation. Do not call both remove and log for the same preparation as a routine completion flow: that can consume two items.

Add, remove and log are not idempotent. If a request times out, reconcile against the queue and any accessible statistic logs instead of replaying it blindly. Keep your own order correlation and deduplication state; queue notes are not an API idempotency key.

Move selected recipes to another workspace​

Use recipe export when you need specific recipes and their dependencies, not a snapshot of the whole workspace. Use separate keys for source and destination; don't send a source key to the destination.

  1. With COCKTAILS_READ in the source, send POST /cocktails/export/json with {"cocktailIds":["…"]}. Save the raw JSON response as-is; it includes referenced inventory and embedded images. A list/detail data response is not an import file.
  2. On the destination, use the app's Manage → Cocktails → Import/Export tools to import the file and review proposed matches, or call POST /cocktails/import/json with COCKTAILS_CREATE. Send the saved dump as exportData and set phase to validate, then prepare-mapping. validate checks the file; prepare-mapping compares it with the destination workspace. Neither phase writes. For validate, check the raw response's valid flag as well as the HTTP status.
  3. Review the destination's proposed autoMappings and cocktailConflicts. Send phase: "execute" with the same exportData and the reviewed mappingDecisions. Each dependency decision identifies the original exportId and either a destination existingId (use-existing) or create-new. Cocktail decisions are import, skip, rename (with newName), or overwrite (with a destination overwriteId). Include decisions for the referenced dependencies and, to import every exported cocktail, a decision for each exported cocktail. The destination workspace key also needs COCKTAILS_UPDATE for overwrite. Inspect the raw result and any warnings, then reread the destination recipes to check the result.

Review mappings in the app if in doubt. An overwrite changes the target recipe, not the source, and an import can create new IDs; refresh local ID mappings afterward. For printable output, POST /cocktails/export/pdf accepts selected cocktailIds and returns a PDF rather than an importable file. PDF export requires the configured Chromium service.

For broader content moves and recovery, see Backups, imports and restore and Workspace backup automation.