Integration quickstart
Verify a key, discover its workspace ID, and read a cocktail recipe. These
examples use Bash, curl (7.76 or newer) and jq. Run them against an instance
you control, preferably with a test workspace that has at least one recipe.
1. Set up a read-only key
Follow API keys & permissions and grant only COCKTAILS_READ.
Use the origin of the app where you created the key, not the origin of
this documentation. Replace the reserved example origin below.
base_url='https://cocktails.example.invalid'
set +x # Do not trace commands containing credentials
set -o pipefail
read -r -s -p 'Workspace API key: ' api_key
printf '\n'
cm_api() {
printf 'Authorization: Bearer %s\n' "${api_key:?Enter your workspace API key}" |
curl -q --proto '=https' --silent --show-error --fail-with-body \
--connect-timeout 10 --header @- "$@"
}
This passes the authorization header through standard input rather than
putting the token in your history or in curl's argument list. It doesn't use
cookies or follow redirects. Don't add --verbose or --trace with a real
key. In an application, load the credential from a secret store on the server.
For loopback-only development without TLS, use the instance's HTTP origin and
change the helper's --proto '=https' to --proto '=http,https'. Never send
production credentials over HTTP.
2. Confirm the workspace and permissions
identity=$(cm_api "$base_url/api/v1/me")
jq -e '.data | {workspaceId, workspace, permissions, isMaster}' <<<"$identity"
workspace_id=$(jq -er '
.data
| select(.isMaster == false and (.permissions | index("COCKTAILS_READ") != null))
| .workspaceId | select(type == "string" and length > 0) | @uri
' <<<"$identity")
Stop if a command fails. Confirm the returned workspace name and ID before
using the next examples. A master key has no workspace ID and isn't suitable
for this quickstart. If setting the ID by hand, copy it from the signed-in
app's /workspaces/{workspaceId}/… URL, not a public /m/… link.
3. Read a list, then a recipe
Workspace endpoints generally take the form
/api/v1/workspaces/{workspaceId}/{resource}. Some add a resource ID or an
action segment; check both the path and method in the
API Reference.
workspace_api="$base_url/api/v1/workspaces/$workspace_id"
cocktails=$(cm_api "$workspace_api/cocktails")
jq -e '.data | map({id, name, isArchived})' <<<"$cocktails"
cocktail_id=$(jq -er '[.data[] | select(.isArchived == false)][0].id
| select(type == "string")' <<<"$cocktails")
cm_api "$workspace_api/cocktails/$cocktail_id" |
jq -e '.data | {id, name, steps, hasImage, imageUrl}'
This selects the first unarchived recipe in the response. If there is none, use a different test workspace or add a recipe before continuing. The list returns summaries and can include archived recipes; the detail endpoint returns the recipe data including steps. Treat IDs as opaque and key any local cache by instance, workspace and record ID, not by recipe name.
Use --get with --data-urlencode for query parameters:
cm_api --get "$workspace_api/cocktails" \
--data-urlencode 'search=gin' \
--data-urlencode 'include=garnishes,ingredients' |
jq -e '.data'
search matches names and, for terms of at least three characters, tags
and linked garnishes and ingredients. include adds lightweight references,
not recipe steps. The list returns all matches: it does not take
page, limit or a cursor. Do not build a paging loop around it.
For cocktail images, hasImage tells you whether an image exists and
imageUrl is an app-relative path to its bytes endpoint. Fetch it from the
same app origin with the same read scope. A bare <img> cannot attach an
API key; don't put the token in the URL. For a private integration, fetch
on your backend and apply your own authorization before serving the bytes.
4. Handle responses by endpoint
Most v1 JSON operations return { "data": ... }. Some lists, such as
GET …/statistics/logs and GET …/audit-logs, return
{ "data": [...], "pagination": {...} }. Image and PDF endpoints return
bytes. The selected-cocktail JSON export and import endpoints and the
workspace backup export and import endpoints use their
own raw JSON formats. Use the HTTP status and content type before decoding the
body.
For example, GET …/statistics/logs?page=1&limit=50 requires
STATISTICS_READ, starts at page 1, defaults to 50 items, and allows up
to 200 per page. Inspect pagination.page, pagination.totalPages,
pagination.total (matching rows), and pagination.list_total (rows on this
page). Keep filters and limit fixed as you advance and stop when the
current page reaches totalPages (zero for no matches). This is offset
pagination; page contents can shift as new entries are created. For example,
deduplicate by ID if you collect pages while the workspace is active. Don't
assume the same pagination fields or controls for every endpoint.
Typical JSON errors look like
{"error":{"code":"VALIDATION_ERROR","message":"Invalid request query"}}.
error.issues may provide more detail. Some handlers also send a top-level
message, and the framework or a proxy can return non-JSON errors.
| Status | Start here |
|---|---|
400 | Check the path, query or JSON body and inspect error.code and error.issues. |
401 | Check the URL and Bearer header. Use /api/v1/me to check an expired, revoked or otherwise rejected token. A session-only operation won't accept a Bearer key. |
403 | Verify the workspace ID, the key's scopes, and any additional permission check. With a session, check the user's workspace role. |
404 | Check the API version, route and resource ID. An item in another workspace is not a valid target. |
405 | Check the HTTP method and the Allow response header if present. |
409 | Resolve the reported conflict before retrying, for example a record still referenced elsewhere. |
429 | Honor Retry-After when present; limit concurrency and back off rather than immediately replaying the request. |
There is no documented global per-key quota for the cocktail and queue routes. Some routes have their own limiters and a deployment can impose additional limits; see Hosting and browser access. For transient failures, use bounded retries with jitter on reads. After a timeout on a write, check the result before trying again: the write may have committed.
When done, run unset api_key or close the shell. For writes, continue with
Integration workflows in a test workspace.