API reference
Version 1 · Base URL https://askbit.io
1. Overview
Bit's API lets your own code keep your assistant's knowledge up to date: your site's build can send every page when you deploy, or your CMS can send an article the moment it's published, instead of waiting for Bit to read your site again.
- Every request goes to
https://askbit.ioover HTTPS, with a JSON body where there is one. - Responses are JSON. Errors have an
errorcode (see Errors). - Your site id is in your dashboard's address (
/dashboard/{siteId}), andGET /v1/keyreturns it.
More endpoints will come on the same keys, starting with reading leads and conversations.
2. Authentication
Owners and admins make keys in the dashboard, under Settings, Advanced, API keys. A key looks like bit_ followed by 43 letters, digits, - and _. It's shown once: store it in your server's environment variables, never in a web page or an app people can download, because anyone holding it can use it.
Send it with every request:
Authorization: Bearer bit_YOUR_KEYEach key works for one site and carries scopes, chosen when it's made:
| Scope | Lets the key |
|---|---|
knowledge:write | send pages to the site's knowledge, and remove them |
site:read | read the site's id, assistant name and domains, and revoke itself |
We keep only a fingerprint of each key, so a lost key can't be shown again: revoke it in the dashboard and make another. A revoked key stops working at once. The WordPress plugin makes its own key when you press Connect; it shows in the same list.
3. Send content
POST/v1/sites/{siteId}/knowledge
Scope knowledge:write. Adds or updates the documents you send, matched by url, and removes the addresses in remove. A document whose content hasn't changed since last time is left alone, so sending everything again is cheap. The assistant uses new content from its next reply.
Request body
| Field | Type | What it is |
|---|---|---|
documents | array, required | Up to 2,000 documents to add or update. Can be empty when you only remove. |
remove | array of strings | Up to 500 addresses to forget, whatever put them there (a page Bit read from your site, too). An address that's also in documents is kept. |
complete | boolean | Default false. When true, this request is everything you send: documents sent before through the API (or the WordPress plugin) that aren't in it are removed. Pages Bit read from your site and files you uploaded are never removed this way. Only use it when one request holds all your content. |
A document
| Field | Type | What it is |
|---|---|---|
url | string, required | Its address, up to 500 characters. For pages on your own site use the path without a trailing slash (/pricing): the same key Bit gives a page it read, so yours replaces that copy. Unique within a request. |
kind | string, required | What it is, up to 40 characters: page, post, faq, product, service, policy… |
title | string, required | Up to 300 characters. |
summary | string | One or two sentences, up to 500 characters. |
body | string, required | The text, up to 200,000 characters. Plain text or light Markdown; ## headings help the assistant find the right part of a long page. |
updatedAt | string | When it last changed, as an ISO 8601 date. Optional. |
Response
200 with counts: documents added, updated, unchanged and removed, and how many searchable pieces were stored.
{
"added": 1,
"updated": 0,
"unchanged": 0,
"removed": 1,
"chunks": 3,
"data": []
}4. Check a key
GET/v1/key
Scope site:read. Returns the key you called with and its site. Use it to check a key works, and that it's for the site you think.
{
"key": { "name": "Site build", "kind": "manual", "scopes": ["site:read", "knowledge:write"] },
"site": {
"id": "acme",
"assistant": "Bit",
"domains": ["acme.com", "www.acme.com"],
"loader": "https://askbit.io/widget/loader.js",
"dashboard": "https://askbit.io/dashboard/acme"
}
}5. Revoke a key
DELETE/v1/key
Scope site:read. Revokes the key you called with, for example when your integration is uninstalled. Answers 204 with no body. After that the key gets 401.
6. Errors
Errors answer with a status and a JSON body such as { "error": "bad_key" }.
| Status | error | What happened |
|---|---|---|
| 400 | invalid_json | The body isn't JSON. |
| 400 | invalid_body | A field is missing, too long or the wrong type. issues lists up to five, with the path to each. |
| 401 | missing_key | No Authorization: Bearer header, or it isn't shaped like a key. |
| 401 | bad_key | The key is wrong, revoked, or for another site. |
| 403 | missing_scope | The key works but doesn't have the scope this needs (scope says which). |
| 404 | site_not_found | No site with that id. |
| 500 | ingest_failed | Something went wrong storing it. Try again later; if it keeps happening, tell us. |
7. Limits and good practice
- Keep each request under 4 MB. About 100 ordinary pages fits easily. Send a big site in batches, one after another rather than all at once.
- Send changes, not everything, day to day. Unchanged documents are skipped, but a large first send takes a while: allow up to a few minutes and use a long timeout.
- Retry with a pause on network errors and
5xx, waiting longer each time. Don't retry a4xxwithout fixing the request. - Send what visitors can read. Leave out drafts, private pages and anything behind a login: the assistant may quote what you send.
- Prices and stock for a connected store are checked live; you don't need to send them.
8. Examples
curl
curl -X POST https://askbit.io/v1/sites/YOUR_SITE_ID/knowledge \
-H "Authorization: Bearer $BIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"documents": [
{
"url": "/pricing",
"kind": "page",
"title": "Pricing",
"summary": "Plans and what each includes",
"body": "## Starter\nRs 4,999 a month for one location.\n\n## Growth\nRs 9,999 a month, up to five locations."
}
],
"remove": ["/old-pricing"]
}'Node
// Node 18+ (fetch is built in). Keep the key in an environment variable.
const res = await fetch("https://askbit.io/v1/sites/YOUR_SITE_ID/knowledge", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BIT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
documents: [
{ url: "/blog/opening-hours", kind: "post", title: "New opening hours", body: "From 1 December we open at 9am." },
],
}),
});
if (!res.ok) throw new Error(`Bit answered ${res.status}: ${await res.text()}`);
console.log(await res.json()); // { added: 1, updated: 0, unchanged: 0, removed: 0, chunks: 1, data: [] }Python
import os, requests
res = requests.post(
"https://askbit.io/v1/sites/YOUR_SITE_ID/knowledge",
headers={"Authorization": f"Bearer {os.environ['BIT_API_KEY']}"},
json={
"documents": [
{"url": "/faq", "kind": "faq", "title": "FAQ", "body": "## Do you deliver?\nYes, across Lahore in 2 days."}
]
},
timeout=120,
)
res.raise_for_status()
print(res.json())A whole site, in batches
// Sending a whole site: batches of 100, one after another, then one final call that removes
// anything you didn't send. Pages Bit read from your site or files you uploaded are never touched.
const all = await loadEveryPage(); // your own code: [{ url, kind, title, body }, …]
for (let i = 0; i < all.length; i += 100) {
await push({ documents: all.slice(i, i + 100) });
}
// Optional: forget pages you deleted since last time (keep a list of what you sent before).
await push({ documents: [], remove: deletedUrls });9. Signed pushes from your build
Before API keys, a site's build could send content signed with a shared secret instead of a key. It still works and takes the same body. Choose the secret in Settings, Advanced, Content push, then sign each request with an x-bit-signature header. A signature is good for 5 minutes either side of the time in it.
// The signature header: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
import { createHmac } from "node:crypto";
const body = JSON.stringify({ documents, complete: true });
const t = Math.floor(Date.now() / 1000);
const v1 = createHmac("sha256", process.env.BIT_PUSH_SECRET).update(`${t}.${body}`).digest("hex");
await fetch("https://askbit.io/v1/sites/YOUR_SITE_ID/knowledge", {
method: "POST",
headers: { "Content-Type": "application/json", "x-bit-signature": `t=${t},v1=${v1}` },
body,
});For anything new, use an API key: it's simpler, and you can see when it was last used and revoke it.


