Headless quickstart

Integrate in 15 minutes

Add profile-driven product matching to any storefront — Shopify headless, commercetools, custom React, plain HTML. One script tag. No build step required.

1

Get your API token

Issue a read-only shopper token for your merchant. This token identifies your store and is safe to embed in a public script tag — it only has read scope.

bash
curl -X POST https://api.fewture.com/v1/merchants/me/tokens \
  -H "x-merchant-id: YOUR_MERCHANT_ID" \
  -H "Content-Type: application/json" \
  -d '{"scopes": ["read"]}'
json
{
  "token": "fwtok_a1b2c3...",
  "scopes": ["read"],
  "createdAt": "2026-05-18T00:00:00.000Z"
}

Save the token value — you'll use it in the script tag below. Tokens don't expire by default. Rotate them via the same endpoint and update your script tag.

Testing locally?

The demo merchant ships with a pre-seeded token: fwtok_demo_public_readonly. Point data-api-url at http://localhost:3051 to use it.

2

Add a mount container

Place an empty <div> where you want the Fewture widget to appear — in your product page template, cart sidebar, or checkout flow.

html
<div id="fewture-app"></div>

The ID must match the data-container attribute on the script tag. The widget renders into a Shadow DOM root, so your page styles won't bleed in.

3

Load the SDK script tag

Add the script tag after your mount container. The SDK auto-mounts on DOMContentLoaded.

html
<script
  src="https://cdn.fewture.com/sdk/fewture-sdk-v0.1.0.js"
  data-merchant-id="YOUR_MERCHANT_ID"
  data-token="fwtok_a1b2c3..."
  data-api-url="https://api.fewture.com"
  data-vertical="pet"
  data-container="fewture-app"
></script>
AttributeRequiredDescription
data-merchant-idyesYour merchant ID. Used as fallback if token lookup fails.
data-tokenyesBearer token issued in step 1. Sent as Authorization header on all API calls.
data-api-urlyesBase URL of the Fewture API. Omit trailing slash.
data-verticalnoSchema vertical to use. Defaults to "pet".
data-containernoID of the mount element. Defaults to "fewture-app".
4

Verify it's working

Open the live test page — it loads the versioned SDK bundle against your local API with the demo merchant token.

bash
# Start the stack if it isn't already running
pnpm run bootstrap   # postgres + redis
pnpm run seed        # demo merchant + 277 products
pnpm --filter api run start
pnpm --filter web run dev

# Then open in your browser:
open http://localhost:3050/sdk/demo.html

You should see the three-screen widget: pet profile form → curated basket → confirm. If the basket is empty, check that pet_species is included in your profile — it's the primary exclude rule.

5

Customise branding (optional)

The widget reads your merchant's branding tokens at mount time and applies them as CSS custom properties. Update them via the Brand Studio or API — no redeployment needed.

bash
curl -X PATCH https://api.fewture.com/v1/merchants/me/branding \
  -H "x-merchant-id: YOUR_MERCHANT_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "primaryColor": "#6366f1",
    "secondaryColor": "#1e1b4b",
    "fontFamily": "Inter",
    "borderRadius": 12,
    "buttonStyle": "filled"
  }'

Or use the Brand Studio for a live preview before saving.

API reference

All endpoints are prefixed with /v1. Pass Authorization: Bearer <token> or x-merchant-id on authenticated calls.

GET/v1/schemas/:verticalFetch the rule schema for a vertical (pet, beauty, …)
POST/v1/matchRun profile → basket matching. Returns basket + explanation trace.
POST/v1/match/:id/feedbackRecord accept / edit / abandon signal on a match result.
GET/v1/merchants/meFetch your merchant record including branding tokens.
GET/v1/merchants/me/brandingPublic — returns CSS variable map. Used by SDK at mount.
PATCH/v1/merchants/me/brandingUpdate branding tokens. Invalidates the Redis cache.
POST/v1/merchants/me/tokensIssue a new scoped API token.
POST/v1/catalogue/syncBulk upsert products for this merchant.
POST/v1/catalogue/productsUpsert a single product.
DELETE/v1/catalogue/products/:skuRemove a product from the catalogue.
POST/v1/profilesCreate or update a shopper profile.
GET/v1/profiles/:shopperIdFetch a saved shopper profile.

What to do next

  • Sync your catalogue — call POST /v1/catalogue/sync with your product feed to replace the demo data.
  • Tag your products — add consumer_attributes (species, breed fit, lifestage) to each product so the rules engine can score them correctly.
  • Set up branding — run through the Brand Studio so the widget matches your storefront before you go live.
  • Run the interactive demofewture-demo.local lets you test the full profile → basket flow before embedding.