Customer accounts

Sign shoppers in with an email or phone code and give them the hosted account headlessly: profile, consent, addresses, orders, Gift Cards, Store Credit, wishlist and privacy requests.

A headless storefront signs shoppers in and gives them everything the store's hosted account has: profile, a missing email or phone, marketing consent, address book, orders, Gift Cards, Store Credit, wishlist, privacy requests, cases, and reviews and blog comments written as the customer. Every call runs the same rules and services as the hosted account, so the store's customer settings (account mode, sign-in methods, sign-up on or off, phone countries, wishlist settings) apply unchanged.

How the customer session works#

  • The customer signs in on the shopper session (POST /sessions). It is the same kind of session the hosted store keeps in its cookie; here its token travels in Tringify-Shop-Session.

  • Every account call needs a storefront key (Tringify-Shop-Key) or a server key (Authorization: Bearer), and a session started with a key of the same headless storefront. Without a key the call answers 403 SHOP_API_ACCOUNT_KEY_REQUIRED; a missing, expired or other storefront's session answers 401 SHOP_API_SESSION_REQUIRED.

  • A successful sign-in gives the session a new token, returned as session.token. From then on send the new token; the old one names an empty guest session. The session keeps its ID, browser ID, touches and consent, and lasts as long as the store's customer session setting (Settings > Customers).

  • Sign-out keeps the session and its token as a guest's. The customer's wishlist and cart stay with the customer.

  • Account reads that need a signed-in customer answer 401 STOREFRONT_CUST_SIGN_IN_REQUIRED for a guest session.

Keeping the token: browser and server#

  • The API never sets a cookie and reads the token only from the Tringify-Shop-Session header, so a browser never sends it by itself and another site cannot make a request in the shopper's name. There is nothing for CSRF to exploit on the API.

  • Browser mode (storefront key): keep the token in your own storage on your site's origin. Calls from a browser are answered only for the storefront's allowed origins (Settings > Headless); other origins get SHOP_API_ORIGIN_NOT_ALLOWED. DELETE is allowed in CORS for the address and wishlist calls.

  • Server mode (server key): keep the token in an HttpOnly, Secure, SameSite=Lax cookie on your own domain and call the API from your server, forwarding Tringify-Shop-Client-IP and Tringify-Shop-Client-User-Agent so code limits and consent records name the shopper. Protect your own forms against CSRF as you would for any signed-in page.

  • Treat the token like a password: it is the customer's signed-in session until sign-out or expiry.

Signing in#

Sign-in is always by a one-time code to an email address or phone number; the store's settings say which ones are offered. GET /customer/settings?country=IN (key needed, no session) returns customer_settings, the same object themes read as ctx.customer_settings: account_mode, registration_enabled, email_login_available, phone_login_available, phone_registration_available, phone_add_available, preferred_auth_method, default_phone_country, collect_marketing_consent, collect_text_marketing_consent, text_marketing_consent_label, registration_fields and the wishlist settings, plus phone_countries (the countries whose numbers the store takes; empty means every country).

bash
# 1. Start a shopper session (once per visitor)
curl -s -X POST https://<store domain>/api/shop/2026-11/sessions \
  -H 'Tringify-Shop-Key: tfpk_…' -H 'Content-Type: application/json' \
  -d '{"country":"IN","language":"en"}'
# → {"session": {"id": "…", "token": "<token>", …}}

# 2. Send a code
curl -s -X POST https://<store domain>/api/shop/2026-11/customer/codes \
  -H 'Tringify-Shop-Key: tfpk_…' -H 'Tringify-Shop-Session: <token>' \
  -H 'Content-Type: application/json' -d '{"email":"shopper@example.com"}'
# → 202 {"expires_at": "…", "expiry_minutes": 5, "message": "…"}

# 3. Verify it
curl -s -X POST https://<store domain>/api/shop/2026-11/customer/sign-in \
  -H 'Tringify-Shop-Key: tfpk_…' -H 'Tringify-Shop-Session: <token>' \
  -H 'Content-Type: application/json' \
  -d '{"email":"shopper@example.com","code":"123456","first_name":"Asha"}'
# → {"session": {"id", "token": "<new token>", "expires_at"}, "customer": {…}, "new_customer": true}
  • POST /customer/codes takes email or phone_number (with its country code), and optionally provider (email or phone). The answer is the same whether or not the contact has an account. Codes go through the hosted sign-in's send limits: per shopper address, per contact, per store, and the extra budgets for phone numbers outside the store's countries. A phone number from a country outside phone_countries answers AUTH_PHONE_COUNTRY_NOT_ALLOWED before any code is sent.

  • POST /customer/sign-in takes the same contact with code. It signs in to the contact's account, or creates one when the contact has none and the store allows sign-up. first_name, last_name and accepts_marketing apply to a new account; accepts_text_marketing records SMS and WhatsApp marketing consent for the account's phone. Each counts only where the store collects it (collect_marketing_consent, collect_text_marketing_consent), as on the hosted sign-up form. Wrong codes count per code and per address, with the hosted limits.

  • Signing in moves the guest's wishlist and cart into the customer's, by the hosted store's rules.

  • POST /customer/sign-out answers {signed_out: true, session: {id, token}}.

Endpoints#

Request

Does

GET /customer/settings

Sign-in options (see above). Key needed; no session needed.

POST /customer/codes

Sends a sign-in code. 202 {expires_at, expiry_minutes, message}.

POST /customer/sign-in

Verifies the code: signs in or signs up. Returns the session's new token, customer and new_customer.

POST /customer/sign-out

Signs the session out; it stays as a guest's.

GET /customer

customer: the signed-in customer as themes read ctx.customer (id, email, first_name, last_name, display_name, phone, phone_display, accepts_marketing, accepts_text_marketing, email_verified, phone_verified, orders_count, created_at, date_of_birth).

PATCH /customer

{first_name?, last_name?, date_of_birth?, accepts_marketing?, accepts_text_marketing?}: only the fields sent change. date_of_birth is YYYY-MM-DD; "" clears it. Returns customer.

POST /customer/contacts

{email} or {phone_number}: adds the contact the account lacks. When a record nobody has signed into (a checkout guest) holds it, a code goes to the contact and the answer has requires_verification: true; send the same call with code to add it verified and merge that record into the account.

GET /customer/address-form

address_form: the countries the storefront sells to and each one's fields in order, with labels in the request's language, required flags and patterns (ctx.customer.address_form).

GET /customer/addresses?query=&type=&page=

addresses: 20 a page (items, total, page, pages), type shipping or billing.

POST /customer/addresses

{address_type?, is_default?, first_name, last_name, company?, phone?, address1, address2?, district?, city, province_code?, country_code, postal_code?}: 201 {address}. Checked against the country's address form (required fields, postal code, province), as on the hosted account; field names a refused field when the check names one.

PATCH /customer/addresses/{id}

Only the fields sent change. is_default: true makes it the default of its type. Returns address.

DELETE /customer/addresses/{id}

{deleted: true}.

GET /customer/orders?query=&status=&payment=&page=

orders: the customer's orders, newest first (ctx.customer.orders): items [{id, name, order_number, created_at, total, total_items, status, status_label, financial_status, fulfillment_status, channel_type, collection_mode, delivery_issue_status, rto_status, return_status, return_kind, reship_count, …}], paging, and the status and payment filters with their counts. query searches order numbers.

GET /customer/orders/{id}

order: one order as the hosted account's order page shows it (ctx.customer.order): lines, totals, payments, fulfillments and tracking, addresses, cancellation and the links to its status page. Another customer's order answers 404 SHOP_API_NOT_FOUND.

GET /customer/gift-cards?after=

gift_cards: the Gift Cards the customer received or sent, each once, as in the hosted account (items, page_size). Received cards are those issued to the customer, sent to an email or phone they confirmed, or bought for their own account email or phone; next_cursor is the next page's after, empty on the last page.

GET /customer/store-credit?page=

store_credit: balance, currency and history (kind, label, amount, created_at, order_number), with history_page and history_pages. null when the store has Store Credit off or the customer holds none.

GET /customer/app-fields

app_fields [{app_id, app (the app's handle), fields}]: the signed-in customer's values of each installed app's customer fields that buyers may read (a loyalty app's points balance, for example), the same values app blocks on the account page read as app_customer. One entry per app with values; at most 50 values per app.

GET /customer/privacy-requests?cursor=

privacy_requests [{id, reference, request_type, status, due_at, due_at_display}], newest first, and next_cursor. due_at is ISO 8601 in the store's timezone, due_at_display the same moment in the request's language and the date style of its country, the time zone named.

POST /customer/privacy-requests

{request_type: "export" | "deletion"}: the customer's request for a copy of their data or its deletion, with no confirmation email (they are signed in). 201 with privacy_requests.

GET /wishlist

wishlist: the guest's or the customer's wishlist (ctx.wishlist).

POST /wishlist/items

{product_id, variant_id?, properties?, client_mutation_id?}: saves a product sold on the key's channel. 201 when added. The store's wishlist settings apply: guests only while guest wishlists are on, for the guest wishlist length; at most wishlist_max_items.

DELETE /wishlist/items?product_id=&variant_id=&identity_hash=

Removes a saved product (or the one personalised line identity_hash names).

DELETE /wishlist

Empties the wishlist.

POST /checkout-sessions/{id}/sign-in-link

A one-time link that opens the session's hosted checkout signed in as the customer (see Opening checkout signed in). 201 {url, expires_at}.

Every answer carries context (country, language, currency), taken from the session unless the call sends country and language. Account answers are never cached. A refusal is the usual error body; its code is the hosted account's (STOREFRONT_CUST_*, STOREFRONT_WISHLIST_*, AUTH_*), its message is in the request's language and field names the input.

Cases, reviews and comments#

  • Cases (help requests) accept the signed-in session under the same rules: a key and a session of the same headless storefront. See Cases.

  • A review written with a signed-in session is the customer's: the store's "signed-in customers only" and "buyers only" settings count the customer's account and purchases.

  • A blog comment written with a signed-in session comments as the customer's account (name and email come from it). A blog that takes comments from signed-in customers only answers guests with SHOP_API_COMMENTS_SIGN_IN_REQUIRED.

  • Live Chat (POST /chat/identity) starts the chat as the signed-in customer under the same rules: a storefront or server key and a session of the same headless storefront; otherwise the chat starts as a guest.

Checkout#

A checkout session created with a signed-in shopper session (Tringify-Shop-Session, started by the same headless storefront) is priced for that customer, as hosted checkout prices a signed-in shopper: customer-group prices, discounts for that customer or their groups, and per-customer limits. It says signed_in: true. Read with the same shopper session, it also carries store_credit: available (the customer's Store Credit in the session's currency) and the store's max_per_order_percent or max_per_order_amount; null for a guest, a store with Store Credit off, a store that takes test payments only, or a customer who holds none. Signing out prices the session as a guest's again.

Opening checkout signed in#

The plain checkout_url opens hosted checkout as a guest of the shopper's browser. To open it signed in, ask for a one-time sign-in link right before sending the shopper there: POST /checkout-sessions/{id}/sign-in-link with the key and the customer's signed-in shopper session answers 201 {url, expires_at}. Send the browser to url at once (a redirect or window.location); it signs the browser in on the store's domain and opens checkout priced for the customer, with their saved addresses and Store Credit. Ask for a new link every time; never store, share or log it.

  • Only the checkout session's own shopper session, signed in, with a storefront or server key of the headless storefront that started both, can ask for a link. Another session's or storefront's request answers 404 SHOP_API_CHECKOUT_NOT_FOUND; a guest session 401 STOREFRONT_CUST_SIGN_IN_REQUIRED; a session that was already opened or has ended 409 SHOP_API_CHECKOUT_CLOSED; one without lines SHOP_API_CHECKOUT_EMPTY.

  • The link carries a token of 32 random bytes in its query string. Only its SHA-256 is stored, with the shopper session, that session's current token and the customer. It works for 60 seconds and once: opening it spends the checkout link with it. Asking for a new link replaces the previous one.

  • Opening it is refused (the shopper lands on the cart with a notice) when the token is wrong, expired or already used, or when the shopper session has since signed out, signed in again (its token changed) or signed in as someone else. The plain checkout_url still works as a guest's, and a new link can be asked for.

  • Links are limited to 10 per shopper session every 10 minutes and 300 per key a minute (429 SHOP_API_RATE_LIMITED with Retry-After).

  • Signing in by link records the customer session as a sign-in with a code does: the store's customer session length, the customer's journey, and the browser's cart and wishlist merged into the customer's. The checkout page sends no referrer, so the link does not leave the store's domain.

Errors#

Code

When

SHOP_API_ACCOUNT_KEY_REQUIRED (403)

No storefront or server key: AI agents do not sign shoppers in

SHOP_API_SESSION_REQUIRED (401)

No live shopper session, or one another headless storefront started

STOREFRONT_CUST_SIGN_IN_REQUIRED (401)

The call needs a signed-in customer and the session is a guest's

AUTH_PHONE_COUNTRY_NOT_ALLOWED (400)

The phone number's country is not one the store takes

STOREFRONT_CUST_INVALID_EXPIRED_CODE, STOREFRONT_OTP_EXPIRED, STOREFRONT_OTP_ATTEMPTS_EXCEEDED

The code is wrong, expired, or was tried too often

SHOP_API_RATE_LIMITED (429)

Too many requests or codes; retry after Retry-After

STOREFRONT_WISHLIST_*

The wishlist refused the item: wishlists off, guest wishlists off, the list is full, or the product is not sold on this channel