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 inTringify-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 answers403 SHOP_API_ACCOUNT_KEY_REQUIRED; a missing, expired or other storefront's session answers401 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_REQUIREDfor a guest session.
Keeping the token: browser and server#
The API never sets a cookie and reads the token only from the
Tringify-Shop-Sessionheader, 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.DELETEis 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-IPandTringify-Shop-Client-User-Agentso 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).
# 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/codestakesemailorphone_number(with its country code), and optionallyprovider(emailorphone). 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 outsidephone_countriesanswersAUTH_PHONE_COUNTRY_NOT_ALLOWEDbefore any code is sent.POST /customer/sign-intakes the same contact withcode. 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_nameandaccepts_marketingapply to a new account;accepts_text_marketingrecords 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-outanswers{signed_out: true, session: {id, token}}.
Endpoints#
Request |
Does |
|---|---|
|
Sign-in options (see above). Key needed; no session needed. |
|
Sends a sign-in code. |
|
Verifies the code: signs in or signs up. Returns the session's new token, |
|
Signs the session out; it stays as a guest's. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Only the fields sent change. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Removes a saved product (or the one personalised line |
|
Empties the wishlist. |
|
A one-time link that opens the session's hosted checkout signed in as the customer (see Opening checkout signed in). |
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 session401 STOREFRONT_CUST_SIGN_IN_REQUIRED; a session that was already opened or has ended409 SHOP_API_CHECKOUT_CLOSED; one without linesSHOP_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_urlstill 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_LIMITEDwithRetry-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 |
|---|---|
|
No storefront or server key: AI agents do not sign shoppers in |
|
No live shopper session, or one another headless storefront started |
|
The call needs a signed-in customer and the session is a guest's |
|
The phone number's country is not one the store takes |
|
The code is wrong, expired, or was tried too often |
|
Too many requests or codes; retry after |
|
The wishlist refused the item: wishlists off, guest wishlists off, the list is full, or the product is not sold on this channel |