Headless Storefront API v1
Build custom storefronts, mobile apps, and SPAs with the Cartly token-authenticated REST API.
Overview
The Headless Storefront API v1 (/storefront/v1/*) is a stateless REST API for building custom commerce experiences outside the default Liquid storefront. It uses two token types:
- Storefront Access Token (SAT) — issued per sales channel, required on every request. Encodes which shop you are accessing.
- Customer Access Token (CAT) — JWT issued at customer login, required for customer-protected routes (
/customer/*).
Authentication
Pass the SAT as a header on every request:
X-Shopify-Storefront-Access-Token: sat_your_token
// or
Authorization: Bearer sat_your_tokenPass the CAT for customer routes:
Authorization: Bearer cat_eyJhbGci...Sales Channels
A sales channel represents a single client (your mobile app, SPA, etc.). Create one via the Admin API to receive your SAT. The token is shown only once.
// Create a sales channel (admin API — run server-side)
const res = await fetch('https://cartly.pro/admin/sales-channels', {
method: 'POST',
headers: {
'Authorization': `Bearer ${ADMIN_JWT}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Mobile App',
allowed_origins: ['https://app.example.com'],
locale: 'en',
}),
});
const { access_token } = await res.json();
// Store access_token securely — shown only onceManage channels: GET /admin/sales-channels | DELETE /admin/sales-channels/:id
Products & Collections
GET /storefront/v1/products— list (limit, offset, collection, q)GET /storefront/v1/products/:handle— single productGET /storefront/v1/collections— list collectionsGET /storefront/v1/collections/:handle— single collectionGET /storefront/v1/search?q=query— full-text searchGET /storefront/v1/pages/:handle— CMS pageGET /storefront/v1/shop— shop config, theme, menus
Prices are returned as int64 cents. Currency is the shop's base currency (or market currency when using locale-prefixed routes).
Stateless Cart
The cart ID lives in the URL — no session cookie required. Store the cart ID on the client (localStorage, AsyncStorage, etc.).
const SAT = 'sat_your_token_here';
const BASE = 'https://cartly.pro/storefront/v1';
// Create cart
const cart = await fetch(`${BASE}/cart`, {
method: 'POST',
headers: { 'X-Shopify-Storefront-Access-Token': SAT },
}).then(r => r.json());
// Add item
await fetch(`${BASE}/cart/${cart.id}/items`, {
method: 'POST',
headers: {
'X-Shopify-Storefront-Access-Token': SAT,
'Content-Type': 'application/json',
},
body: JSON.stringify({ variant_id: '...', quantity: 1 }),
});
// Apply discount
await fetch(`${BASE}/cart/${cart.id}/discount`, {
method: 'POST',
headers: {
'X-Shopify-Storefront-Access-Token': SAT,
'Content-Type': 'application/json',
},
body: JSON.stringify({ code: 'SAVE10' }),
});Key endpoints:
POST /storefront/v1/cart— create cartGET /storefront/v1/cart/:cartId— get cartPOST /storefront/v1/cart/:cartId/items— add itemPUT /storefront/v1/cart/:cartId/items/:lineId— update quantityDELETE /storefront/v1/cart/:cartId/items/:lineId— remove itemPOST /storefront/v1/cart/:cartId/discount— apply discount codeDELETE /storefront/v1/cart/:cartId/discount— remove discount
Customer Auth
// Login — returns Customer Access Token (CAT)
const { access_token } = await fetch(`${BASE}/customer/token`, {
method: 'POST',
headers: {
'X-Shopify-Storefront-Access-Token': SAT,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: 'user@example.com', password: 'secret123' }),
}).then(r => r.json());
// Fetch orders (CAT required)
const { orders } = await fetch(`${BASE}/customer/orders`, {
headers: {
'X-Shopify-Storefront-Access-Token': SAT,
'Authorization': `Bearer ${access_token}`,
},
}).then(r => r.json());Customer public endpoints (SAT only):
POST /storefront/v1/customer/register— 202, no tokens (see below)POST /storefront/v1/customer/token— login, returns CATPOST /storefront/v1/customer/token/refreshPOST /storefront/v1/customer/logout—refresh_tokenin the body, 204; revokes that refresh token only, works with an expired CAT
POST /storefront/v1/customer/token is limited to 10 requests per minute per client IP (register: 5/min); over the limit it returns 429 with Retry-After. Proxying logins through your own server shares one bucket unless you forward the shopper's address in X-Real-IP.
Register is enumeration-safe: it returns 202 pending_verification with no tokens, and the same body whether the email was free or already registered. Call POST /storefront/v1/customer/token afterwards to obtain a CAT.
Customer protected endpoints (SAT + CAT):
GET /storefront/v1/customerGET /storefront/v1/customer/ordersGET /storefront/v1/customer/orders/:idGET /storefront/v1/customer/addresses
Market-Aware Routes
Prefix any catalog route with a locale code to receive market-specific pricing and translated content:
GET /storefront/v1/de/products // EUR prices + German translations
GET /storefront/v1/fr/products/:handle // EUR prices + French translation
GET /storefront/v1/seo/hreflang // all locale alternate links