API reference

REST API

JSON over HTTPS. All endpoints are scoped to one organisation. Status: Beta

Authentication

Server-to-server calls use an API key created by an owner or admin in Settings → API keys. Keys are shown once, stored as hashes and carry read and/or write scopes.

curl https://<your-deployment>/api/products?limit=5 \
  -H "Authorization: Bearer ews_sk_<prefix>_<secret>"

The web app uses an HttpOnly session cookie. Cookie-authenticated write requests must come from the same origin (CSRF protection). Routes marked “session” are not available to API keys.

Rate limits

GroupLimitKey
General API240 requests / minuteper API key or IP
AI engines & agents60 requests / minuteper API key or IP
Auth endpoints10 requests / minuteper IP
Public demo endpoints40 requests / minuteper IP

Responses include x-ratelimit-limit and x-ratelimit-remaining. A 429 response includes retryAfterSeconds. Limits are per server instance in this version.

Errors

{ "error": { "code": "validation_error", "message": "price: must be a number", "field": "price" } }
HTTPcodeMeaning
400invalid_json / invalid_tokenMalformed body or expired token
401unauthenticatedSign in or send a valid API key
403forbidden / bad_originRole lacks permission, or cross-site request blocked
404not_foundResource does not exist in your organisation
409integration_not_configured / integration_not_available / already_decidedAction not possible in the current state
413payload_too_large / file_too_largeBody or image too large
415unsupported_media_type / invalid_imageWrong image type or content does not match type
422validation_errorA field failed validation — `field` says which
423account_lockedToo many failed sign-ins
429rate_limitedToo many requests — see retryAfterSeconds
502provider_error / provider_unreachable / integration_unreachableA configured external provider failed
Integrations that are not configured return an explicit integration_not_configured or integration_not_available error — never a fake success. Agent actions on external systems without a live integration finish with status not_executed.

Webhooks

Outgoing webhooks (HMAC-signed event delivery to your endpoint) are Planned and are not available yet. Incoming provider webhooks (Shopify orders/products) are also planned; today data enters through sync, CSV import or the API.

Catalog

GET/api/productssession or API keydata:read

List products (filters: q, category, status, limit, offset).

Response
{ "total": 24, "items": [ { "id": "prd_…", "sku": "KC-MUG-014", "title": "…", "attributes": {…} } ] }
POST/api/productssession or API keycatalog:write (API key scope: write)

Create a product.

Request body
{ "sku": "KC-NEW-001", "title": "Brass Diya", "price": 499, "category": "home.decor.candles", "attributes": { "material": "brass" } }
Response
201 { "product": {…} }
GET/api/products/{id}session or API keydata:read

Product with channel listings and images.

Response
{ "product": {…}, "listings": [], "images": [] }
PATCH/api/products/{id}session or API keycatalog:write

Update product fields or attributes.

Request body
{ "attributes": { "capacity_ml": 350 } }
Response
{ "product": {…} }
DELETE/api/products/{id}session or API keycatalog:write

Archive a product (soft delete).

Response
{ "ok": true, "archived": true }
POST/api/products/importsessioncatalog:write

Validate (dryRun) or import a CSV catalog.

Request body
{ "csv": "sku,title,price\nKC-1,Mug,499", "dryRun": true }
Response
{ "rows": 1, "valid": 1, "created": 1, "errors": [], "warnings": [], "preview": [ … ] }

AI engines

POST/api/ai/vision/analyzesessionai:run

Commerce Vision AI: image quality, colours, category, attributes, listings and matches. Images: PNG/JPEG/WebP data URL ≤ 4 MB.

Request body
{ "metrics": { "width": 1200, "height": 1200, "brightness": 0.8, "contrast": 0.2, "sharpness": 120, "whiteBackground": 0.9, "fill": 0.7, "dominant": [[50,62,130]], "dhash": "f0e0c0c0e0f0f8fc" }, "imageDataUrl": "data:image/jpeg;base64,…", "hint": "indigo ceramic mug" }
Response
{ "mode": "baseline" | "simulated" | "live", "quality": { "score": 85, "issues": [] }, "category": {…}, "attributes": {…}, "needsInput": ["capacity_ml"], "listings": [ … ], "matches": [ … ] }
POST/api/ai/catalog/generatesession or API keyai:run (save: catalog:write)

Catalog Intelligence: channel listings + quality scores for a product; save=true stores drafts.

Request body
{ "productId": "prd_…", "channels": ["amazon_in", "shopify"], "save": false }
Response
{ "mode": "template" | "live", "listings": [ { "channel": "amazon_in", "title": "…", "score": { "score": 82, "checks": [ … ] } } ] }
POST/api/ai/demand/forecastsession or API keydata:read

Demand Intelligence: probabilistic forecast, backtest and replenishment plan for a product.

Request body
{ "productId": "prd_…", "horizonDays": 28, "serviceLevel": "0.85" }
Response
{ "forecast": { "total": { "p10": 98, "p50": 140, "p90": 182 }, "backtest": { "wape": 0.17, "baselineWape": 0.21 } }, "plan": { "stockoutProbability": 0.38, "recommendedQty": 96 } }
POST/api/ai/risk/evaluatesession or API keydata:read

Commerce Risk AI: RTO risk for a stored order (orderId) or ad-hoc features.

Request body
{ "orderId": "ord_…" }
Response
{ "score": 0.71, "band": "high", "factors": [ { "label": "Address quality", "contribution": 0.76 } ], "actions": [ … ], "model": "ews-rto-baseline-v0 …" }
GET/api/ai/providerssessiondata:read

Configured model providers (NIM, OpenAI-compatible, Triton, baseline) and their verified status.

Response
{ "providers": [ { "id": "nvidia-nim", "configured": false } ] }

Agents & workflows

POST/api/agents/executesession or API keyagents:run

Run the agent engine on an instruction. Returns the run with plan, tasks, approvals and ledger.

Request body
{ "instruction": "Analyze today's orders and identify products with inventory risk." }
Response
{ "id": "run_…", "status": "awaiting_approval", "tasks": [ … ], "approvals": [ … ], "summary": "✓ …" }
GET/api/agents/activitysession or API keydata:read

Recent runs and approval requests.

Response
{ "runs": [ … ], "approvals": [ … ] }
GET/api/agents/runs/{id}session or API keydata:read

Full run detail.

Response
{ "id": "run_…", "tasks": [ … ], "ledger": [ … ] }
POST/api/approvals/{id}sessionrole-dependent

Approve or reject a pending action. T2 needs manager+, T3 needs admin/owner.

Request body
{ "decision": "approve", "note": "Confirmed with customer" }
Response
{ "id": "run_…", "status": "completed", … }
GET/api/agents/ledger/verifysessiondata:read

Verify the organisation’s hash-chained execution ledger.

Response
{ "ok": true, "entries": 52, "brokenAt": null }
GET/api/workflowssession or API keydata:read

List workflows and recent executions.

Response
{ "workflows": [ … ], "executions": [ … ] }
POST/api/workflows/createsession or API keyworkflows:write

Create a workflow (alias of POST /api/workflows).

Request body
{ "name": "Hold risky COD", "enabled": true, "trigger": { "type": "event", "value": "order.created" }, "conditions": [ { "field": "risk.score", "op": "gte", "value": 0.5 } ], "steps": [ { "tool": "risk.scan" }, { "tool": "order.hold" } ] }
Response
201 { "ok": true, "id": "wf_…" }
POST/api/workflows/{id}/runsessionagents:run

Run a workflow now, or simulate its trigger event against current data.

Request body
{ "source": "event" }
Response
{ "status": "awaiting_approval" | "skipped", "note": "…", "run": { … } }

Analytics & data

GET/api/analytics/overviewsession or API keydata:read

GMV, net revenue, gross margin, CM1, CM2, RTO and return rates; series; by channel. Query: range=7d|30d|90d|180d, channel.

Response
{ "current": { "gmv": 2777121, "netRevenue": 2255371, "cm2": 1375473, "rtoRate": 0.146 }, "series": [ … ] }
GET/api/orderssession or API keydata:read

List orders with latest risk score (filters: from, to, status, channel, payment, q).

Response
{ "total": 8707, "items": [ … ] }
GET/api/inventorysession or API keydata:read

Forecast-driven inventory health per product and purchase-order drafts.

Response
{ "items": [ { "sku": "…", "plan": { "status": "stockout_risk" } } ], "purchaseOrders": [ … ] }

Integrations

GET/api/integrationssessiondata:read

Integration directory with connection status for the organisation.

Response
{ "integrations": [ { "id": "shopify", "connection": null, "availability": { "live": false } } ] }
POST/api/integrations/{provider}/connectsessionintegrations:manage

Create a demo connection, or a live one (Shopify OAuth / WooCommerce keys / Shiprocket API user). Returns integration_not_available where approval is pending.

Request body
{ "mode": "live", "storeUrl": "https://shop.example", "consumerKey": "ck_…", "consumerSecret": "cs_…" }
Response
{ "ok": true, "mode": "live" } | 409 { "error": { "code": "integration_not_available" } }
POST/api/integrations/{provider}/syncsessionintegrations:manage

Sync a connection (live: reads first page from provider; demo: no external call).

Response
{ "mode": "demo", "fetched": 0, "message": "…" }

System

GET/api/healthpublic

Health check: database and provider configuration.

Response
{ "ok": true, "database": "reachable" }