Skip to content
Select theme
Light
Dark
Auto
Select language
English
فارسی

Customer Account API

Everything a buyer sees once they sign in: their orders and their status, their addresses, their invoice details, their wishlist and their active sessions. It is separate from the Storefront API because the storefront key is public, and nothing behind a public key can be personal.

POST {shop}.kaladan.store/api/2026-10/customer/graphql

Call it from the buyer’s browser, on the shop’s own origin, with the storefront key and, once they sign in, the buyer’s access token. A theme’s server never calls it and never handles a buyer’s token.

There are no passwords and no sign-up form. The first successful verification creates the account.

mutation { customerOtpRequest(phone: "09121234567") { challenge { id resendAfter codeLength } userErrors { code } } }
mutation {
customerOtpVerify(challengeId: "…", code: "12345") {
tokens { accessToken accessTokenExpiresAt }
isNewCustomer
userErrors { code }
}
}

The interface is yours: a storefront collects the code inline, where a redirect to sign in would read as a broken site. The defences are Kaladan’s: rate limits per number, IP address and shop, attempt caps, code expiry and resend backoff all run on the server.

  • Wait for resendAfter before enabling “send again”.
  • Read codeLength. It is a platform setting; do not hard-code five digits.
  • Show “complete your profile” once, when isNewCustomer is true.

The access token is short-lived and kept in memory. In a browser, send X-Kaladan-Session: cookie on customerOtpVerify, customerAccessTokenRefresh and customerSignOut: the refresh token is then kept in an HttpOnly cookie on the shop’s own host that no script, and no theme, can read.

Refresh tokens are single-use. Presenting a spent one ends the whole session, on the assumption it was stolen, so never run two refreshes at once.

  • AUTHORIZED and UNRESOLVED are not failures. An order sits there when a gateway callback was lost and reconciliation has not caught up. Show «در حال بررسی پرداخت», never «پرداخت ناموفق», or a buyer who already paid will pay again.
  • Orders are read-only. A buyer cannot change an order here; the merchant can.
  • No catalogue here. Order lines and wishlist items carry enough to draw a row. For the product itself, query the Storefront API by handle, which a CDN can cache.
  • A deleted product leaves productHandle: null. Draw the row without a link.
  • Show the buyer their sessions. SMS codes are weak against SIM swaps, and a buyer noticing a session they do not recognise is the cheapest alarm there is.