Common Recipes
End-to-end examples for the most common API integrations.
Practical, copy-paste walkthroughs for the things integrators do most. Each assumes you have a token; see the Quickstart if you don't.
Recipe 1 — Sync inventory from an external system
Push current inventory levels into Claret. This is an asynchronous workflow: you submit the data, get a job_id, and poll for completion.
Required scope: Workflow Sync (public_api.workflow). Add Workflow Replace for replace mode.
Step 1 — Submit the inventory
curl -X POST "https://plan.claret.app/{tenant}/api/v1/workflows/sync-inventory" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000" \
-d '{
"mode": "upsert",
"data": [
{
"item_name": "Chardonnay Juice",
"bin_name": "Tank-01",
"lot_name": "LOT-2026-001",
"date_filled": "2026-04-01",
"quantity": 5000,
"uom": "Liter"
}
]
}'modeisupsert(default) orreplace. Inreplacemode you must also send ascope({"location": "...", "item": "..."}) identifying what to replace, and the token needs the Workflow Replace scope.dataaccepts up to 100,000 rows per request.Every row needs
item_name,bin_name,lot_name,date_filled(YYYY-MM-DD),quantity, anduom.The
Idempotency-Keyheader (a UUID you generate) makes retries safe — reuse the same value when retrying a request.
The response is 202 Accepted with a job_id.
Step 2 — Poll for completion
The status moves pending → in_progress → completed (or failed). Poll every 5 seconds for the first 30 seconds, then every 15 seconds.
Recipe 2 — Pull sales data
Read sales records, filtered by date and type, paging through the full set. Sales use cursor pagination.
Required scope: Read (public_api.read).
Step 1 — First page
Step 2 — Follow the cursor
Read meta.pagination.next_cursor from the response and pass it back as cursor:
Repeat until meta.pagination.has_more is false. The same pattern works for GET /inventory, GET /supply-plans, and GET /financial-plans.
Recipe 3 — Generate a supply plan
Trigger supply plan computation. There are two modes.
Required scope: Compute (public_api.compute).
Option A — Single item-location (synchronous)
Returns the computed plan in the response (up to a 30-second timeout):
Identify the target by either item_location_id, or item_name + location_name. Identify the view by view_id or view_name.
Option B — Whole location (batched, asynchronous)
Queues generation for every item-location at a location and returns a job_id:
Poll GET /jobs/{job_id} (Recipe 1, Step 2) until it completes, then read the results with GET /supply-plans (Recipe 2's pattern).
Related documentation
The API Reference — full per-endpoint reference
Last updated
Was this helpful?