Auth: header Authorization: Bearer <partner key>. Sandbox and production use different keys and base URLs (issued at onboarding).
One call per conversation turn, synchronous with the assistant's reply. Body ≤ 256 KB — send the last ~8–12 turns, not the whole history.
Request
{
"messages": [ {"role":"user","content":"need a laptop backpack"} ],
"geo": "MY",
"session_id": "abc123",
"lang": "en"
}
messages[]— required; conversation history, rolesuser/assistant.geo— required; user country, ISO-3166 alpha-2 (MY,ID,BR…). Inventory and rates depend on it.session_id— optional; stable per user session, for fair per-user limits and anti-fraud.lang— optional; UI language hint.- Optional header
X-Forwarded-Forwith the end-user IP for per-user limits. No PII is required.
Response 200
{
"reply": "…assistant text, always shown…",
"ad": {
"type": "product",
"title": "…", "desc": "…", "price": "MYR 129",
"image": "https://cdn…/p.jpg",
"sponsored": true,
"click_url": "https://api.indoleads.ai/c/<token>"
},
"intent": { "show_ad": true, "confidence": 0.72, "category": "…" }
}
reply— always render.ad— object ornull(no commercial intent).type:product|offer|coupon(hascode) |banner. Rendertitle,desc,price,image; link toclick_urlwithrel="sponsored noopener" target="_blank"and a visible Sponsored label. Never rewrite or wrapclick_url.intent— for your analytics.
Status codes
| Code | Meaning | What to do |
|---|---|---|
| 200 | ok (ad may be null) | show reply; if ad — render the card |
| 400 | missing messages[] / malformed JSON | fix the request |
| 401 / 403 | invalid or missing key | check Authorization |
| 429 | rate limit exceeded | do not retry; show reply without a card |
| 5xx | internal error | 1 retry with backoff, then fail-soft |
Latency: bound by the LLM — 0.8–3 s, rarely 5–8 s. Set client timeout ≥ 10 s. On error/timeout/ad:null show the reply without a card — ads must never break the chat.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article