Quickstart
Call the API with your store key, list products, create a cart, add a line and take a test payment, in about five minutes.
This walk-through makes the same calls a storefront makes: read the catalogue, start a cart, put something in it and check out. Every request runs from a terminal or a server, never from a browser, because it carries your server secret.
You need an Elara One store. If you do not have one yet, get started or book a demo.
Copy your keys
In your store admin, open Settings → Storefront API. Copy the store key (it starts pk_live_, or pk_test_ on a staging store) and reveal the server secret. Put both in your shell or your server's environment:
export ELARAONE_TENANT_KEY="pk_live_…"
export ELARAONE_TENANT_SECRET="…"Keep the secret on the server
The server secret lets a caller act as your storefront server. Never put it in browser code or in a public environment variable such as NEXT_PUBLIC_*. See Authentication.
Check the connection
GET /v1/ping answers for your store when the key and secret are right.
curl https://api.elaraone.app/api/v1/ping \
-H "X-Tenant-Key: $ELARAONE_TENANT_KEY" \
-H "X-Tenant-Secret: $ELARAONE_TENANT_SECRET"A wrong or missing key answers with an error such as TENANT_KEY_MISSING (400) or TENANT_NOT_FOUND (404).
List products
Ask for variants and their prices with include. Prices are money objects in pence.
curl -G https://api.elaraone.app/api/v1/products \
-H "X-Tenant-Key: $ELARAONE_TENANT_KEY" \
-H "X-Tenant-Secret: $ELARAONE_TENANT_SECRET" \
--data-urlencode "include=variants.prices,images" \
--data-urlencode "perPage=3"{
"data": [
{
"id": 101,
"status": "published",
"name": "Oak desk lamp",
"slug": "oak-desk-lamp",
"variants": [
{
"id": 1543,
"sku": "LAMP-OAK-NAT",
"stock": 12,
"shippable": true,
"price": { "amount": 8900, "currency": "GBP", "formatted": "£89.00" }
}
],
"images": [{ "id": 55, "url": "https://…/oak-desk-lamp.webp" }]
}
],
"links": { "first": "…", "last": "…", "prev": null, "next": "…" },
"meta": { "current_page": 1, "per_page": 3, "total": 24 }
}Note a variant's id or sku: you add variants, not products, to a cart. Filters, sorting and paging are in Catalogue.
Create a cart
POST /v1/cart returns a cart_token. Send it as X-Cart-Token on every cart and checkout call. Keep it on your server, for example in an httpOnly cookie.
curl -X POST https://api.elaraone.app/api/v1/cart \
-H "X-Tenant-Key: $ELARAONE_TENANT_KEY" \
-H "X-Tenant-Secret: $ELARAONE_TENANT_SECRET"{
"data": {
"cart_token": "01JB9K3N7Q2W5X8Z4C6V1T0R3M",
"cart": {
"id": 812,
"currency": "GBP",
"lines": [],
"total": { "amount": 0, "currency": "GBP", "formatted": "£0.00" }
}
}
}Add a line
Add a variant by variant_id or sku. The Idempotency-Key makes a retried request safe: the line is added once, however many times the request is sent.
export CART_TOKEN="01JB9K3N7Q2W5X8Z4C6V1T0R3M"
curl -X POST https://api.elaraone.app/api/v1/cart/lines \
-H "X-Tenant-Key: $ELARAONE_TENANT_KEY" \
-H "X-Tenant-Secret: $ELARAONE_TENANT_SECRET" \
-H "X-Cart-Token: $CART_TOKEN" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "variant_id": 1543, "quantity": 1 }'Every cart write returns the whole cart, recalculated: lines, promotions, tax and totals. See Carts and the cart token for coupons, addresses and shipping.
Take a test payment
A checkout sets the addresses and a shipping option, then pays and places the order:
PUT /v1/cart/addresses, thenGET /v1/cart/shipping-optionsandPUT /v1/cart/shipping-option.POST /v1/checkout/payment-intentreturns a Stripeclient_secret. Your page mounts Stripe's Payment Element with it, and the shopper confirms the payment in the browser.- Your server calls
POST /v1/checkout/completewith the PaymentIntent and anIdempotency-Key. It answers201with the placed order.
curl -X POST https://api.elaraone.app/api/v1/checkout/complete \
-H "X-Tenant-Key: $ELARAONE_TENANT_KEY" \
-H "X-Tenant-Secret: $ELARAONE_TENANT_SECRET" \
-H "X-Cart-Token: $CART_TOKEN" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "payment": { "gateway": "stripe", "payment_intent": "pi_…" } }'When GET /v1/checkout/config reports "gateway_mode": "test", payments go to Stripe's test mode: pay with Stripe's test card 4242 4242 4242 4242, any future expiry date and any CVC. A declined card answers 402 PAYMENT_FAILED with a decline_code you can show the shopper.
The Checkout with Stripe guide builds this end to end, including the browser code.
Next steps
Choose a starter
Start from a working storefront in Next.js, Nuxt or Astro + Alpine.
Product listing with filters
Collections, price ranges, attributes, sorting and paging.
Checkout with Stripe
Addresses, shipping, the Payment Element and placing the order.
Errors
The error envelope and every code, with what to do about each.