Skip to content
Elara One docs

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:

Terminal
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"
200 OK (trimmed)
{
  "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"
201 Created
{
  "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:

  1. PUT /v1/cart/addresses, then GET /v1/cart/shipping-options and PUT /v1/cart/shipping-option.
  2. POST /v1/checkout/payment-intent returns a Stripe client_secret. Your page mounts Stripe's Payment Element with it, and the shopper confirms the payment in the browser.
  3. Your server calls POST /v1/checkout/complete with the PaymentIntent and an Idempotency-Key. It answers 201 with the placed order.
Place the 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