GUIDES / STOREFRONT

Storefront checkout.

Show Simple's products on your own site or app and send pickup orders straight into the merchant's POS. Simple prices every cart on the server; your storefront never sends prices or totals.

Before you begin

Call the API from your own server, never from the shopper's browser. You need a key with catalog:read, inventory:read, customers:read, customers:write, carts:write, orders:write, orders:read and, to cancel, orders:cancel. Checkout must be enabled for the environment.

export SIMPLE_API_BASE_URL=https://sandbox.simpleposapi.simplecommerce.io
export SIMPLE_API_KEY=simple_test_…   # from your server's secret store, never the browser

1. Sync the catalog

Every active product with a priced variant is in the catalog. Read it page by page, then keep it current with updated_since and remove tombstones, as described in Pagination and sync. Check stock just before showing a product as available.

curl "$SIMPLE_API_BASE_URL/api/v1/public/catalog/products?store_id=$STORE_ID&limit=100" \
  --header "Authorization: Bearer $SIMPLE_API_KEY"

curl "$SIMPLE_API_BASE_URL/api/v1/public/catalog/availability?store_id=$STORE_ID&variant_ids=$VARIANT_ID" \
  --header "Authorization: Bearer $SIMPLE_API_KEY"

2. Find or create the customer

Every cart belongs to a customer assigned to the store. Look the shopper up by email, and create them if they are new.

curl "$SIMPLE_API_BASE_URL/api/v1/public/customers?email=buyer@example.com" \
  --header "Authorization: Bearer $SIMPLE_API_KEY"

# Not found? Create one in the store:
curl --request POST "$SIMPLE_API_BASE_URL/api/v1/public/customers" \
  --header "Authorization: Bearer $SIMPLE_API_KEY" --header "Content-Type: application/json" \
  --data '{"store_id":"'$STORE_ID'","name":"A Buyer","email":"buyer@example.com","phone":"+15551234567"}'

3. Price a cart

Send variants and whole quantities; Simple returns prices, tax, fees and the total. Show the shopper these numbers exactly. To change items, PATCH /carts/{cart_id} with the current version and the full new item list; you get a new version. Carts expire after 24 hours and do not reserve stock.

curl --request POST "$SIMPLE_API_BASE_URL/api/v1/public/carts" \
  --header "Authorization: Bearer $SIMPLE_API_KEY" \
  --header "Idempotency-Key: $(uuidgen)" --header "Content-Type: application/json" \
  --data '{
    "store_id": "'$STORE_ID'",
    "customer_id": "'$CUSTOMER_ID'",
    "fulfillment": "pickup",
    "items": [{ "variant_id": "'$VARIANT_ID'", "quantity": 2 }]
  }'
{
  "id": "…", "version": 1, "status": "active", "currency": "USD",
  "items": [ … ], "subtotal": "24.00", "discount": "0.00", "tax": "1.98",
  "fee_total": "0.00", "total": "25.98", "expires_at": "…", "order_id": null
}

4. Place the order

Submit the cart id and the version the shopper accepted, plus your own external_order_id (unique per integration). Simple re-prices and checks stock in the same transaction, then creates an unpaid pickup order, its invoice and stock movements. If prices changed or stock ran out you get 409: fetch the cart, show the new total, and ask the shopper again. Simple never charges a card through this API; the shopper pays at pickup.

curl --request POST "$SIMPLE_API_BASE_URL/api/v1/public/orders" \
  --header "Authorization: Bearer $SIMPLE_API_KEY" \
  --header "Idempotency-Key: $ORDER_KEY" --header "Content-Type: application/json" \
  --data '{ "cart_id": "'$CART_ID'", "cart_version": 1, "external_order_id": "web-1007" }'

Generate the Idempotency-Key once per checkout attempt and reuse it for retries after a timeout: Simple returns the original order rather than creating a second one.

5. Track and cancel

Read orders with GET /orders/{order_id}, or subscribe to order.updated and order.cancelled webhooks to hear about changes made in the store. You can cancel an order your integration created while it is unpaid and not yet picked up; Simple puts the stock back.

curl --request POST "$SIMPLE_API_BASE_URL/api/v1/public/orders/$ORDER_ID/cancel" \
  --header "Authorization: Bearer $SIMPLE_API_KEY" \
  --header "Idempotency-Key: $(uuidgen)" --header "Content-Type: application/json" \
  --data '{ "reason": "customer_request" }'

Current limits

  • Pickup only; delivery checkout is not available yet.
  • USD and EUR stores only; whole quantities only.
  • Promotions, payment-dependent fees and taxable fees are refused rather than priced incorrectly.
  • Paid orders cannot be cancelled through the API; refund them in Simple.