Developer guide
Buyer sign-in with OTP, Google or Apple
Buyers of a RapBooster store sign in with a one-time code sent to their phone, or with Google or Apple. A successful sign-in returns a 15-minute access token, sent as the X-Buyer-Token header, and a 30-day refresh token that you swap for a new pair. Buyer accounts belong to the store's workspace, not to RapBooster.
Guide
Step by step
Send and check a code
POST /auth/otp sends a code and answers a request_id. POST /auth/otp/verify checks it and signs the buyer in, or up when the phone is new (is_new: true). The buyer must accept your terms (terms_accepted: true); marketing_consent records their opt-in.
JavaScript (@rapbooster/sdk)
const { data: otp } = await rb.store.auth.requestOtp({ phone: "+919876543210" });
const { data: session, error } = await rb.store.auth.verifyOtp({
phone: "+919876543210",
code: "123456",
request_id: otp!.data.request_id,
terms_accepted: true,
});
if (error) throw new Error(error.code); // BUYER_OTP_INVALID, BUYER_OTP_LIMIT
rb.setBuyerToken(session!.data.access_token);Google and Apple
Send the ID token your app received from Google or Apple to POST /auth/google or POST /auth/apple; the answer is the same session. A store can turn a method off, which answers AUTH_METHOD_DISABLED.
Keep the session
Send X-Buyer-Token: <access_token> on /me/*, carts and checkout. When it expires (401 BUYER_TOKEN_INVALID), call POST /auth/refresh with the refresh token: you get a new pair and the old refresh token stops working. POST /auth/logout ends the session.
Store refresh tokens like passwords: in the app's secure storage, or an httpOnly cookie on your own server.
GET /me: the buyer;PATCH /mechanges name, email and per-channel consents.POST /me/export: emails the buyer their data;DELETE /meerases the account (orders keep their tax records).- A third-party server checks a buyer with
GET /me(their token) orGET /buyers/{id}(a secret key with store:write).