Developer docs

Developer docs

Use the API when your own system needs to read what SaleHero knows (stock, orders, invoices, profit) or hand it work (open a return, assign suppliers, place a B2B order). Everything is JSON over HTTPS, and every key belongs to one organization.

The APIs

Which API for which job

APIDoes this jobKey
/api/v1Operations: open a return with courier pickup, read stock and stock changes, assign suppliers in bulk.sbk_… v1
/api/ai/v1Read-only answers for dashboards and AI agents: stock per SKU, orders, returns, invoices, receivables, sales, profit.sbk_… ai:read
/api/mcpThe same data as tools for an MCP client such as Claude Desktop, Claude Code or Cursor.sbk_… ai:read / agent
/api/b2b-portalFor the buyers of a seller who runs the B2B portal: place orders from an ERP and track them.b2bk_…
/returns/<org>/embedA returns form you embed in your own shop with two lines of HTML.none (public)

Base URL

Every path in these docs is relative to the host below. Send JSON in and expect JSON out.

https://salehero.ro

Create an API key

  • Sign in as an admin and open Settings, API keys.
  • Give the key a name you will recognise, for example “ERP integration”. The name is shown wherever the key acts, for instance in the audit log.
  • Choose its scope (below) and press Create key.
  • Copy the key at once. It is shown a single time; SaleHero keeps only a SHA-256 hash of it and cannot show it again. Lost it? Revoke it and create a new one.

A key looks like sbk_ followed by random characters. Store it in a secret store or an environment variable, never in committed code or a chat. Revoking a key on the same page stops it immediately and touches no other key.

Authentication

Send the key on every request as a bearer token. There is no other way in: a browser sign-in does not apply to these endpoints.

Authorization: Bearer sbk_YOUR_KEY

A missing, malformed, unknown or revoked key answers 401. A valid key without the scope the API needs answers 403.

Scopes

A key has exactly one scope, chosen when you create it. In the key form the three scopes carry these labels:

ScopeLabel in SettingsOpens
v1Wrapper API (/api/v1)The operations API, /api/v1.
ai:readAI agent, read-only (/api/ai/v1)The read API, /api/ai/v1, and the read tools of the MCP server. Refused by /api/v1.
agentAI agent, full accessEverything an admin colleague can do in the app, plus the read API and MCP. Meant for supervised AI agents; see the MCP page.

Keys created before scopes existed are v1 keys. Give an integration the narrowest scope that does its job, and one key per integration so you can revoke them separately.

Errors

The operations API (/api/v1) answers failures as JSON with a sentence and, where one applies, a stable code. Switch on the code, not the sentence. A body that fails validation lists the offending fields in issues.

{ "error": "Invalid or revoked API key", "code": "unauthorized" }

{ "error": "Validation failed", "issues": [ { "path": ["take"], "message": "Number must be less than or equal to 500" } ] }

The read API (/api/ai/v1) wraps the same information in one envelope:

{ "error": { "code": "sku_not_found", "message": "SKU X is not known to SaleHero" } }
StatusMeaning
400The request is invalid: a parameter or the body failed validation.
401Missing, malformed, unknown or revoked key.
403The key's scope does not open this API, or a route rule denies it.
404The thing you asked for does not exist in your organization.
409A conflict, for example an Idempotency-Key still in use.
429Over the rate limit. Wait for Retry-After seconds.
500Something broke on our side. The body carries a short reference; quote it to support.

Retry 429 and 5xx with a growing delay. Never retry a 4xx unchanged. After a 5xx or a timeout on a write, look up what happened before you send it again.

Rate limits

Each key is limited per minute and per API. The defaults are below; they apply to every key.

APIDefault limit
/api/v1120 requests per minute per key
/api/ai/v1120 requests per minute per key
/api/mcp120 requests per minute per key
/api/b2b-portal120 requests per minute per token

Responses from /api/v1 carry X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (seconds until the window reopens). Over the limit you get 429 with a Retry-After header in seconds.

What is recorded

Calls made with a key are attributed to it. The read API and the MCP server write an audit entry per call (key, path or tool, status, duration; for MCP never the arguments). Returns opened through /api/v1 carry the key's name as the opener and are announced in the organization's Slack channel when Slack is connected.

Get an API key

Create an account, connect your tools, then create a key in Settings.