Skip to main content
This example uses fetch against the public Storefront API. Catalog reads are anonymous; cart operations are protected by the capability returned with the ordering session.

1. Create a small client

Before running this in a browser, register its exact origin with Crave. Scheme, hostname, and non-default port are part of the origin, so local, preview, and production deployments need separate registrations; wildcards are not accepted.

2. Read the published catalog

3. Start an ordering session

marketplaceId is optional source attribution, such as "web"; it is not a location ID. The route already scopes the cart to locationId.

4. Add an item

Do not place the cart ID or capability in a query string. Clear the guest record after claim, cart deletion, expiry, or terminal checkout handling. If customer-authenticated access continues after claim, retain only the authoritative revision in a separate authenticated-cart record. On CART_CONFLICT, fetch the cart using X-Cart-Token, accept the latest ETag, and ask the user to retry instead of replaying the write.

Next steps

REST API Essentials

Understand every authentication boundary.

Checkout Flow

Complete payment and poll the authoritative order result.

Slack Community

Ask questions and get help from the Crave team and community.

Email Support

Reach out to hello@craveup.com for direct support.