Guides
Shopper login and accounts
Which login methods
GET /v1/store → login_methods: any of phone_otp, email_otp, email_password. Offer only those. Phone login works with 10-digit Indian mobile numbers.
OTP login (phone or email)
1. GET /v1/auth/captcha → a proof-of-work puzzle
2. solve it in the browser (~1 second) → captcha payload
3. POST /v1/auth/otp { channel, phone|email, captcha } → 202, code sent
4. POST /v1/auth/verify { channel, phone|email, code } → tokens
import { solveCaptcha } from '@storepecker/storefront-sdk';
const captcha = await solveCaptcha(await client.auth.captcha()); // or use the ALTCHA widget
await client.auth.sendCode({ channel: 'phone', phone: '9876543210', captcha });
const tokens = await client.auth.verifyCode({ channel: 'phone', phone: '9876543210', code: '482913' });
Each captcha works once. The first successful login creates the shopper's account in this store (201, is_new_customer: true).
Password login (existing shoppers of the store only): POST /v1/auth/password { email, password }.
Tokens
{ "access_token": "eyJ…", "refresh_token": "Xq3…", "token_type": "Bearer", "expires_in": 900,
"customer": { "id": "cus_…", "name": "Priya", "email": null, "phone": "+919876543210" },
"is_new_customer": true }
- Send the access token as
X-Customer-Token(your API key stays inAuthorization). It lasts 15 minutes. With the SDK:client.withCustomer(accessToken). - Before it expires,
POST /v1/auth/refresh { refresh_token }returns a new pair. Refresh tokens rotate: always store the new one. - Two refreshes with the same token within 30 seconds (two tabs, a retry) return
401 REFRESH_TOKEN_ROTATEDfor the second; keep using the newer token. A rotated token replayed later is treated as theft:401 REFRESH_TOKEN_REUSEDand the shopper is logged out everywhere. POST /v1/auth/logout { refresh_token }ends the session.- Tokens work only with the app and store that issued them.
Keep both tokens in httpOnly cookies set by your server (the starter's lib/session.ts and proxy.ts show how).
Limits
| Limit | Value |
|---|---|
| Codes sent from one IP to one store | 5 per 15 minutes |
| Codes sent to one phone or email | 1 a minute, 5 an hour |
| Wrong codes per phone or email | 5 per 15 minutes |
| Password attempts per email | 10 per 15 minutes |
| Login SMS per store per day | set by the store (default 200) → 429 OTP_LIMIT_REACHED |
The shopper's account
All need X-Customer-Token.
| Endpoints | What for |
|---|---|
GET /v1/me, PATCH /v1/me { name } | Profile |
GET /v1/me/orders, GET /v1/me/orders/{id} | Order history (newest first) and one order |
GET /v1/me/wishlist, POST /v1/me/wishlist { variant_id }, DELETE /v1/me/wishlist/{variant_id} | Wishlist |
GET /v1/me/addresses, POST, PUT /v1/me/addresses/{id}, DELETE /v1/me/addresses/{id} | Saved addresses |
GET /v1/me/cart, PATCH /v1/me/cart | The saved cart (shared with the store's own website) |
Addresses take name, phone, line, city, state_code (e.g. KL), country_code (ISO, e.g. IN), pincode, is_default. The first address becomes the default; setting is_default moves it. If the store validates pincodes, a bad one returns 400 INVALID_PINCODE.