Indax

For AI coding agents

One page an AI coding agent can read to build a working integration.

This page is written for an AI coding agent (Claude Code, Cursor, Copilot and others). Give it this page, or the whole section as one file: https://indax.co/docs/products-api/llms-full.txt. Every docs page is also available as Markdown: add .md to its URL.

Task brief

You are adding Indax search and chat to a company's website. Indax indexes the company's public website (products, parts, pages, PDFs) and runs Dax, an assistant scoped to that company. You build the user interface; the API does the rest.

  • Base URL: https://api.indax.net
  • Key: from the company's Indax app, the API page of the Indax app. Format indax_live_ + 32 characters. Read it from configuration, never hard-code it in source control.
  • Two key kinds: website keys (allowed websites listed; used in browser code) and server-only keys (no allowed websites; used only from servers).

Endpoints

POST /v1/search
Authorization: Bearer <key>
Content-Type: application/json

{"q": "<what the visitor typed>", "domain": "<company domain, optional; default the key's company>", "limit": 10, "cursor": "<next_cursor>", "types": ["products","parts","pages","documents"], "context": { ... }}

Response:

{"id":"…","results":[{"id":"…","type":"product|part|page|document","title":"…","url":"https://<company site>/…","summary":"…","image":"…|null","part_number":"…|null","category":"…|null","page_kind":"…"}],"next_cursor":"10|null","total":23,"context_applied":false,"credits_used":1,"timing":{"search_ms":180,"total_ms":205}}

Rules: only q is required. domain picks the company (any company on the Indax network; unknown → 404 unknown_company); each result has company. filters: {category, brand, cert, specs} and facets: true filter products. Link each result to url. Show image when present. Page with cursor = previous next_cursor until it is null.

Chat (WebSocket)

wss://api.indax.net/v1/chat
→ {"type":"hello","key":"<key>","domain":"<optional company domain>","conversation_id":"<optional, to resume>","context":{...}}
← {"type":"ready","conversation_id":"…","resumed":false,"greeting":"…|null","suggested_questions":["…"]}
→ {"type":"message","text":"<visitor message, ≤2000 chars>","context":{...}}
← {"type":"status","state":"searching"}
← {"type":"results","items":[{"id","type","title","url","image","snippet"}]}   (0 or more; new items each time, append)
← {"type":"status","state":"answering"}
← {"type":"delta","text":"…"}            (repeat; append in order)
← {"type":"done","conversation_id":"…","credits_used":1,"timing":{"first_frame_ms":120,"first_results_ms":300,"first_token_ms":2400,"total_ms":5100}}
← {"type":"error","code":"…","message":"<safe to show>"}
→ {"type":"abort"}                         (stop the current answer)
→ {"type":"context","context":{...}}       (visitor moved to another page)

Rules:

  1. Send hello first, within 10 seconds. Send message only after ready.
  2. One message at a time: wait for done or error before the next. A second message while answering returns error with code: "busy".
  3. The server keeps the conversation. Send only the new text. Store conversation_id in sessionStorage and send it in hello after a reconnect.
  4. Close codes: 4401 bad or missing key → stop and show "chat unavailable"; 4403 site not allowed → stop; 4402 out of credits → stop and show a contact link; 4400 bad frame → fix the client. Any other close → reconnect after 2 seconds.
  5. Render delta text as plain text, or as Markdown with HTML disabled. Never insert it as raw HTML.

Chat (HTTP fallback)

POST /v1/chat with Authorization and {"text": "...", "conversation_id": "..."} returns text/event-stream: one data: <frame JSON> line per server frame above. Use it from a server or where WebSockets are blocked.

Context (optional, both endpoints)

{"session_id":"<your visitor id, no personal data>","current":{"url":"<page url>","title":"<page title>"},"trail":[{"url":"…","title":"…","at":"<ISO time>"}],"referrer":"<document.referrer>"}

Only URLs on the company's domain are used; the newest 20 trail pages count. It improves ranking and answers. Build it from location.href, document.title and a sessionStorage list of visited pages.

Errors (HTTPS)

{"error":"<code>","message":"<safe to show>"} with status: 400 invalid, 401 unauthorized, 402 credits_exhausted, 403 forbidden_origin | server_only_key, 429 rate_limited | budget (honor Retry-After), 502 search_failed | chat_failed (retry once), 503 unavailable.

Limits

Searches: 120 a minute per key. Chat: 20 messages every 10 minutes per visitor (session_id, else IP). Message ≤ 2,000 characters; 30 visitor messages per conversation; 20 open sockets per IP.

Credits

Search = 1 credit. Chat turn = max(1, ⌈(input − 0.9·cached + 5·output tokens) ÷ 20,000⌉), usually 1–2. Each response returns credits_used. Debounce search-as-you-type (250 ms, 2+ characters).

Minimal working client (TypeScript, browser)

const KEY = import.meta.env.VITE_INDAX_KEY as string; // a website key that allows this site
const API = "https://api.indax.net";
 
export async function search(q: string, cursor?: string) {
  const res = await fetch(`${API}/v1/search`, {
    method: "POST",
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({ q, limit: 10, cursor, context: { current: { url: location.href, title: document.title } } }),
  });
  const body = await res.json();
  if (!res.ok) throw Object.assign(new Error(body.message), { code: body.error, status: res.status });
  return body as { results: Array<{ id: string; type: string; title: string; url: string; summary: string; image: string | null }>; next_cursor: string | null };
}
 
export function chat(handlers: { onReady?: (greeting: string | null, suggestions: string[]) => void; onDelta: (t: string) => void; onResults?: (items: any[]) => void; onDone?: () => void; onError?: (msg: string) => void }) {
  let ws: WebSocket; let ready = false; let busy = false;
  const open = () => {
    ws = new WebSocket(`${API.replace("https", "wss")}/v1/chat`);
    ws.onopen = () => ws.send(JSON.stringify({ type: "hello", key: KEY, conversation_id: sessionStorage.getItem("indax_cid") ?? undefined }));
    ws.onmessage = (e) => {
      const m = JSON.parse(e.data);
      if (m.type === "ready") { ready = true; sessionStorage.setItem("indax_cid", m.conversation_id); handlers.onReady?.(m.greeting, m.suggested_questions); }
      else if (m.type === "delta") handlers.onDelta(m.text);
      else if (m.type === "results") handlers.onResults?.(m.items);
      else if (m.type === "done") { busy = false; handlers.onDone?.(); }
      else if (m.type === "error") { busy = false; handlers.onError?.(m.message); }
    };
    ws.onclose = (e) => { ready = false; if (![4400, 4401, 4402, 4403].includes(e.code)) setTimeout(open, 2000); else handlers.onError?.("Chat is not available."); };
  };
  open();
  return {
    send(text: string) {
      if (!ready || busy) return false;
      busy = true;
      ws.send(JSON.stringify({ type: "message", text, context: { current: { url: location.href, title: document.title } } }));
      return true;
    },
    stop() { ws.send(JSON.stringify({ type: "abort" })); },
    close() { ws.close(1000); },
  };
}

Common mistakes

  • Putting the key in the WebSocket URL. Send it in hello.
  • Using a server-only key in the browser (403 server_only_key), or a website key from a site not on its list (403 forbidden_origin).
  • Sending the whole conversation each turn. Send only the new message; keep conversation_id.
  • Sending a second message before done.
  • Inserting delta text as HTML.
  • Calling search on every keystroke without a debounce.
  • Sending names or emails in session_id or context.

Test checklist

  • A search for a known product returns it first, with a link to the company's page.
  • Paging with next_cursor returns no duplicates.
  • The chat streams delta frames, then done; a follow-up question keeps the context.
  • Reloading the page resumes the conversation (ready.resumed: true).
  • An invalid key shows a friendly message (close 4401 / 401).
  • 429 waits for Retry-After; 402 shows a contact link.
  • The key is read from configuration and is not in the repository.

On this page