Chat API reference
Request and response formats for the health, agents and chat endpoints, with cURL, JavaScript and Python examples.
Base URL: https://YOUR-API-HOST/api/v1. Replace YOUR-API-HOST with the host shown in your workspace's Developer tab. All request and response bodies are JSON.
Authenticated endpoints need the header X-API-Key: sk-botbase-.... See API keys.
#GET /health
A liveness check. No API key needed.
curl "https://YOUR-API-HOST/api/v1/health"Response 200:
{
"status": "ok",
"version": "1.0",
"docs": "..."
}Use status for monitoring. The other fields are informational.
#GET /agents
Lists the active assistants in the key's workspace that this key may call, newest first. If the key is restricted to certain assistants, only those are listed.
curl "https://YOUR-API-HOST/api/v1/agents" \
-H "X-API-Key: $BOTBASE_API_KEY"Response 200:
{
"agents": [
{
"agent_id": "2b7f6a8e-5c1d-4f0a-9d33-6a1e2c4b8f10",
"name": "Msaidizi wa Duka",
"description": "Answers questions about our products and delivery",
"language": "Swahili",
"is_active": true
}
],
"workspace_id": "a4c0..."
}| Field | Type | Description |
|---|---|---|
agents[].agent_id | string | The ID to send to /chat. |
agents[].name | string | The assistant's name. |
agents[].description | string or null | The assistant's description. |
agents[].language | string | The assistant's configured language. |
agents[].is_active | boolean | Always true here; inactive assistants are not listed. |
workspace_id | string | The workspace the key belongs to. |
#POST /chat
Sends one message to an assistant and returns its answer.
#Request body
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | An assistant ID from /agents. |
message | string | Yes | The user's message. Leading and trailing spaces are trimmed. Must not be empty; at most 4,000 characters. |
conversation_id | string or null | No | Omit or send null to start a new conversation. Send the ID from a previous response to continue it. |
stream | boolean | No | Must be false or omitted. Streaming is not supported yet. |
#Examples
curl -X POST "https://YOUR-API-HOST/api/v1/chat" \
-H "X-API-Key: $BOTBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "YOUR_AGENT_ID",
"message": "What are your opening hours?",
"conversation_id": null
}'#Response 200
{
"answer": "Tunafungua kila siku kuanzia saa 2:00 asubuhi hadi saa 12:00 jioni.",
"citations": [
{ "source": "opening-hours.pdf", "chunk_index": 0 },
{ "source": "Contact us", "chunk_index": 2, "source_url": "https://duka-langu.co.tz/contact" }
],
"conversation_id": "f3a2c1d0-9b8e-4c7a-8d6f-1e2d3c4b5a69",
"agent_id": "2b7f6a8e-5c1d-4f0a-9d33-6a1e2c4b8f10",
"model_used": "..."
}| Field | Type | Description |
|---|---|---|
answer | string | The assistant's reply, as plain text. |
citations | array | Knowledge the answer was based on. May be empty. |
citations[].source | string | Document name or page label. |
citations[].chunk_index | integer | Which part of that source was used. |
citations[].source_url | string | Only present for website pages. |
conversation_id | string | Send this back to continue the same conversation. |
agent_id | string | The assistant that answered. |
model_used | string | Identifier of the AI model that produced the answer. Informational; do not build logic on it. |
#Conversations
- Each
/chatcall withoutconversation_idstarts a new conversation. - To keep context ("And on Saturday?"), store the
conversation_idper end user, for example per WhatsApp number, and send it with every message from that user. - A conversation belongs to one assistant. Using a
conversation_idfrom another assistant, or one that does not exist, returns404 Conversation not found. - API conversations appear in the assistant's Conversations tab in the dashboard.
#Responses are not streamed
The call returns when the full answer is ready. Answers usually take a few seconds; set your HTTP client timeout to at least 30 to 60 seconds.
#Errors
Errors from these endpoints use a flat body:
{ "error": "Invalid or revoked API key." }The full list of status codes, messages and rate limits is in Errors and limits.