Authentication
Four different callers authenticate against a MyShopie store, and each has its own credential: store staff working in admin, a register at the till with a cashier signed into it, a shopper with an account, and a machine — an integration or an AI agent — holding a scoped API key. Picking the right one is most of the work; the token mechanics are the same bearer header throughout.
Plans: All plans
Prerequisites
Section titled “Prerequisites”- Your store domain. Every tenant endpoint is relative to
https://{your-store-domain}/api/v1. - For API keys, a role holding
edit_settings. See Staff & permissions.
Which credential to use
Section titled “Which credential to use”| Caller | Credential | Guard |
|---|---|---|
| A person in admin | Staff token from POST /login |
auth:sanctum |
| An integration, script or AI agent | msh_ Admin API key |
auth:sanctum |
| A till | Register device token plus a cashier session token | auth:sanctum |
| A shopper | Customer token from a shopper sign-in | auth:customer |
| A guest shopper’s cart | X-Guest-Token header — not an identity |
none |
Staff sign-in
Section titled “Staff sign-in”-
Post credentials to the store:
Terminal window curl -X POST https://your-store.example/api/v1/login \-H 'Accept: application/json' \-d 'email=you@example.com&password=…' -
Read the token from
dataand send it on every subsequent call asAuthorization: Bearer <token>. -
If the account has MFA enabled, the login response says so instead of returning a token. Complete it with
POST /mfa/verify-loginand the code from the authenticator app. -
When a token expires, call
POST /auth/refresh. This endpoint is public on purpose — the access token being refreshed may already be expired. -
GET /mereturns the signed-in staff user with their roles and permissions. Use it to decide what your UI should offer rather than guessing from the role name.
Sign-in is throttled to 10 attempts per minute per IP, so a credential-stuffing loop stops quickly.
Other staff sign-in routes
Section titled “Other staff sign-in routes”| Route | Use |
|---|---|
POST /auth/passkeys/login/options → /verify |
WebAuthn passkey, the phishing-resistant option |
GET /auth/google/redirect → POST /auth/google/exchange |
Sign in with Google |
POST /auth/hosted/exchange |
The native mobile app’s hosted login — RFC 8252 authorization code with PKCE |
POST /auth/store-switch/exchange |
Move a signed-in staff user to another store they belong to |
POST /auth/impersonation/exchange |
Support impersonation, originated from the central plane and audited |
POST /forgot-password, POST /reset-password |
Password reset, 5 attempts per 15 minutes |
POS: register, then cashier
Section titled “POS: register, then cashier”A till authenticates in two layers, because “which device is this” and “who is standing at it” are different facts with different lifetimes.
-
A manager enrolls the register once from admin —
POST /pos/registers/{register}/enroll. The device stores the resulting register token. This happens on setup, not per shift. -
The device asks who may sign in here:
GET /pos/session/cashiers, authorized by the register token rather than by any staff login. -
The cashier signs in with their PIN or NFC badge:
POST /pos/session/login. This mints a cashier session token for that person on that device. -
The till now sends the cashier session token on sales calls. Handing over to a colleague means another
POST /pos/session/login— the register token never changes. -
POST /pos/session/logoutends the cashier session, run under the cashier’s own token.
Sensitive actions on a committed line — a price override, a void — carry a manager PIN in the request body and are authorized by the override gate, so the cashier’s own session stays in place and the override is recorded against the manager who approved it. See Overrides & loss prevention.
Shoppers
Section titled “Shoppers”| Route | Flow |
|---|---|
POST /customer/register, POST /customer/login |
Email and password |
POST /customer/auth/start → /otp-verify |
Email-first sign-in: enter an email, receive a code |
POST /customer/auth/otp-resend |
Resend that code |
POST /customer/forgot-password, /reset-password |
Password reset |
GET /customer/verify-email |
Email verification link |
POST /auth/passkeys/login/* |
Passkeys, for shoppers too |
One-time codes live in cache only, with a short expiry. They are never written to the store database, so there is no table to leak and no backup to mine — and no way to look a lost code up, only to resend it. Codes are throttled to 5 attempts per 15 minutes, counted per IP and per store.
A shopper token reaches the auth:customer surface: their own orders, invoices, addresses, wishlist, saved
payment methods, digital library and subscriptions. It reaches nothing in admin. See
Storefront API.
Guest carts
Section titled “Guest carts”A shopper with no account carries a guest token, supplied as the X-Guest-Token header (or in the body).
It identifies a cart, not a person. Echo back whatever the cart endpoints return, or the next request
starts an empty cart.
Admin API keys
Section titled “Admin API keys”For integrations and AI agents, issue a key rather than borrowing a login.
-
Open Settings → AI Agents and choose to create a key.
-
Name it after the thing that will use it — “warehouse sync”, “Claude desktop” — so revoking later is obvious.
-
Tick only the scopes it needs. The five pairs are
products:read/products:write,orders:read/orders:manage,settings:read/settings:write,storefront:read/storefront:writeandmarketplace:read/marketplace:write. A write scope implies its read half. -
Copy the key. It begins with
msh_and is shown once. Put it straight into your own secret manager. -
Send it exactly like any other bearer token:
Authorization: Bearer msh_….
Keys are throttled on their own lane: 120 requests per minute per IP and 60 per minute per key, so one noisy integration cannot consume another’s budget.
A worked example: the partner catalog read
Section titled “A worked example: the partner catalog read”The partner endpoints are the clearest illustration of scope gating. GET /api/v1/partner/products requires
products:read; GET /api/v1/partner/orders/{order} requires orders:read.
curl https://your-store.example/api/v1/partner/products \ -H 'Accept: application/json' \ -H 'Authorization: Bearer msh_…'A key without products:read gets 403, not 401 — the key is valid, the scope is not there. The partner
lane additionally requires an active subscription and the standard API entitlement on your plan.
Field reference
Section titled “Field reference”| Thing | Where | Notes |
|---|---|---|
Authorization: Bearer … |
Every authenticated call | Staff, customer and API keys all use it |
X-Guest-Token |
Cart and checkout | Identifies a cart; not an identity |
| Key prefix | API keys | msh_ |
| Scopes | Settings → AI Agents | products, orders, settings, storefront, marketplace — read and write each |
| Login PIN | POS → staff | PUT /pos/me/login-pin, or set for staff with edit_users |
| NFC badge | POS → staff | PUT /pos/staff/{user}/badge |
| MFA | Staff account | TOTP; POST /mfa/verify-login completes sign-in |
Common problems
Section titled “Common problems”401 immediately after a successful login. The token went to the wrong host. A tenant token is only valid on that store’s domain; the central plane has its own.
401 on every call after a while. The staff token expired. Refresh it with POST /auth/refresh.
403 with a key that works elsewhere. The scope is missing for this endpoint, or the plan does not include the API entitlement.
My key stopped working and I did not revoke it. Check whether the subscription lapsed — the partner lane requires an active subscription.
The cashier PIN is rejected. PINs are per staff user and per store. A manager can reset one with
edit_users.
A shopper never receives the code. It is cache-only and cannot be looked up. Resend it, and check Settings → Mail — deliverability, not the API, is the usual cause.
Impersonation token refused. Impersonation originates on the central plane; the exchange endpoint only accepts a token minted there.
How do I get an API key for an integration?
Open Settings → AI Agents and create a key. It is shown once, begins with msh_, and carries the scopes
you tick — products, orders, settings, storefront and marketplace, each read and write.
Store it in your own secret manager; MyShopie cannot show it again.
Should an integration use a staff login or an API key? An API key. A staff token belongs to a person, inherits that person’s role, expires, and dies when they leave. A key is scoped to exactly the operations you ticked, is revocable on its own, and is throttled on its own limiter.
Why does POS sign-in need two tokens? The device and the person are separate facts. A register enrolls once and holds a device token that proves which till this is. A cashier then signs in with a PIN or badge against that device token, which mints a short-lived session token for that person. Handing the till to a colleague replaces the second token, never the first.
Where are one-time login codes stored? In cache only, with a short expiry. They are never written to the store database, so a code cannot be recovered from a backup or read out of a table — which also means a lost code cannot be looked up, only resent.
