Knowledge Chat API

An AI chat widget that answers strictly from the Knowledge Base collections you choose, plus a server API to search the KB and manage documents and threads. Your sk_* key routes the request to your workspace (or paired sandbox for sk_test_*).

Scopes

ScopeAllows
service.smart-chat.messages.sendSend a message to the chatbot.
service.smart-chat.threads.viewView chat threads.
service.smart-chat.threads.manageManage chat threads.
service.smart-chat.kb.viewSearch the Knowledge Base and list documents.
service.smart-chat.kb.manageManage Knowledge Base documents.
service.smart-chat.agents.viewView AI agents.
service.smart-chat.agents.manageManage AI agents.

Chat widget

Render the chat widget with one script tag. It answers only from the KB collections bound to that pk_* key, with the per-key title, colour and quick questions set in the dashboard.

<script src="https://app.softsolz.uk/softsolz.js"
  data-service-id="smart-chat"
  data-public-key="pk_live_…"
  data-mode="floating"></script>

data-mode="floating" gives a bottom-right bubble; omit it for an inline widget. See Embeds for the loader and allowlist rules.

Send a message (server)

POST /api/v1/services/smart-chat/messages · scope service.smart-chat.messages.send

curl -X POST https://app.softsolz.uk/api/v1/services/smart-chat/messages \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "message": "How do I reset my password?", "kb_only": true }'

This endpoint returns a single buffered JSON reply once the answer is fully generated; it does not stream.

Request body fields:

FieldTypeRequiredDescription
messagestringrequiredThe user message / question (min length 1).
historyarrayoptionalPrior turns as { role, content } pairs.
collection_idsarrayoptionalKB collection ids to ground in. Falls back to the API key config when omitted.
kb_onlybooleanoptionalWhen true (the default), answer strictly from the KB.
include_citationsbooleanoptionalWhether to return page-level citations.

Response fields:

FieldTypeDescription
replystringThe assistant reply text.
citationsarrayPage-level KB citations.
usageobjectModel token usage, e.g. { prompt_tokens, completion_tokens, total_tokens }.
modelstring | nullModel that produced the reply.

Search the Knowledge Base (server)

POST /api/v1/services/smart-chat/kb/search · scope service.smart-chat.kb.view

curl -X POST https://app.softsolz.uk/api/v1/services/smart-chat/kb/search \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "query": "refund policy", "top_k": 5 }'

Returns matched chunks with citations and similarity scores.

Request body fields:

FieldTypeRequiredDescription
querystringrequiredThe search query (min length 1).
top_kintegeroptionalMax chunks to return, 1-50 (default 6).
document_idsarrayoptionalRestrict to specific document ids.
tagsarrayoptionalRestrict to documents with these tags.
foldersarrayoptionalRestrict to these folders.

Response fields:

FieldTypeDescription
hitsarrayMatched chunks, each with file_name, page_number, score, snippet and text.
modelstring | nullEmbedding model used.
Method & pathScopeDoes
GET /api/v1/services/smart-chat/kb/documentskb.viewList Knowledge Base documents.
POST /api/v1/services/smart-chat/kb/documentskb.manageUpload a document.

API-key callers see only visibility=tenant documents.

Create an agent

POST /api/v1/services/smart-chat/agents · scope service.smart-chat.agents.manage

curl -X POST https://app.softsolz.uk/api/v1/services/smart-chat/agents \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{ "name": "AR Assistant",
        "instructions": "You are an AR assistant that helps chase overdue invoices.",
        "allowed_tables": ["invoices", "customers"] }'

Request body fields:

FieldTypeRequiredDescription
namestringrequiredAgent name (max 120 chars).
instructionsstringrequiredSystem instructions / persona (max 8000 chars).
descriptionstring | nulloptionalShort description (max 500 chars).
allowed_tablesarrayoptionalTenant tables the agent may read (unknown names are dropped).
visibilitystringoptionalOne of private, tenant, shared (default tenant).
shared_user_idsarrayoptionalMember ids (required when visibility is shared).
shared_role_idsarrayoptionalRole ids (when visibility is shared).

Webhook events

EventWhen
smart-chat.message.receivedThe chatbot answers a message.
smart-chat.thread.createdA new chat thread is opened.
smart-chat.kb.document.readyA Knowledge Base document finishes processing.
smart-chat.kb.document.failedA Knowledge Base document fails to process.
smart-chat.agent.invokedAn AI agent runs.

See Webhooks for payload + signature format.