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 all four: products:read, stock:read, orders:read, orders:write. 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/product-searchFast product search
GET/product-filtersFilter facets for listings
GET/brandsBrand list

Cart and orders

MethodPathScopePurpose
POST/cart/quotestock:readValidate cart lines, stock, and price before checkout
POST/ordersorders:writePlace an order
POST/orders/trackorders:readTrack order by number (guest)
GET/orders/confirmationRead confirmation state (magic link)
POST/orders/confirmationConfirm order (magic link)

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/ordersOrder history
GET/me/orders/{id}Order detail
GET / POST/me/prescriptionsPrescription uploads
POST/me/prescriptions/upload-urlGet upload URL for Rx file
GET / PATCH/me/notificationsEmail / WhatsApp preferences

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 and payment methods from your API key routing.
  2. POST /cart/quote — send line items; receive prices, stock errors, and whether a prescription is required.
  3. POST /orders — submit customer details, address, payment choice, and optional prescription document URLs.

Orders created through this API appear in Ailaaj One Order Management with source API / custom storefront.


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 all four scopes and 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)