Skip to content

Custom Storefront Integration Guide

Audience: Tenant admins, engineers, and DevOps building a custom customer website on your own domain.

Purpose: Public Storefront API reference — authentication, endpoints, checkout flow, prescriptions, and product detail fields.

Setup first: Connect your storefront — API key, scopes, routing, and screenshots.

This guide covers public integration only — HTTP endpoints, headers, and response shapes your website calls.

RoleUse this guide to…
Tenant adminUnderstand what your shop needs from Ailaaj One before go-live
Engineer / agencyIntegrate catalog, cart, checkout, login, and prescriptions
DevOpsConfigure environment variables on your hosting platform

1. How it fits together

Your customer website has no product or order database of its own. It calls Ailaaj One for everything:

https://{your-ailaaj-one-host}/api/storefront?tenant_id=<your-tenant-uuid>
flowchart LR
subgraph shop ["Your customer website"]
UI["Shop UI"]
SERVER["Your server / SSR layer"]
end
subgraph ailaaj ["Ailaaj One — Storefront API"]
API["/api/storefront"]
end
UI --> SERVER
SERVER -->|"API key + tenant_id"| API
API -->|"JSON success / error envelope"| SERVER
SERVER --> UI

Every response uses the same envelope:

{ "success": true, "data": { ... } }
{ "success": false, "error": { "code": "...", "message": "..." } }

Keep your API key on the server. Catalog reads may be proxied through your backend; cart, checkout, and account writes should never expose the key in the browser.


2. Authentication

Every Storefront API call requires:

ItemWhereExample
TenantQuery string?tenant_id=<your-tenant-uuid>
API keyHeaderX-API-Key: <your-storefront-api-key> or Authorization: Bearer <key>

Logged-in customer routes also require:

ItemWhereWhen
Session tokenHeader X-Storefront-Session: <token>After POST /auth/login or /auth/register

Scopes on your API key control what the key can do. A full shop needs products:read, stock:read, orders:read, orders:write, plus checkout-sessions:read, checkout-sessions:write, customers:read, customers:write, and prescriptions:write when accounts and abandoned checkout are enabled. See Connect your storefront for how to create the key and bind checkout routing.


3. Public API overview

All paths are relative to /api/storefront. Full method list and curl examples: Connect your storefront.

Catalog and search (products:read)

MethodPathPurpose
GET/configCheckout defaults (store, warehouse, shipment, payments) bound to your API key
GET/categoriesTop navigation and collection tree
GET/categories/{slug}One storefront category
GET/productsProduct listing — filters, search, pagination
GET/products/{slug}Product detail page (PDP)
GET/products/{slug}/alternatesIngredient-matched alternates
GET/products/{slug}/reviewsProduct reviews
GET/products/{slug}/auto-refillAuto-Refill preview for one product
GET/product-searchFast product search
GET/product-filtersFilter facets for listings
GET/brandsBrand list
POST/notify-requestsNotify-me when a product is back in stock

Cart and OMS orders

POST /orders is the call that creates the order in Order Management. It uses the store, warehouse, shipment, payments, and order source saved on the API key (Custom Storefront is source api).

MethodPathScopePurpose
POST/cart/quotestock:readValidate lines, stock, tax, shipping, and prescription policy
POST/ordersorders:writeCreate the OMS order. Response data.order.order_number
POST/orders/upload-urlorders:writePresigned prescription upload. Put public_url in rx_document_urls
GET/orders/confirmation—Read confirmation state (order_number + token)
POST/orders/confirmation—Confirm the order (magic link)
POST/checkout-sessionscheckout-sessions:writeSave contact, cart, and checkout step
GET/checkout-sessions/resumecheckout-sessions:readResume with query session
GET / POST/api/external/checkout-sessionscheckout-sessions:readAbandoned-session list and recovery mark

Customer account

MethodPathPurpose
POST/auth/registerCreate account
POST/auth/loginSign in
POST/auth/logoutSign out
GET/auth/meCurrent customer
POST/auth/password-reset/requestRequest reset OTP by email
POST/auth/password-reset/confirmSet new password with OTP
GET/meAccount summary
PATCH/me/profileUpdate name, email, phone
PATCH/me/passwordChange password
GET / POST / PATCH / DELETE/me/addressesSaved addresses
GET/me/ordersOMS order history (orders:read)
GET/me/orders/{id}OMS order detail (orders:read)
GET / POST/me/prescriptionsPrescription uploads
POST/me/prescriptions/upload-urlGet upload URL for Rx file
GET / PATCH/me/notificationsEmail / WhatsApp preferences
GET / POST/me/auto-refillList or create Auto-Refill plans
GET / PATCH/me/auto-refill/{referenceCode}Plan detail and edits
POST/me/auto-refill/{referenceCode}/pausePause a plan
POST/me/auto-refill/{referenceCode}/skipSkip the next cycle
POST/me/auto-refill/{referenceCode}/cancelCancel a plan

4. Typical checkout flow

sequenceDiagram
participant Shop as Your website
participant API as Storefront API
Shop->>API: GET /config
API-->>Shop: Shipment + payment options
Shop->>API: POST /cart/quote
API-->>Shop: Priced lines, Rx policy
Note over Shop: Collect address, payment, Rx if required
Shop->>API: POST /orders
API-->>Shop: order_number, status

Suggested call order

  1. GET /config — load shipment, payment methods, and routing.omsSource from the API key.
  2. POST /cart/quote — send { slug, qty } lines; receive prices, stock, and prescription_policy.
  3. If a prescription is required, POST /orders/upload-url, upload the file, and keep public_url.
  4. POST /orders — customer name, phone, address, city, payment_kind (prepaid or cod), and optional rx_document_urls.

The response data.order.order_number is the OMS order. It appears in Order Management on the store and warehouse bound to the key, with the key’s order source (Custom Storefront / api).

While the customer is still in checkout, POST /checkout-sessions saves the cart. Placing the order with the same phone marks that session converted.


5. Prescription handling

POST /cart/quote returns a prescription_policy per line. Your checkout UI should react as follows:

PolicyMeaningYour checkout
noneRegular productNo Rx step
relaxedRelaxed OTCOptional prescriber name / PMDC
narcotic or rx_requiredControlled / RxPrescription upload required

Upload options

  • Attach rx_document_urls on POST /orders during checkout, or
  • After login: POST /me/prescriptions/upload-url → upload file → POST /me/prescriptions

6. Product detail (PDP) fields

GET /products/{slug} returns data.product.pdp. Useful fields for your product page:

JSON fieldContent
overview.productOverviewProduct overview text
overview.usesUses / indications
overview.warningsAndInteractionsWarnings and interactions
overview.dosageDosage guidance
sideEffectsCommon side effects
storageStorage instructions
faqFAQ entries

Configure this content in Ailaaj One PIMS (product descriptions and storefront content). Your website only reads it through the API.


7. Environment variables

Set on your customer website host (not in this guide’s Ailaaj One admin steps — those are in Connect your storefront).

Required

VariablePurpose
VITE_STOREFRONT_API_BASE_URLhttps://{your-ailaaj-one-host}/api/storefront
VITE_STOREFRONT_TENANT_IDYour tenant UUID
STOREFRONT_SERVER_API_TOKENYour Storefront API key (server-side only)
VITE_STOREFRONT_SITE_URLPublic shop URL

Optional

VariablePurpose
VITE_STOREFRONT_API_KEYOnly if catalog is proxied from the client build — prefer server-side
HUB_INTERNAL_BASE_URLAlternate internal API origin for SSR

8. Go-live checklist

In Ailaaj One

  • Storefront API key with catalog, stock, order, checkout-session, and customer scopes, plus routing defaults (setup guide)
  • Storefront domain registered for confirmation links
  • Storefront Categories and products visible online in PIMS

On your website

  • API base URL, tenant ID, and server API token configured
  • Public shop URL matches your live domain
  • DNS / hosting points your domain at the shop

9. Troubleshooting

SymptomWhat to check
401 / 403API key, tenant ID, and scopes on the key
Empty categoryStorefront Categories and product visibility in Ailaaj One
Quote fails on stockRouting on the API key — warehouse must match available stock
Login OK, account routes failSend X-Storefront-Session on /me/* and /auth/me
Confirmation link brokenPublic shop URL and storefront domain in Ailaaj One
No email / WhatsAppCustomer notification preferences; hub notification setup

GuideContents
Connect your storefrontAPI key, scopes, routing, screenshots, curl verification
Release notes v1.1.0Recent storefront changes
Cloudflare routingCustom domain routing (if you use Cloudflare)