Developer API
Ask a bot questions from your own app, website or backend. The same knowledge base and the same escalation to your team as in the messengers.
Overview
The API is one JSON endpoint per action under https://api.supportbot.info/v1. Every bot has its own key, so a request always talks to exactly one bot and its knowledge base. Conversations through the API appear in that bot's Inbox, where your team can reply. The Developer API is part of the Pro and Business plans.
| Endpoint | Use it for |
|---|---|
| POST /v1/chat | Send the conversation, get the bot's answer. |
| POST /v1/poll | Fetch replies your team wrote in the Inbox. |
| GET /v1/widget-config | Read the saved widget style. |
Authentication
Send the bot's key as a bearer token. Find it in the dashboard: open the bot, click API, then Reveal or Copy.
Authorization: Bearer sb_5d2c8e1f0a7b4c39e6d1f2a8b7c4e90d
- Rotate issues a new key and stops the old one immediately, including in every widget snippet that uses it. Put the new key in your code and snippets right after rotating.
- The website widget puts the same key in your page's HTML, so anyone can copy it and send requests that count toward your monthly answers. Rotate the key if it is misused.
- Use long random
session_idvalues, for example a UUID, because anyone with the key can read the team replies of asession_idthey know.
POST /v1/chat
Send the conversation so far; the last message must be from the user. The bot answers that last message, using the earlier ones as context.
curl https://api.supportbot.info/v1/chat \
-H "Authorization: Bearer sb_your_key" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "My X200 shows error E04"}
],
"session_id": "3f9c2a7e-5b1d-4e8a-9c6f-2d7b8e1a4c90",
"end_user_id": "customer-7421"
}'Request fields
| Field | Type | Description |
|---|---|---|
| messages | array, required | Turns with role (user or assistant) and content (a string or content blocks). The last turn must be user, and its text can be up to 8000 characters. |
| session_id | string | Your ID for this conversation; send the same value on every turn. It keeps one thread in the Inbox, lets your team take over, and is needed for /v1/poll and debounce. Without it every request opens a new Inbox conversation and team replies cannot reach you. Use a long random value. |
| end_user_id | string | Your ID for the person. Shown in the Inbox and in escalations. |
| lang | string | Two-letter default language, for example en or uk. The user's own language still wins when it is clear. |
| private | boolean | true keeps the conversation out of the Inbox and notifies nobody. The response can still have escalated: true and a line saying a person will reply, so handle that yourself. It still counts as an answer. Default false. |
| origin | string | api (default) or widget. Labels the conversation in the Inbox. |
| host | string | The website the request came from, shown in the Inbox. |
| last_seen_message_id | integer | The highest team-reply ID you already showed. Newer team replies come back in admin_messages. |
| fast | boolean | Default true: a quick first step answers greetings and questions covered by the bot's description at once. Product questions go to the full search over cases and documents, and a request for a person is handed off. false always runs the full search, which takes longer. Ignored when the last message has files. |
| debounce | number | Seconds to wait (up to 30) for more messages in the same session_id. A newer request cancels the older one, which returns debounced: true. |
Attachments
To send a photo, voice note or document, make the last message's content an array of blocks. Files go inline as base64 or a data URL; links to remote files are not fetched.
{
"role": "user",
"content": [
{"type": "text", "text": "What does this error mean?"},
{"type": "image", "data": "data:image/png;base64,iVBORw0KG..."}
]
}Each block has a type (image, audio, video, document or file), the data and an optional file name. The real file type is detected from its content. Up to 4 images (20 MB in total) are looked at. Voice and video are transcribed, documents are read. Attach files to the last message only.
Response
{
"id": "msg_18f3a9c41d2",
"session_id": "3f9c2a7e-5b1d-4e8a-9c6f-2d7b8e1a4c90",
"inbox_session_id": 4182,
"reply": "E04 means the feed roller is not picking up the sheet...",
"escalated": false,
"case_id": "a17b989687474ff2b7f624135d94d784",
"sources": [
{"title": "Case", "url": "https://supportbot.info/case/a17b989687474ff2b7f624135d94d784"}
],
"tool_calls": [],
"attachments": [],
"usage": {},
"admin_messages": []
}| Field | Meaning |
|---|---|
| reply | The answer text. On a handoff it is, or ends with, a short line saying a person will reply. Empty when queued_for_human or debounced is true. |
| escalated | true when the bot handed the conversation to your team. See Human handoff. |
| sources | Up to 5 past cases the search found for this question (title is always "Case"); the reply may not use all of them. |
| case_id | The case linked in the reply text, or null. |
| attachments | Files the bot attached as evidence, if any. |
| admin_messages | Team replies newer than your last_seen_message_id, each with id, text and ts. |
| inbox_session_id | The conversation's ID in the Inbox, when it is recorded there. |
| limited, debounced, queued_for_human | Present and true when limits stopped the answer, a newer request replaced this one, or a person currently owns the conversation. |
| tool_calls, usage | Always empty for now; ignore them. |
Human handoff
When the user asks for a person, or the bot should not answer alone, the response has escalated: true. The conversation is marked escalated in the bot's Inbox and your team gets a private message about it.
- After a handoff, or once your team replies, new messages get
queued_for_human: trueand an empty reply instead of a bot answer. This ends when someone clicks Done in the Inbox, or 3 hours after the last message from the bot or your team. - Team replies reach you in
admin_messages: either on the next /v1/chat call or by polling /v1/poll. - Show them as written by a person. The widget labels them "Human support".
POST /v1/poll
Check for new team replies without sending a message. Poll every few seconds while a conversation is escalated.
curl https://api.supportbot.info/v1/poll \
-H "Authorization: Bearer sb_your_key" \
-H "Content-Type: application/json" \
-d '{"session_id": "3f9c2a7e-5b1d-4e8a-9c6f-2d7b8e1a4c90", "origin": "api", "last_seen_message_id": 0}'
{"admin_messages": [{"id": 9, "text": "...", "ts": 1760352000000}],
"status": "escalated", "admin_typing": false}status is open or escalated. admin_typing is true while someone on your team is typing. An unknown session_id returns an empty list with status open.
Send "origin": "api" for API conversations; without it the poll looks for a widget conversation.
Embed the widget
The widget is a chat bubble that talks to /v1/chat for you. Copy the snippet from the bot's API › Chat widget tab, or write it yourself:
<script src="https://supportbot.info/widget.js" data-token="sb_your_key" data-accent="#2C6BED" data-position="bottom-right" data-greeting="Hi! Ask anything about Acme." defer></script>
It opens in its own frame, so your page's CSS does not affect it. Conversations are kept in the visitor's browser: for the current tab only, or across visits in that browser when you set data-end-user-id.
To style the widget from your website, open the bot's API › Chat widget tab and use Auto-brand from your site.
Widget attributes
| Attribute | Default | Description |
|---|---|---|
| data-token | The bot's key. Required. | |
| data-accent | #2C6BED | Color of the bubble, the user's messages and the send button. |
| data-position | bottom-right | bottom-right or bottom-left. |
| data-greeting | The first message shown when the chat opens. A greeting in Cyrillic switches the widget's labels to Ukrainian and makes Ukrainian the default reply language; otherwise the default is English. | |
| data-radius | 14 | Corner radius in pixels. |
| data-font | CSS font-family inside the widget. Empty uses the system font. | |
| data-end-user-id | Your logged-in user's ID. Shown in the Inbox and in escalations, and keeps their chats in this browser after the tab is closed. Chats do not move between devices. | |
| data-autobrand | on | on: if the bot has no saved widget CSS yet, the first page view reads your page's colors, font and logo and saves them as the bot's widget style for every page. off keeps only your attributes and the dashboard style. |
A saved style, from the dashboard or from data-autobrand, takes priority over data-accent, data-font, data-radius and data-greeting.
GET /v1/widget-config
Returns the style saved for this bot: configured plus fields such as accent, font, radius, greeting, display_name, logo_url and custom_css. configured: false means nothing is saved yet.
Limits and billing
- Each /v1/chat reply with an answer from the bot counts as one answer toward your account's monthly answers. A handoff with no answer, a request to rephrase, requests that return
queued_for_humanordebounced, and errors do not count. Polling and widget-config are free. - When limits stop the bot (this month's answers used up, extra-usage balance used up, more bots than your plan allows, or a Free plan, which doesn't include the API), /v1/chat still returns 200 with
limited: true,escalated: trueand a short reply that the assistant is temporarily unavailable and the team will follow up. The conversation is not handed off. If extra answers are on and the balance allows, the request is answered and charged 5¢. - The last message's text is limited to 8000 characters.
Errors
Errors return JSON in this shape (422 uses FastAPI's list format instead):
{"detail": {"error": {"code": "invalid_key", "message": "..."}}}| Status | Code | When |
|---|---|---|
| 400 | empty_messages, last_must_be_user, missing_session_id | No messages, the last one is not from the user, or /v1/poll without session_id. |
| 401 | missing_auth, bad_auth_scheme, invalid_key | No Authorization header, not a Bearer token, or a wrong or rotated key. |
| 413 | message_too_long | The last message's text is over 8000 characters. |
| 422 | The body is not valid JSON in the expected shape. | |
| 500 | synthesis_failed | The answer could not be produced and is not counted. You can retry; the retry repeats the message in the Inbox. |
Examples
JavaScript
const res = await fetch('https://api.supportbot.info/v1/chat', {
method: 'POST',
headers: { 'Authorization': `Bearer ${process.env.SUPPORTBOT_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
messages: history, // [{ role, content }, ...]
session_id: conversationId, // e.g. crypto.randomUUID(), kept per conversation
end_user_id: userId,
last_seen_message_id: lastSeen,
}),
});
const data = await res.json();
// data.reply, data.escalated, data.admin_messagesPython
import os, uuid, requests
session_id = str(uuid.uuid4()) # keep it for the whole conversation
r = requests.post(
"https://api.supportbot.info/v1/chat",
headers={"Authorization": f"Bearer {os.environ['SUPPORTBOT_KEY']}"},
json={"messages": [{"role": "user", "content": "Does the warranty cover the print head?"}],
"session_id": session_id},
timeout=60,
)
r.raise_for_status()
print(r.json()["reply"])