Cartbase Storefront Docs
Everything needed to build a storefront on Cartbase — every endpoint, every SDK call, every component contract. Written so an agent can build a store from these pages alone.
Storefront docs
Audience: an AGENT building a storefront from a blank Next.js app, or a custom app for the store. These docs are the entire knowledge transfer, every call shape, every curl, every setting, every component contract. If a storefront or an app can't be built from these files alone, the fix is a doc fix, never tribal knowledge.
For agents: start here
| You are | Start with |
|---|---|
| Building a new storefront from nothing | npx create-cartbase@latest my-store --key pk_…, then BUILD-A-STOREFRONT.md, the runbook; the domain files below are its reference chapters |
| Bringing an app you already have onto the store | BRING-YOUR-OWN-STOREFRONT.md: the package into that app, the rules, the mounts per admin screen, the checklist, the danger zones |
| Running the store from the terminal (products, orders, settings) | npx cartbase@latest init, then the brief it writes, CARTBASE.md; cartbase resources lists every command |
| Building an app for the store | BUILD-AN-APP.md; its chapters are the app-* files |
| Working in the store from an AI assistant | assistants.md: one address to give the assistant, the sign-in, and its tools |
Whichever door: the rules the platform enforces are rule 1 to 6 of BRING-YOUR-OWN-STOREFRONT.md, the checkout's laws are checkout.md, and every component's contract is components.md.
Every example runs
Every bash block in these pages is executed against a live platform
before a release, and a page that drifts from the platform fails that
release. The variables the blocks use are the ones a store has: BASE
(the platform origin), CLIENT_ID (the store's id) and PUBLISHABLE_KEY
(the store's key). A block marked # doc-noexec is shown and not run: it
needs a signed-in CLI, or it would act outside the store.
Per-domain file format
One file per domain. For each endpoint, in order:
- Purpose: one sentence, when a storefront calls it.
- Auth: which headers (anon
x-client-id/ publishable key / Bearer). - Request: method, path, query/body shape (jsonc block).
- Response: shape (jsonc block), with field notes.
- Working curl: executable per the contract above.
- Errors: status +
codefor every contract-listed failure. - SDK: the
@cartbase/storefront/apifunction that wraps it. - Components: which
@cartbase/storefrontUI components consume it. - Settings: admin settings that change its behavior (checkout rules, locales, consent, accounts mode…).
Files
| File | Domain |
|---|---|
| BUILD-A-STOREFRONT.md | The agent runbook, from a blank app to a completed checkout |
| BRING-YOUR-OWN-STOREFRONT.md | An app that already exists onto the Cartbase backend: the rules, the mounts per admin screen, the checklist, the danger zones |
| assistants.md | An AI assistant connected to the store: the MCP server's address, the sign-in, the tools |
| products.md | Products, variants, pricing context |
| search.md | Search, facets, related products |
| collections.md | Collections + membership listings |
| categories.md | Categories, tags, types |
| store.md | The store's identity: name, slug, brand |
| regions.md | Regions, currencies, locales |
| carts.md | Cart lifecycle + line items |
| gift-cards.md | Gift-card tender on carts |
| checkout.md | Shipping options, payment providers/collections, prepare-checkout orchestration, complete |
| orders.md | Order reads, display-id lookup, transfers |
| customers.md | Customer profile, addresses, documents |
| subscriptions.md | Subscription portal: schedule control, contract edits, payment-method recovery |
| auth.md | The code sign-in, the store's session cookie, and what the login decides |
| content.md | Pages + blogs |
| menus.md | Navigation menus |
| metaobjects.md | Merchant-defined content types |
| apps.md | A custom app's public records, read as metaobjects |
| BUILD-AN-APP.md | The app runbook, from a blank folder to an app in the admin, shared as a repository |
| app-manifest.md | Every field of cartbase.app.json, generated from the schema; app-manifest.schema.json for editors |
| app-runtime-api.md | The app's own API: its settings, its secrets, its records |
| app-cli.md | The cartbase app commands |
| reviews.md | Review widget, token wizard, photo rewards |
| integrations.md | Store config: carriers, COD, tracking block, lockers |
| consent.md | Consent Mode v2 banner config |
| experiments.md | A/B tests: a visitor's variant, and what a visitor was shown |
| marketing.md | Campaign popups: the live campaigns, the signup door |
| redirects.md | 404-path URL redirects |
| components.md | UI component families: contracts + required SDK calls |
| platform.md | Platform fingerprints: generator meta, window.Cartbase, x-cartbase-version header, cart cookie naming |