Developer docs
Read API for agents and dashboards
Use the read API when a dashboard, a script or an AI agent needs the numbers SaleHero holds correctly: stock as reconciled between your accounting and your warehouse system, unit cost, orders across every channel, invoices and what was collected on them, sales and profit. It can only read, so a leaked key cannot change anything.
Access
| Fact | Value |
|---|---|
| Base URL | https://salehero.ro/api/ai/v1 |
| Key | An API key with scope ai:read (label “AI agent, read-only”). A full-access agent key opens it too; a plain v1 key is refused with 403. |
| Methods | GET |
| Format | JSON, UTF-8. Timestamps are ISO 8601 in UTC; ledger and report dates are YYYY-MM-DD. |
| Rate limit | 120 requests per minute per key; over it, 429 with Retry-After |
Orders and returns carry the customer's name, email, phone and delivery address, so treat the key like any access to customer data. Every call, query string included, is written to the audit log.
Conventions
- Freshness: every response carries data_as_of, when the data in it was last refreshed (null when never). Check it, and GET /sync-status, before drawing conclusions from a number.
- Paging: lists take limit (default 100, at most 500) and answer next_cursor. Pass it back as cursor for the next page; null means the last page.
- Dates: from and to are YYYY-MM-DD, inclusive, UTC days, the same days as the Analytics pages.
- Errors share one body, { "error": { "code", "message" } }. Codes: invalid_request (400), unauthorized (401), forbidden (403), sku_not_found, warehouse_not_found and not_found (404), rate_limited (429, see Retry-After), internal_error (500).
- A SKU is known when SaleHero has it in the catalog, in stock or in the ledger. A known SKU with nothing in the asked range answers 200 with an empty list, not 404.
Stock
/api/ai/v1/stock/{sku}One SKU's stock per warehouse as SaleHero holds it: the accounting reading, the warehouse-system reading and the difference between them. URL-encode the SKU.
Request
curl -s https://salehero.ro/api/ai/v1/stock/SKU-001 \
-H "Authorization: Bearer $SALEHERO_READ_KEY"Response
{
"sku": "SKU-001",
"name": "Example product",
"data_as_of": "2026-11-10T08:00:00.000Z",
"readings": { "smartbill": "2026-11-10T08:00:00.000Z", "base": "2026-11-10T08:10:00.000Z" },
"main_source": "smartbill",
"warehouses": [
{
"warehouse": "Main",
"quantity": 33,
"smartbill_quantity": 33,
"pending_invoice_quantity": 0,
"smartbill_effective_quantity": 33,
"base_quantity": 36,
"difference": -3
}
]
}- quantity is the stock SaleHero works with: the effective accounting figure, or the warehouse-system figure when that is your main stock source. difference is non-zero exactly where a stock-error check should look. A warehouse where every value is 0 is left out.
/api/ai/v1/stock/{sku}/movementsOne SKU's stock ledger, newest first.
Parameters
from, toYYYY-MM-DD- Inclusive day range.
warehousestring- Warehouse name, exactly as SaleHero shows it.
limit, cursorinteger 1–500, string- Paging.
Request
curl -s "https://salehero.ro/api/ai/v1/stock/SKU-001/movements?from=2026-10-01&limit=2" \
-H "Authorization: Bearer $SALEHERO_READ_KEY"Response
{
"sku": "SKU-001",
"data_as_of": "2026-11-10T09:00:00.000Z",
"coverage": { "movements_imported_until": "2026-10-26", "sales_imported_until": "2026-10-26", "invoices_synced_at": "2026-11-10T09:00:00.000Z" },
"movements": [
{ "date": "2026-10-28", "type": "sale", "raw_type": "invoice", "document": "SER 12345", "source": "smartbill", "warehouse": "Main", "quantity": -1, "unit_cost": 21.4, "balance_after": null, "order_id": 123456789 }
],
"next_cursor": null
}- type is sale, receipt, reversal (storno, including customer returns), transfer_in, transfer_out, adjustment or other. quantity is positive in, negative out. The ledger is as complete as the last import: read coverage before relying on it.
Orders
/api/ai/v1/ordersOrders across every channel (BaseLinker, Shopify, manual, B2B), newest confirmed first. A duplicate copy of an order is folded into the order it copies. Every filter you give must match.
Parameters
qstring- Free text, read as an email, phone, order or marketplace number, AWB or name.
number, email, phone, name, awbstring- Exact lookups. phone matches on the last 9 digits whatever the format.
sku, skusstring- A line's SKU, or up to 100 SKUs comma-separated.
from, toYYYY-MM-DD- Confirmation day.
statusstring- A role (new, processing, ready, in_delivery, delivered, cancelled, return, other) or part of a status name.
channel, order_source, countrystring- Sales channel, BaseLinker order source, delivery country (ISO-2).
paidtrue | false- Payment received or not.
limit, cursorinteger 1–500, string- Paging.
Request
curl -s "https://salehero.ro/api/ai/v1/orders?paid=false&from=2026-11-01&limit=1" \
-H "Authorization: Bearer $SALEHERO_READ_KEY"Response
{
"data_as_of": "2026-11-10T08:00:00.000Z",
"orders": [
{
"id": "cm…",
"source": "base",
"number": "ORDER-1001",
"channel": "shopify",
"status": { "name": "Shipped", "role": "IN_DELIVERY" },
"confirmed_at": "2026-11-05T10:00:00.000Z",
"country": "RO",
"currency": "RON",
"total": 249.9,
"total_ron": 249.9,
"payment": { "method": "cod", "received": false, "paid_amount": null },
"invoice": { "series": "SER", "number": 1234, "paid": false },
"customer": { "name": "Example Customer", "email": "[email protected]", "phone": "0700000000" },
"awb": "1234567890",
"lines": [ { "sku": "SKU-001", "name": "Example product", "quantity": 1 } ],
"lines_count": 1,
"returns_count": 0
}
],
"next_cursor": null
}- total_ron is at the BNR rate of the confirmation day, null when there is no rate. lines holds the first 20.
| Endpoint | What it gives |
|---|---|
| GET /orders/{ref} | One order in full: all lines with prices, delivery and billing address, packages with AWB and tracking, invoice with paid and unpaid amounts, courier cash-on-delivery payouts, returns and the last 50 events. ref is a SaleHero id, a BaseLinker id or an order or marketplace number (409 ambiguous_order when several carry it). Nothing is fetched live from BaseLinker. |
| GET /returns, GET /returns/{ref} | Return cases, newest first (q, origin, attention, from, to), and one case by id or RET identifier with where each step stands: BaseLinker return, DPD pickup, monday item. |
Products and cost
| Endpoint | What it gives |
|---|---|
| GET /products?q=… or ?skus=… | Products by SKU, name or barcode: exact matches first, then text matches (limit default 50, at most 200; truncated says more matched). skus takes up to 100 exact SKUs in one call. |
| GET /products/{sku} | The product sheet: catalog data, every price SaleHero holds for it (VAT included), the cost basis and the last 20 price changes. |
| GET /products/{sku}/cost | Average unit cost per warehouse, last receipt cost and pricing_cost_basis: the cost SaleHero computes margins against, useful for “never offer below cost”. |
curl -s "https://salehero.ro/api/ai/v1/products?skus=SKU-001,SKU-002" \
-H "Authorization: Bearer $SALEHERO_READ_KEY"
{
"data_as_of": "2026-11-10T03:20:00.000Z",
"products": [
{ "sku": "SKU-001", "name": "Example product", "barcode": "5940000000017",
"list_price": 499.9, "currency": "RON", "state": "ACTIV",
"active": true, "archived": false, "image_url": "https://…" }
],
"truncated": false
}Invoices, receivables, sales and profit
| Endpoint | What it gives |
|---|---|
| GET /invoices | SmartBill invoices, newest issued first. Filters: number (series and number in any common spelling), numbers (up to 100), order, client, from, to, paid. Each has series, number, issued_at, client, total, paid_amount, unpaid_amount, paid, payment_checked_at and the orders it covers. |
| GET /invoices/{series}/{number} | One invoice with its lines, the courier payouts that paid it and the matched e-Factura messages. |
| GET /receivables | What clients still owe: total_outstanding, invoice_count, age buckets (0–30, 31–60, 61–90, over 90 days) and the top 50 clients. unchecked_invoices counts invoices whose payment was never polled, which the report misses. |
| GET /profit | Profit per SKU with the full unit cost (invoice cost, customs, VAT, EPR, transport, commission) for from … to, at most 31 days; call it month by month. Filters channel and country; paged by limit and cursor. warnings says what could not be priced or converted. |
/api/ai/v1/salesOrders, units, revenue and an estimated profit for a period, grouped as you choose. Same orders as the Analytics pages: one per real order, by confirmation day, cancelled and returned statuses left out. Revenue is the lines' price with VAT in RON at each day's BNR rate.
Parameters
from, toYYYY-MM-DD · required- The period, at most 366 days.
group_byday | month | channel | order_source | country | sku- Default month.
channel, order_source, country, skustring- Filters. country is ISO-2.
limitinteger 1–500- Caps the groups; truncated says when it did.
Request
curl -s "https://salehero.ro/api/ai/v1/sales?from=2026-10-01&to=2026-10-31&group_by=channel" \
-H "Authorization: Bearer $SALEHERO_READ_KEY"Response
{
"data_as_of": "2026-11-10T08:00:00.000Z",
"from": "2026-10-01",
"to": "2026-10-31",
"group_by": "channel",
"currency": "RON",
"cost_basis": "cog",
"totals": {
"orders": 1200, "units": 2100, "revenue": 410000.5, "cost_estimate": 250000.2,
"profit_estimate": 160000.3, "margin_pct": 39.0,
"units_without_price": 0, "units_without_cost": 14, "units_unconverted": 0
},
"groups": [ { "key": "shopify", "orders": 800, "units": 1300, "revenue": 300000.1, "…": "…" } ],
"truncated": false
}- cost_estimate is units times the product's cost of goods; profit_estimate counts only lines that have both a price and a cost. units_without_price, units_without_cost and units_unconverted say what the figures leave out.
/api/ai/v1/sync-statusWhen each data feed last ran and whether it worked. Check it before trusting a number.
Request
curl -s https://salehero.ro/api/ai/v1/sync-status \
-H "Authorization: Bearer $SALEHERO_READ_KEY"Response
{
"data_as_of": "2026-11-10T10:15:00.000Z",
"sources": [
{ "source": "base", "domain": "orders", "status": "ok",
"last_run": "2026-11-10T10:00:00.000Z", "last_success": "2026-11-10T10:00:00.000Z", "last_error": null }
]
}- source is smartbill, base or shopify; domain is what was synced (orders, products, inventory, invoices, payments and so on). last_error is set only while the feed is failing.