Developer Guide

API: Getting Started

Your knowledge base over plain HTTPS and JSON: ask questions, add content, read leads and conversations. One base URL, one header.

Base URL and authentication

Every endpoint lives under https://api.slatech.ai. Requests and responses are JSON, except file and image uploads, which are multipart/form-data. Each request carries your key in one header:

Header
X-Api-Key: <your key>

A missing, invalid, expired or revoked key is refused with 401 before anything else happens.

Get a key

  1. Sign in to the dashboard at app.slatech.ai and open API Keys.
  2. Click Create key, pick the site and write the scopes the key needs, separated by commas (see below). An expiry date is optional.
  3. Copy the key from the next screen. It is shown once and cannot be recovered afterwards: if you lose it, create a new one.

A key is 64 hexadecimal characters. It belongs to exactly one site, and the site comes from the key alone: no endpoint takes a site id, so a key cannot reach another site's content.

Every site also gets a key automatically when it is added. That key carries query only, because it is the one you paste into your page markup for the chat widget, where anyone can read it.

Scopes

ScopeWhat it opens
queryAsking questions: /v1/query, /v1/query/stream, feedback and image questions. The widget key has this scope.
ingestWriting the knowledge base: /v1/ingest/* and DELETE /v1/documents/{documentId}.
data:readReading leads and conversations (/v1/zapier/*) and aggregate analytics (/v1/embed/analytics/*).

To be exact about how they are checked: the ask endpoints accept any active key of the site, whatever its scopes. ingest and data:read are enforced, and a valid key without the scope gets 403.

Keep write and data keys on your server. A key with ingest can change what your assistant answers, and a key with data:read reads leads with their contact details. Neither belongs in browser code. Give each integration its own key, so you can revoke one without touching the others. A change to a key's scopes or a revocation can take up to a minute to apply.

Your first request

Ask the site's knowledge base a question:

cURL
curl -X POST https://api.slatech.ai/v1/query \
  -H "X-Api-Key: $SLATECH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question": "What are your opening hours?"}'
JavaScript
// Server-side (Node 18+). Keep the key out of browser code.
const res = await fetch("https://api.slatech.ai/v1/query", {
  method: "POST",
  headers: {
    "X-Api-Key": process.env.SLATECH_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ question: "What are your opening hours?" }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
const data = await res.json();
console.log(data.answer, data.sources);
Python
import os
import requests

resp = requests.post(
    "https://api.slatech.ai/v1/query",
    headers={"X-Api-Key": os.environ["SLATECH_API_KEY"]},
    json={"question": "What are your opening hours?"},
    timeout=60,
)
resp.raise_for_status()
data = resp.json()
print(data["answer"])
C#
using System.Net.Http.Json;
using System.Text.Json;

using var http = new HttpClient { BaseAddress = new Uri("https://api.slatech.ai/") };
http.DefaultRequestHeaders.Add("X-Api-Key", Environment.GetEnvironmentVariable("SLATECH_API_KEY"));

var resp = await http.PostAsJsonAsync("v1/query", new { question = "What are your opening hours?" });
resp.EnsureSuccessStatusCode();
var data = await resp.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine(data.GetProperty("answer").GetString());

The answer comes back with the sources it was grounded in. The ask guide covers the full request, streaming, conversation history and feedback.

Client libraries

Instead of writing the HTTP requests yourself, you can use the official libraries for JavaScript/TypeScript and Python. They cover every operation of the API, stream answers, turn errors into exceptions and verify webhook signatures:

npm
npm install @slatech/bot-sdk
pip
pip install slatech

The client libraries guide lists every method and the operation it calls.

Calling from a web page

A request sent by a browser carries an Origin header. If the site's settings list allowed origins, the ask and knowledge-base endpoints refuse other origins with 403 and {"error": "Origin not allowed"}. Requests from your server carry no Origin and are not affected.

Errors

Errors are JSON with an error field. Request validation adds the failing fields:

JSON
// Most errors
{ "error": "Invalid or revoked API key." }

// 400 from request validation
{
  "error": "Validation failed",
  "details": [
    { "field": "TopK", "message": "TopK must be between 1 and 20." }
  ]
}

// 403 when the plan does not include the feature
{
  "error": "feature_disabled",
  "feature": "zapier",
  "message": "This feature (zapier) is not enabled for your plan. Contact support to upgrade."
}

// 429 from the monthly allowance (no Retry-After header)
{ "error": "...", "currentUsage": 100, "maxAllowed": 100 }
StatusMeaning
400The request is invalid: a required field is missing, a value is out of range, or the file type is not accepted.
401No key, or the key is invalid, expired or revoked.
403The key lacks the scope, the plan does not include the feature (feature_disabled), or the browser origin is not allowed.
404The job, document or answer does not exist for this site.
413The uploaded file is too large.
429A rate limit or the monthly allowance, see below.
500, 502Something failed on our side. Safe to retry later.
503The assistant is temporarily unavailable; the body carries "reason": "provider_unavailable". Retry later.

Rate limits and allowances

A 429 means one of two things, and the response tells you which:

  • Rate limit. Requests are counted per key over short windows. A rejected request carries a Retry-After header with the number of seconds to wait. Requests that send a key usually also get X-RateLimit-Limit and X-RateLimit-Remaining; treat those as a hint, not a contract, and do not hard-code a number: back off when you see 429 and honour Retry-After.
  • Monthly allowance. Answers are counted against the site's plan, and documents against the plan's document allowance. When the plan refuses a request, the 429 has no Retry-After, and its body carries currentUsage and maxAllowed. Retrying will not help until the allowance resets or the plan changes.
Python
import os
import time
import requests

def ask(question):
    for attempt in range(3):
        resp = requests.post(
            "https://api.slatech.ai/v1/query",
            headers={"X-Api-Key": os.environ["SLATECH_API_KEY"]},
            json={"question": question},
            timeout=60,
        )
        retry_after = resp.headers.get("Retry-After")
        if resp.status_code == 429 and retry_after:
            # Rate limit: wait as long as the server says, then try again.
            time.sleep(int(retry_after))
            continue
        # A 429 without Retry-After is the monthly allowance: retrying will not help.
        resp.raise_for_status()
        return resp.json()
    raise RuntimeError("still rate limited after 3 attempts")
JavaScript
async function ask(question) {
  for (let attempt = 0; attempt < 3; attempt++) {
    const res = await fetch("https://api.slatech.ai/v1/query", {
      method: "POST",
      headers: {
        "X-Api-Key": process.env.SLATECH_API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ question }),
    });
    const retryAfter = res.headers.get("Retry-After");
    if (res.status === 429 && retryAfter) {
      await new Promise((r) => setTimeout(r, Number(retryAfter) * 1000));
      continue;
    }
    if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
    return res.json();
  }
  throw new Error("still rate limited after 3 attempts");
}

Plan features

The data endpoints under /v1/zapier/ and the MCP server belong to plan features. When your plan does not include one, the API answers 403 with "error": "feature_disabled" and the name of the feature, even for a valid key with the right scope.

Where next