Recipe: Build a Storefront
A storefront on the Shop API, from browsing to a placed order. Every request carries the X-STOREFRONT-KEY header; customer-scoped steps also carry the customer's Authorization: Bearer <token>.
Open each linked page for the exact request body and response shape.
1. Authenticate the storefront
Every Shop API request sends your storefront key:
X-STOREFRONT-KEY: <key>For customer-scoped actions (their cart, account, orders), first log the customer in and keep the returned token:
- Customer Login —
POST /api/shop/customers/login→data.token. Send it asAuthorization: Bearer <token>on later calls. - New customers: Customer Registration.
2. Browse the catalog
- Get Categories — build the navigation.
- List / search products — paginated with
?page=,?per_page=,?query=,?sort=, and category / price / attribute filters. - Product detail — fetch a single product for its price, images, and type-specific data (variants, bundle options, downloadable links, grouped items).
3. Cart
- Create / Get Cart — start or load the cart.
- Add to Cart —
POST /api/shop/cart/items, body{ productId, quantity, ... }. The extra fields depend on the product type (configurable products need their selected options; grouped / bundle / downloadable need their selections) — open the page for the exact shape per type. - Update Cart Item · Remove Cart Item.
- Apply Coupon · Remove Coupon.
4. Checkout (in order — the sequence is enforced)
- Set Billing Address
- Set Shipping Address
- Get Shipping Methods → Set Shipping Method
- Get Payment Methods → Set Payment Method
- Place Order
5. Post-order
- Get Customer Orders and the single order for the confirmation screen.
- Get Customer Invoices for downloadable invoices.
GraphQL variant
Every step above has a GraphQL equivalent at POST /api/graphql (see the Shop GraphQL section). When mutating the cart or placing the order, select the result fields the mutation returns (cart contents, order id, success, message) — the cart/checkout mutations are actions, so don't select an id on them.
Status codes to handle
200/201 success · 401 unauthenticated (missing key/token) · 403 forbidden · 400 bad input · 404 not found · 422 validation (e.g. quantity exceeds stock).

