Setu API

The Setu tag and REST API for behavioural intent, smart checkout and recovery. Base URL: https://setu-api-production-a819.up.railway.app

Install the tag

Paste this before </head> in your Shopify theme (theme.liquid):

<script src="https://setu-api-production-a819.up.railway.app/setu.js"
        data-tenant-slug="ikaa"
        data-api-url="https://setu-api-production-a819.up.railway.app/api"
        data-persona-name="Jhilmil"
        data-wa-number="+918805100535"
        data-widget-color="#C9A96E"
        data-track-only="true"></script>

data-track-only="true" tracks behaviour + runs the widget but leaves native Shopify checkout untouched. Remove it to enable the hosted Setu checkout.

Start a session

POST /api/session/start
curl -X POST $BASE/api/session/start \
  -H "Content-Type: application/json" \
  -d '{"tenant_slug":"ikaa","device_type":"mobile","browser":"Safari"}'

// → { "session_id": 12, "session_token": "…", "tenant_id": 2, "intent_threshold": 70 }

You can also identify the tenant with api_key (body or X-Api-Key header).

Track an event

POST /api/event
fetch(BASE + '/api/event', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    session_token: '…',
    event_type: 'add_to_cart',
    payload: { product: 'Trinetri Earrings' }
  })
})
// → { "score": 90, "threshold": 70, "threshold_hit": true, "should_fire_widget": true }

Record a WhatsApp click

POST /api/conversion
POST /api/conversion  { "session_token": "…" }   // deduped per session

Checkout

POST /api/checkout/init
POST /api/checkout/contact
POST /api/checkout/cod-score
GET /api/checkout/pincode/:pincode
POST /api/checkout/confirm
// 1. create a checkout
POST /api/checkout/init { "tenant_slug":"ikaa", "cart_data": { "items":[…], "total":499 } }
// 2. score COD risk -> allow_cod | nudge_prepaid | cod_with_otp | prepaid_only
POST /api/checkout/cod-score { "checkout_session_id": 12, "pincode":"560001", "order_value":499 }
// 3. confirm -> creates a real Shopify order (draft -> complete)
POST /api/checkout/confirm { "checkout_session_id": 12, "payment_method":"cod", "address": {…} }
// → { "ok": true, "shopify_order_name": "#1042", "shopify_order_number": 1042 }

Event types & scores

EventPoints
page_view+5
product_view+5
product_view_repeat+15
scroll_price / scroll_size+10
add_to_cart+25
cart_view+20
checkout_hover+15
exit_intent+20
return_visitor+15

The widget fires when a session's cumulative score crosses the tenant's intent_threshold (default 70).

Widget configuration

Configured via data-* attributes on the script tag: data-persona-name, data-wa-number, data-widget-color, data-checkout-url. The widget hijacks an existing WhatsApp button on the page or shows its own.