API conventions
The rules every endpoint follows. Base URL, versioning, errors, pagination, idempotency, rate limits and data formats.
Everything on this page holds for every endpoint of the API and the Storefront API. The reference pages only document what is specific to each operation.
Base URL and versioning
https://api.mobiari.com/v1| API | Paths | Who calls it | OpenAPI document |
|---|---|---|---|
| API | /v1/... | Your integrations: ERPs, back-office tools, automations | public.json |
| Storefront | /v1/storefront/... | Storefront themes, headless stores, shoppers' browsers | storefront.json |
Point Postman, an SDK generator or a mock server at the OpenAPI documents;
their servers entry already includes /v1.
Mobiari's own web and mobile apps use a separate API of their own. It is not meant for integrations, and nothing promised on this page covers it.
Neither API has a store in its paths. In the API, a store API key names its
store (see Authentication). In the Storefront API, a publishable key in
the X-Storefront-Key header names the store. The older unversioned
/storefront-api/{store_slug}/... paths are gone from the public API (a few
internal ones stay for the Liquid theme runtime and are not documented). The
chat widget is not part of this change: it still answers at /widget/{key}/...
at the root and under /v1. See the Storefront API guide.
Within /v1, changes are additive only. This covers the API and the
Storefront API. We may, without notice:
- add endpoints, optional request fields and query parameters;
- add fields to responses;
- add values to response enums;
- add error
codes for new failure cases.
Anything else is breaking and ships as a new version or through a deprecation cycle: removing or renaming a path, field or error code, changing a type, making an optional field required, or changing what a status code means. Every change is in the API changelog.
Write clients that survive additive changes:
- ignore response fields you don't know;
- treat an unknown enum value as "other", never as an error;
- branch on
code, not on the error message.
Documented endpoints
The contract covers what the references document: the operations of the
API (public.json) and of the
Storefront API (storefront.json). A path under
/v1 that is in neither answers 404 route_not_found. The API that
Mobiari's own apps use is outside this contract and can change with any
release.
Authentication
Send a bearer token on every request that needs one:
Authorization: Bearer <token>For an integration the token is a store API key (mobi_sa_…): the key
of a service account you create in the store's admin. The key is bound to
that one store, so requests name no store, and it can do what the account's
permission sets allow. A call the key has no permission for answers 403
missing_permission.
A credential that is not bound to a store (a person's session token) names the store in a header instead:
Mobiari-Store: 0199a4f2-6c1e-7d3a-9b1f-3e2c8a5d7f10A request with neither a store API key nor the header answers 400
store_required. See Authentication.
The Storefront API is different: shoppers have no account with the store's admin, so it uses a publishable key instead, sent on every request:
X-Storefront-Key: pk_live_…The key is safe to ship in browser and mobile code. It names the store and
can only do what a shopper can. Operations on a customer's own account also
need that customer's Authorization: Bearer <customer token>. On a store's
own domain the key may be left out. See the Storefront API guide.
Errors
Every error response, on every endpoint, has one shape:
{
"error": "Cannot merge a customer into itself",
"code": "same_customer",
"details": { "...": "optional, depends on code" }
}| Field | Meaning |
|---|---|
code | Stable, snake_case. Branch on this. Renaming a code is a breaking change. |
error | Human-readable message. Wording can change at any time; show it, don't parse it. |
details | Optional structured context. Its shape is fixed per code. |
When no specific code applies, code is derived from the status. The
codes you will meet most:
| Status | code | When |
|---|---|---|
| 400 | bad_request | Malformed request. |
| 400 | invalid_cursor, invalid_limit | Bad pagination parameters. |
| 400 | offset_not_supported | The request sent offset. Page with cursor. |
| 400 | store_required | The credential is not bound to a store and no Mobiari-Store header was sent. See Authentication. |
| 401 | unauthorized | Missing, expired or revoked credentials. |
| 403 | forbidden, missing_permission | Valid credentials, but they lack the permission the operation needs. |
| 404 | not_found | The resource doesn't exist, or isn't in this store. |
| 404 | route_not_found | No such endpoint under /v1. Check the path and method. |
| 409 | conflict | The resource's state doesn't allow this. |
| 409 | idempotency_request_in_progress | See Idempotency. |
| 413 | payload_too_large | Body over the endpoint's limit. |
| 422 | validation_failed | Field errors in details.fields. |
| 422 | idempotency_key_reused | See Idempotency. |
| 429 | rate_limited | See Rate limits. |
| 500 | internal_error | Our fault. Safe to retry idempotent requests. |
Operations list the specific codes they can return in the reference.
A validation failure names each offending field:
{
"error": "Invalid phone",
"code": "validation_failed",
"details": { "fields": { "phone": "at most 20 digits" } }
}Failed responses carry an x-trace-id header. Include it when you report
a problem; it points straight at the request in our logs.
Pagination
Every endpoint that returns a collection returns a Page:
{
"data": [{ "id": "…" }, { "id": "…" }],
"has_more": true,
"next_cursor": "bzo1MA",
"total": 812
}| Field | Meaning |
|---|---|
data | This page's items, in the order the endpoint documents. |
has_more | Whether another page follows. |
next_cursor | Pass as cursor to get the next page. null on the last page. |
total | Count of all matching items. Only present with include_total=true. |
| Query parameter | Meaning |
|---|---|
limit | Page size, 1 to 200. Default 50. |
cursor | next_cursor from the previous page. Omit for the first page. |
include_total | true to get total. Costs an extra query; leave it off when you just walk pages. |
Cursors are opaque strings: store and send them back as they are, never
build or decode them. To read a whole list, follow next_cursor until
has_more is false. Cursor paging stays correct when rows are added
while you walk.
There is one way to page. A request that sends offset answers 400
offset_not_supported.
Bounded lists that belong to a resource (an order's line items, a customer's addresses) are plain arrays inside that resource, not pages.
Walking every page with curl
url="https://api.mobiari.com/v1/customers?limit=200"
cursor=""
while :; do
page=$(curl -sf "$url${cursor:+&cursor=$cursor}" -H "Authorization: Bearer $MOBIARI_KEY")
echo "$page" | jq -c '.data[]'
cursor=$(echo "$page" | jq -r '.next_cursor // empty')
[ -z "$cursor" ] && break
doneWalking every page in TypeScript
type Page<T> = {
data: T[];
has_more: boolean;
next_cursor: string | null;
total?: number;
};
const BASE = 'https://api.mobiari.com/v1';
async function* listAll<T>(path: string, token: string, query: Record<string, string> = {}) {
let cursor: string | null = null;
do {
const url = new URL(BASE + path);
for (const [k, v] of Object.entries(query)) url.searchParams.set(k, v);
url.searchParams.set('limit', '200');
if (cursor) url.searchParams.set('cursor', cursor);
const res = await fetch(url, { headers: { Authorization: `Bearer ${token}` } });
if (!res.ok) {
const err = await res.json();
throw new Error(`${res.status} ${err.code}: ${err.error}`);
}
const page: Page<T> = await res.json();
yield* page.data;
cursor = page.has_more ? page.next_cursor : null;
} while (cursor);
}
for await (const customer of listAll('/customers', key)) {
console.log(customer);
}Idempotency
A POST that times out may or may not have happened. Send an
Idempotency-Key header and retry with the same key to get the
original response instead of a second order, refund or message:
curl -X POST "https://api.mobiari.com/v1/customers/$CUSTOMER_ID/merges" \
-H "Authorization: Bearer $MOBIARI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 5f0c1c52-2a3e-4d8e-9d59-0d3c2f6f4b1e" \
-d '{"from_customer_id": "…"}'- Use a fresh random value (a UUID) per logical operation, at most 255
characters. Keys are scoped to your credential, and to the store named in
Mobiari-Storewhen you send that header. - A retry with the same key, path and body within 24 hours returns the
stored status and body, with
Idempotent-Replayed: true. - A retry while the first request is still running gets 409
idempotency_request_in_progress. Wait briefly and retry. - The same key with a different body or path gets 422
idempotency_key_reused. That is a bug in the client: one key, one request. - 5xx responses are not stored, so a retry after a server error runs the request again.
- Applies to POST requests with a JSON (or empty) body of up to 1 MB. File uploads ignore the header. Other methods don't need it: GET, PUT and DELETE are already safe to repeat.
Rate limits
Each caller gets a budget per one-minute window: per token when authenticated, per client address otherwise.
| Caller | Default budget |
|---|---|
| Authenticated | 1200 requests / minute |
| Anonymous | 300 requests / minute |
Every response reports where you stand:
RateLimit-Limit: 1200
RateLimit-Remaining: 1187
RateLimit-Reset: 42RateLimit-Reset is the number of seconds until the window resets. Over
budget, you get 429 rate_limited with Retry-After (seconds) and
details.retry_after_seconds. Wait that long, then retry:
async function call(url: string, init: RequestInit): Promise<Response> {
for (;;) {
const res = await fetch(url, init);
if (res.status !== 429) return res;
const wait = Number(res.headers.get('Retry-After') ?? '1');
await new Promise((r) => setTimeout(r, wait * 1000));
}
}Budgets can change; read the headers instead of hard-coding the numbers.
Deprecation
When something in /v1 is deprecated, its responses say so:
Deprecation: @1790812800
Link: </v1/…>; rel="successor-version"
Sunset: Sat, 31 Jan 2027 00:00:00 GMTDeprecation(RFC 9745): the date the path was deprecated, as a Unix timestamp.Linkwithrel="successor-version": the/v1path to use instead.Sunset(RFC 8594): when the old path stops working. Sent once a date is set.
Log them in your client so you hear about a sunset before it happens.
Data formats
| Kind | Convention | Example |
|---|---|---|
| Money | Integer cents, in fields named *_cents. Never floats. | "total_cents": 18900 is R$ 189,00 |
| Timestamps | RFC 3339 in UTC, in fields named *_at | "created_at": "2026-10-01T14:03:22.418Z" |
| Ids | UUIDs, as strings | "id": "0199a4f2-6c1e-7d3a-9b1f-3e2c8a5d7f10" |
| Enums | snake_case strings. New values can appear; handle unknown ones. | "status": "paid" |
| Request bodies | JSON, Content-Type: application/json, except file uploads (multipart) |
Send timestamps with an offset or Z; the API answers in UTC. Treat ids as
opaque strings: don't parse them or rely on their ordering.