Public REST API used by your custom storefront to read the catalog and complete checkout.
Every request must include an x-storefront-key header set to a publishable key. Generate keys at /admin/settings/api-keys. Publishable keys are safe to ship to the browser.
fetch("https://your-app.com/api/storefront/products", {
headers: { "x-storefront-key": "pk_live_XXXX_YYYY" },
})All errors are JSON in the same envelope:
{ "error": { "code": "unauthorized", "message": "Missing x-storefront-key" } }Common codes:
unauthorized — missing/invalid publishable keynot_found — product, collection, or cart not foundbad_request — malformed body or queryvalidation_error — Zod schema rejected the bodystripe_not_enabled — checkout blocked; merchant hasn't finished Stripe onboardingcustomer_required (401) — invite-only store: the request needs a signed-in, invited customer (no token, or one that is expired or not valid here)customer_access_revoked (403) — invite-only store: the token is genuine, but the merchant withdrew this customer's access/api/storefront/storePublic facts about the store, readable before anyone signs in: { name, currency, access_mode }. access_mode is "open" or "invite_only".
A store whose access_mode is invite_only shows its products to everyone, but prices, the cart and checkout only to customers the merchant invited. An open store is unaffected by everything in this section.
price_amount: null and compare_at_price_amount: null — hidden, not zero. Price filters and price sorts are ignored for such a request.x-customer-token on every request, product reads included, once a customer is signed in. Product responses of an invite-only store are Cache-Control: private, no-store; never cache a priced response where another visitor could be served it.POST /auth/request answers { ok: true } whether or not the address is invited; POST /auth/verify never creates a customer and refuses with the same 403 for every reason.customer_required otherwise). The cart belongs to that customer and the order uses their account email; email in the checkout body is optional and ignored.customer_access_revoked), even though their token has not expired.offers, llms.txt no prices, and the Google / Meta feeds are valid but empty.Full walkthrough: docs/storefront-integration-prompt.md, section "Invite-only stores". SDK: createStorefrontClient({ …, inviteOnly: true }) and sdk.store.get() (0.12.0).
/api/storefront/productsList active products. Cursor pagination via ?limit=&cursor= (newest sort only). Optional: ?collection=:handle, ?q=search (title + description), ?tag=a&tag=b (or ?tag=a,b — ANY match), ?min_price=&max_price= (minor units), ?sort=newest|price_asc|price_desc.
/api/storefront/products/:handleSingle product by handle.
/api/storefront/products/batch?handles=a,b,cHydrate several products by handle in one call, returned in the order requested (active only, unknown handles dropped, max 50). Use for 'recently viewed' rails — track handles client-side, then batch-fetch. SDK: sdk.products.byHandles([...]).
/api/storefront/products/:handle/relatedCurated cross-sell list (max 12). Order matches what the merchant set.
/api/storefront/collectionsList collections. Cursor pagination.
/api/storefront/collections/:handleSingle collection by handle.
/api/storefront/cartsCreate a cart. Body: { currency?, email? }.
/api/storefront/carts/:idFetch a cart with totals. Includes free_shipping_threshold and remaining_to_free_shipping (both nullable) when the merchant has configured an incentive.
/api/storefront/carts/:id/linesAdd a line. Body: { variant_id, quantity }.
/api/storefront/carts/:id/lines/:lineIdUpdate quantity. Body: { quantity }. Setting quantity=0 removes the line.
/api/storefront/carts/:id/lines/:lineIdRemove a line.
/api/storefront/carts/:id/discountPreview a discount code. Body: { code }.
/api/storefront/carts/:id/shipping-ratesBody: { shipping_address }. Returns { rates: [{ id, name, price }] } — the applicable shipping methods for this cart + address, cheapest first. Render a picker, then pass the chosen id as shipping_rate_id to checkout/start.
/api/storefront/checkout/startBody: { cart_id, email, shipping_address, billing_address?, shipping_rate_id?, discount_code?, accepts_marketing?, marketing_consent?: { wording, version? } }. Returns { payment_intent_client_secret, stripe_account_id, order_preview }. Confirm with Stripe.js client-side, initialised with { stripeAccount: stripe_account_id } — the charge lives on the store’s own Stripe account.
Omit shipping_rate_id to charge the cheapest applicable rate. A chosen rate is re-validated server-side and rejected with 422 if it no longer applies (e.g. the cart total changed) — re-fetch the options when that happens.
Card data is captured by Stripe Elements on your storefront and confirmed with the returned client_secret. The platform never sees a raw card number.
/api/storefront/variants/:id/back-in-stockBody: { email }. Subscribes the visitor to a one-shot restock notification. Idempotent. When the variant total goes from 0 → >0, every pending subscriber gets a single transactional email via the Suppression Guard.
/api/storefront/products/:handle/reviewsApproved reviews + aggregate rating for the product. Cursor pagination.
/api/storefront/reviewsSubmit a review. Body: { product_id, author_name, author_email, rating (1–5), title?, body, order_id? }. Lands as `pending` until a merchant approves.
The list response includes aggregate.count and aggregate.average — drop them straight into a JSON-LD AggregateRating for SEO.
Per-customer. All wishlist requests require a customer token (x-customer-token) on top of the publishable key — see Customer auth. Each returns the full wishlist (newest first).
/api/storefront/wishlistThe customer's saved products as full product objects.
/api/storefront/wishlistAdd a product. Body: { product_id }. Idempotent. Returns { items }.
/api/storefront/wishlist/:productIdRemove a product. Returns the updated { items }.
SDK: sdk.wishlist.list() / .add(productId) / .remove(productId).
/api/storefront/signupBody: { email, first_name?, list_id?, consent?: { wording, version? } }. Subscribes the contact (or sets pending status when the list requires double opt-in). Pass the form’s opt-in text as consent: the store keeps it as proof of consent.
SDK: await sdk.newsletter.subscribe({ email, list_id?, consent? }).
/api/storefront/faqsThe merchant's published FAQ entries in display order: { items: [{ id, question, answer, position }] }. `answer` is Markdown. CDN-cacheable.
/api/storefront/contactSubmit the contact form. Body: { name, email, subject, message, order_reference?, company? }. Limited to 5/hour per (tenant, IP).
company is a honeypot — render it hidden and unreachable. A filled honeypot still returns 201 but the message is dropped, so never treat success as proof a human submitted. SDK: sdk.support.faqs() / .contact({...}).
Install @triad-solutions-se/sdk from GitHub Packages (see docs/storefront-integration-prompt.md for the .npmrc setup) and use the typed client:
import { createStorefrontClient } from "@triad-solutions-se/sdk";
const sdk = createStorefrontClient({
baseUrl: "https://your-app.com",
publishableKey: process.env.NEXT_PUBLIC_SHOPNOW_KEY!,
});
const { items, next_cursor } = await sdk.products.list({ limit: 20 });
const product = await sdk.products.get("classic-tee");
const cart = await sdk.cart.create({ currency: "USD" });
await sdk.cart.addLine(cart.id, { variant_id: product.variants[0].id, quantity: 1 });
const shipping_address = { address_line1: "123 Main", city: "Brooklyn", region: "NY", postal_code: "11201", country: "US" };
// Show the shopper the available methods, let them pick one.
const { rates } = await sdk.cart.shippingRates(cart.id, { shipping_address });
const { payment_intent_client_secret, stripe_account_id } = await sdk.checkout.start({
cart_id: cart.id,
email: "buyer@example.com",
shipping_address,
shipping_rate_id: rates[0]?.id, // the method the shopper chose
});
// The payment is a direct charge on the store's own Stripe account.
const stripe = await loadStripe(STRIPE_PUBLISHABLE_KEY, { stripeAccount: stripe_account_id });Configure outbound endpoints in /admin/settings/webhooks. Each delivery includes an x-shopnow-signature header in the format t=<unix>,v1=<hex>. Verify with your endpoint secret:
import crypto from "node:crypto";
function verify(body, header, secret) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const expected = crypto.createHmac("sha256", secret)
.update(`${parts.t}.${body}`).digest("hex");
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}