Build a headless storefront
A headless storefront replaces the marketplace’s theme with a front end you build yourself, in Next.js, Nuxt, Astro or anything else, while Kreezalid keeps the catalog, the vendors, the orders and the payouts. If you only want to change how the marketplace looks, a theme is far less work.
Who calls what
Section titled “Who calls what”| Part | Calls | With |
|---|---|---|
| Your server (rendering, API routes) | Admin API | Admin API credentials, server-side only |
| The visitor’s browser | Front API | The member’s token, or nothing for a guest |
| Kreezalid | Your webhook endpoint | Signed webhooks |
The Front API acts for one visitor or member; it does not list the marketplace catalog. The catalog is read by your server, cached, and rendered into your pages.
1. Render the catalog from your server
Section titled “1. Render the catalog from your server”-
Navigation:
GET /front_api/v1/categoriesneeds no credentials and returns the marketplace’s categories with theirid. -
Category pages:
GET /api/v1/listingswithcategory_id,status=publishedandadmin_status=approved, paged withpageandlimit(100 at most), trimmed withfields. See Pagination and filtering. -
Product pages:
GET /api/v1/listings/{id}. The listing comes back underproduct, with its images, attributes and vendor. -
Vendor pages:
GET /front_api/v1/directories/{user_id}for the public profile andGET /front_api/v1/reviews/user/{user_id}for the reviews.
Leave out listings whose visibility is search or none from category pages. Rebuild or
revalidate pages from the listing.creation, listing.update and listing.delete
webhooks instead of short cache lifetimes. The Admin API has no
enforced rate limit, which is not a reason to call it on
every page view.
2. Members
Section titled “2. Members”From the browser, call the Front API on the marketplace’s primary address. Cross-origin requests are allowed, so your front end can live on its own domain:
- sign-up:
POST /front_api/v1/account/createwithemail,passwordand thegroup_idof the customer group; - login:
POST /front_api/v1/auth/login, then sendAuthorization: Bearer <token>; - the current member:
GET /front_api/v1/auth/me.
Keep the token where your front end keeps secrets for the session, and clear it on logout: logging out does not revoke it. Details in Authentication.
3. Cart
Section titled “3. Cart”The cart is the Front API’s: create it with POST /front_api/v1/carts, keep its url_key,
add listings with POST /front_api/v1/carts/{url_key}, and show it with
GET /front_api/v1/carts/{url_key}. A guest can fill a cart; it is attached to their account
once they sign in. The full sequence, delivery methods and addresses included, is in
Build a mobile app: it is the same for a
web front end.
Treat the url_key like a session secret: whoever knows a guest’s url_key can read and
change that cart.
4. Payment
Section titled “4. Payment”Choose one of two paths.
The hosted checkout. Send the member to the marketplace’s own checkout for the cart, at
https://<primary address>/checkout/shipping/cart/{url_key}. The marketplace’s payment
provider takes the payment and Kreezalid creates the orders, sends the emails and handles the
vendor payouts. The checkout runs on the marketplace’s domain with its own browser session: a
Front API token does not sign the member in there.
Your own payment provider. Take the payment in your front end, then let your server
record it with POST /api/v1/checkout/preauth-success. Kreezalid closes the cart and passes
the orders to the vendors, but capturing, refunding and paying vendors out stay with you.
See Record orders paid outside Kreezalid.
5. After the purchase
Section titled “5. After the purchase”- The member’s orders:
GET /front_api/v1/ordersandGET /front_api/v1/orders/{id}. - Order follow-up in your own systems: the
order.status.*webhooks. See Sync orders to an ERP.
Checklist
Section titled “Checklist”- No Admin API credentials in any code or variable sent to the browser.
- Catalog pages show only
published,approvedlistings visible in the catalog. - Pages are refreshed from listing webhooks, and webhook signatures are verified.
- A
403from the Front API sends the member back to the login screen. - Every Front API response is checked for its
successorstatusfield. See Errors.