Authentication
Store API keys for integrations, how a request names its store, and what 401 and 403 mean.
Every request to the API carries a bearer token:
Authorization: Bearer <token>An integration authenticates with a store API key: a key that starts with
mobi_sa_, is created in the store's admin and is bound to that one store.
curl "https://api.mobiari.com/v1/products?limit=5" \
-H "Authorization: Bearer $MOBIARI_KEY"There is no sign-in step and nothing to refresh: the key works until it is revoked, reaches its optional expiry, or its account is switched off.
Store API keys
A store API key is the key of a service account: a non-human member of one store. The account holds permission sets like a person does, cannot sign in, and owns keys that act as the account itself. An integration set up this way keeps working after the person who created it leaves, and never does more than its permission sets allow.
Create the account and its keys in the admin, under Access → Service accounts. The steps are in the help center: Service accounts. The key is shown once, when it is issued; the server keeps only a hash.
mobi_sa_<43 characters, URL-safe base64>Send it as Authorization: Bearer mobi_sa_….
| Question | Answer |
|---|---|
| Which store does it reach? | Only the store of its account. Requests name no store. |
| What can it do? | What the account's permission sets (and any group the account is in) grant at the time of each request. A key has no scopes of its own, so changing the account's permissions changes every key at once. A call it has no permission for answers 403 missing_permission. |
| How long does it last? | Until it is revoked or reaches the expiry chosen when it was issued. A key can also be issued with no expiry. |
| How do I rotate it? | Keys have no rotate call. Issue a second key, deploy it, then revoke the first. An account can hold several keys, one per system. |
| How do I stop it at once? | Revoke the key, or switch the account off: every key of the account then answers 401 until it is switched back on. |
Give the account a permission set with only what the integration needs. A leaked key then exposes nothing else.
Creating service accounts and issuing or revoking keys is done in the admin. It is not part of the API yet.
Naming the store
No path of the API has a store in it. The credential says which store the request is about:
| Credential | How the store is named |
|---|---|
Store API key (mobi_sa_…) | By the key. Nothing to send. |
| Any other credential (a person's session token) | By the Mobiari-Store header, with the store id. |
Authorization: Bearer <session token>
Mobiari-Store: 0199a4f2-6c1e-7d3a-9b1f-3e2c8a5d7f10A request with neither a store API key nor the header answers 400
store_required. A store API key always acts on its own store; the header
does not move it to another one.
Signing people in (sign-in, token refresh, two-factor authentication) belongs to the API of Mobiari's own apps, not to this one. Build integrations on a store API key.
Storefront key and customer token
Everything above is for the API. The
Storefront API (/v1/storefront, for shoppers) has
two credentials of its own, and a store API key does not work there:
| Credential | Sent as | What it is |
|---|---|---|
Storefront key (pk_live_…) | X-Storefront-Key: pk_live_… | Names the store. Public by design: safe in browser and mobile code, and able to do only what a shopper can. Optional on the store's own domain, where the host names the store. |
| Customer token | Authorization: Bearer <token> | A signed-in shopper. From POST /v1/storefront/auth/login, .../auth/code/verify or .../customers/verify. Valid for 30 days, only in the store that issued it. |
Create and revoke storefront keys in the admin under Sales Channels. Each
key can carry an allowlist of browser origins; a request from another origin
is 403 origin_not_allowed. To rotate, create a second key, deploy it, then
revoke the old one. Missing or revoked keys are 401 storefront_key_required
and invalid_storefront_key; a customer token that is missing, expired or
from another store is 401 not_signed_in. Details and the full error list are
in the Storefront API guide.
401 or 403?
| Response | Cause | Fix |
|---|---|---|
400 store_required | The credential is not bound to a store and no Mobiari-Store header was sent | Use a store API key, or send the header |
401 unauthorized | Missing header, revoked, expired or mistyped key, or a key whose service account is switched off | Check the key (did the mobi_sa_ prefix get stripped?), issue a new one, or switch the service account back on |
403 forbidden / missing_permission | The key is valid, but its account lacks the permission the operation needs | Add the permission to one of the account's permission sets |
Errors follow the shape described in API conventions.