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
- Sign in to the dashboard at app.slatech.ai and open API Keys.
- Click Create key, pick the site and write the scopes the key needs, separated by commas (see below). An expiry date is optional.
- 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
| Scope | What it opens |
|---|---|
query | Asking questions: /v1/query, /v1/query/stream, feedback and image questions. The widget key has this scope. |
ingest | Writing the knowledge base: /v1/ingest/* and DELETE /v1/documents/{documentId}. |
data:read | Reading 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 }
| Status | Meaning |
|---|---|
400 | The request is invalid: a required field is missing, a value is out of range, or the file type is not accepted. |
401 | No key, or the key is invalid, expired or revoked. |
403 | The key lacks the scope, the plan does not include the feature (feature_disabled), or the browser origin is not allowed. |
404 | The job, document or answer does not exist for this site. |
413 | The uploaded file is too large. |
429 | A rate limit or the monthly allowance, see below. |
500, 502 | Something failed on our side. Safe to retry later. |
503 | The 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-Afterheader with the number of seconds to wait. Requests that send a key usually also getX-RateLimit-LimitandX-RateLimit-Remaining; treat those as a hint, not a contract, and do not hard-code a number: back off when you see429and honourRetry-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
429has noRetry-After, and its body carriescurrentUsageandmaxAllowed. 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
- Ask questions: request fields, streaming, history, feedback, images
- Manage the knowledge base: files, pages, sitemaps, text, deletion
- Read leads, conversations and analytics
- Webhooks: get events pushed to your server, signed
- Client libraries: the API from JavaScript/TypeScript and Python
- MCP server: the same knowledge base as tools for AI agents
- API reference and the machine-readable OpenAPI document