Skip to content

Customer auth

Base path: /v1/auth on the Public API.

Shoppers authenticate with phone OTP. The server issues a customer JWT (typ: "customer").

  • Persist accessToken and refreshToken in SecureStore.
  • Send Authorization: Bearer <accessToken> on authenticated calls.
  • On 401, POST /v1/auth/refresh with { "refreshToken" }, store the new pair, retry once.

Access JWT TTL is 15 minutes (expiresIn). Customer refresh lasts 30 days.

Endpoints

MethodPathAuthPurpose
POST/v1/auth/send-otpPublicSend (or log) a one-time code
POST/v1/auth/verify-otpPublicVerify code; issue JWT pair
POST/v1/auth/refreshPublicRotate access + refresh
POST/v1/auth/logoutPublicRevoke the refresh token

Send OTP

Body

FieldTypeNotes
phonestring4–24 characters

Example

http
POST /v1/auth/send-otp
Content-Type: application/json
Accept-Language: ar

{ "phone": "50000000" }

Results (inside the envelope)

FieldNotes
messageLocalized acknowledgement
codePresent in non-production so the app can verify without SMS

SMS is stubbed: the server logs the code. Do not rely on a real SMS provider yet.

Verify OTP

Body

FieldType
phonestring
codestring, 4–8 characters
http
POST /v1/auth/verify-otp
Content-Type: application/json

{ "phone": "50000000", "code": "1234" }

On success:

FieldNotes
customerPublic customer object
accessTokenJWT — send as Bearer
refreshTokenOpaque — store securely
tokenType"Bearer"
expiresInAccess TTL in seconds (900)

Guest cart (X-Cart-Token) and assistant conversations (X-Assistant-Guest) are merged onto the customer. After login you can drop those guest headers.

Refresh

http
POST /v1/auth/refresh
Content-Type: application/json

{ "refreshToken": "<opaque>" }

The previous refresh token is revoked. Persist the new accessToken + refreshToken.

Logout

http
POST /v1/auth/logout
Authorization: Bearer <accessToken>

Revokes refresh tokens for this customer. Delete the pair from SecureStore. If the access token is already expired, refresh first or just drop the local tokens and continue as a guest.

After login

Call GET /v1/account/me with Bearer. See Account.