LiteBot

HTTP API reference

This chapter lists every REST route LiteBot serves, grouped by mount point, with the method, path, the access it needs and what it does. Use it to find an endpoint and the permission behind it; the chapters linked from each group explain the request and response bodies. The examples use http://127.0.0.1:3345.

Authentication

Most routes need one of two credentials:

Credential How to send it Get it from
JWT access token Authorization: Bearer <token> POST /api/auth/login
API key X-API-Key: lbk_... POST /api/auth/api-keys

When both are present, the JWT is tried first. An API key acts with the role and tenant it was created with. Repeated bad API keys from one IP lock that IP out for a while.

curl -s -X POST http://127.0.0.1:3345/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"username":"admin","password":"<password>"}'
{
  "success": true,
  "data": {
    "user": { "id": "...", "username": "admin", "role": "admin", "tenantId": "default", "permissions": ["bots:read", "..."] },
    "token": "<token>",
    "refreshToken": "<refresh-token>",
    "expiresIn": "24h"
  }
}

expiresIn is JWT_EXPIRES_IN (default 24h). Exchange the refresh token for a new access token with POST /api/auth/refresh and {"refreshToken":"..."}.

Create an API key for a server such as a gateway:

curl -s -X POST http://127.0.0.1:3345/api/auth/api-keys \
  -H 'Authorization: Bearer <token>' -H 'Content-Type: application/json' \
  -d '{"name":"voice-gateway","role":"user","tenantId":"clinic-group"}'

The response carries data.key (lbk_...) once; only a hash is stored. Optional expiresAt takes a date. tenantId is honoured only for a global admin; everyone else gets keys in their own tenant.

Permissions and tenants

Permissions are <resource>:<action>. Resources: bots, documents, collections, admin, api-keys, roles, conversations, campaigns, users, tools. Actions: create, read, update, delete. In the tables, perm means requirePermission on that resource and action; admin means the admin role; login means any valid credential.

Most routes are tenant-scoped: a user or key sees only its own tenant, and another tenant's bot, conversation or campaign answers 404 as if it did not exist. A global admin sees every tenant, or narrows to one with the header X-Tenant-Id: <tenant>; an invalid value answers 400 Invalid X-Tenant-Id header. See Users, roles and tenants.

Responses and errors

Successful JSON responses have the form {"success": true, "data": ...}. Errors have success: false and an error string; some add message or details.

Status Typical body When
400 {"success":false,"error":"Validation error","details":[...]} Joi validation failed. Some routes put the Joi message straight in error
401 {"success":false,"error":"Authentication required","message":"Please provide a valid JWT token or API key"} No or bad credential
403 {"success":false,"error":"Insufficient permissions","message":"You don't have permission to update bots","required":"bots:update"} Missing permission
403 {"success":false,"error":"Admin access required"} Route needs the admin role
404 {"success":false,"error":"Bot not found: <id>"} Unknown id, or one in another tenant
429 {"error":"Too many requests from this IP, please try again later.","retryAfter":900,"limit":100} Rate limit
500 {"success":false,"error":"<message>"} Server error
503 {"success":false,"error":"Database Error",...} MongoDB error caught by the global handler

Errors that reach the global handler hide the message in production ("error":"Something went wrong!"). Errors handled inside a route return the route's own message.

Rate limit

Every /api route except /api/documents/* and /api/collections/* shares one per-IP limit: 100 requests per 15 minutes when NODE_ENV=production, 500 per 5 minutes otherwise. API_RATE_LIMIT sets the count. RateLimit-* response headers show the remaining budget. /health is outside /api and not limited.

Pagination

List routes that page take page (from 1) and limit, and return a pagination object:

{ "pagination": { "page": 1, "limit": 20, "total": 134, "totalPages": 7 } }
Route limit default and maximum Other filters
GET /api/conversations 20, max 100 botId, userId, status (active, ended), startDate, endDate, search, sortBy, sortOrder
GET /api/documents 20 See Knowledge base
GET /api/campaigns 20, max 100 status, sortBy, sortOrder
GET /api/campaigns/:id/contacts 50, max 100 status

All /api responses carry Cache-Control: no-store.

Public routes

These take no credential. Restrict who can reach them at your proxy or firewall (see Security).

Method Path Purpose
GET /health Liveness: {"status":"healthy"} or 503 when MongoDB does not answer
GET /health/ready Readiness: {"ready":true} or 503
POST /api/chat Send a message to a bot (Chat API)
GET /api/chat/session/:sessionId Session summary, including its context
DELETE /api/chat/session/:sessionId?reason= End a session and run its hooks
POST /api/chat-simple Legacy demo responder. Do not use
GET /api/chat-simple/session/:sessionId Legacy demo session
POST /api/auth/login, /api/auth/refresh Get or refresh a JWT
GET /api/websocket/stats /chat WebSocket connection counts
POST /api/campaigns/callback/:campaignId/:contactId/:token Gateway call status, signed URL (Auto-dialer)
POST /api/campaigns/webhook/:campaignId Legacy result webhook; signed only when AUTO_DIALER_WEBHOOK_SECRET is set
* /api/visual-builder/* Flow templates and validation, when ENABLE_VISUAL_EDITOR=true
WS /chat Chat WebSocket (Chat API)
WS /voice?token= or ?api_key= Voice WebSocket; checks the credential at upgrade (Voice)

Auth, API keys and roles

/api/auth and /api/auth/roles.

Method Path Access Purpose
POST /api/auth/login public Log in
POST /api/auth/refresh public New access token from a refresh token
GET /api/auth/me login Current user
GET /api/auth/api-keys perm api-keys:read List keys in scope (no secrets)
POST /api/auth/api-keys perm api-keys:create Create a key
DELETE /api/auth/api-keys/:id perm api-keys:delete Revoke a key
GET /api/auth/roles perm roles:read List roles
GET /api/auth/roles/:id perm roles:read One role
GET /api/auth/roles/list/permissions login Every permission string
POST, PUT, DELETE /api/auth/roles, /api/auth/roles/:id admin Create, change, delete a role

Users and tenants

Method Path Access Purpose
GET /api/users perm users:read List users in scope
GET /api/users/:id perm users:read One user
POST /api/users perm users:create Create a user
PUT /api/users/:id perm users:update Change a user
PUT /api/users/:id/password perm users:update Set a password
DELETE /api/users/:id perm users:delete Delete a user
GET /api/tenants login Tenants in scope (a tenant user sees its own)
POST /api/tenants admin Create a tenant
GET /api/tenants/:id/providers perm api-keys:read The tenant's own LLM keys, masked
PUT, DELETE /api/tenants/:id/providers/:provider perm api-keys:update Set, rotate or remove a tenant LLM key. The key is never echoed
GET /api/tenants/:id/usage?days=7 perm api-keys:read Tenant spend and usage, 7 or 30 days
GET /api/tenants/:id/shared-tools perm tools:read Which global tools the tenant may use
PUT /api/tenants/:id/shared-tools admin Set the allowlist {"tools":[...]}, or {"mode":"all"}

Bots

/api/bots. Every route needs a login; bot routes are tenant-scoped. See Bots and Bot configuration reference.

Method Path Access Purpose
GET /api/bots login List bots
GET /api/bots/:botId login One bot
GET /api/bots/:botId/config login Full configuration
POST /api/bots perm bots:create Create a bot
PUT /api/bots/:botId, /api/bots/:botId/config perm bots:update Change a bot. Applies live
DELETE /api/bots/:botId perm bots:delete Delete a bot
GET /api/bots/:botId/tools login The bot's tools
POST /api/bots/:botId/test perm bots:update Send a test message
GET /api/bots/:botId/export?format= perm bots:read Export as files (default), json or zip
POST /api/bots/export/bulk perm bots:read Export several bots
POST /api/bots/import perm bots:create Import an exported bot (multipart file)
POST /api/bots/generate-with-ai perm bots:create Draft a bot from a description
POST /api/bots/intent-detection, /api/bots/switching-test login Test intent routing and bot switching
GET /api/bots/stats/overview login Bot counts
GET /api/bots/analytics/summary, /trending, /health, /realtime perm bots:read Bot analytics views
GET /api/bots/analytics/:botId/detailed perm bots:read One bot's analytics
GET /api/bots/providers/status login LLM provider health
POST /api/bots/providers/health-check admin Re-check providers; clears a stuck unhealthy mark
POST /api/bots/reload admin Reload bots from disk and MongoDB. Refused with 403 when NODE_ENV=production
GET /api/bots/tools/available, /tools/stats, /tools/:toolName login Tool registry views
GET /api/bots/tools/validate/all perm bots:read Validate every tool
POST /api/bots/tools/:toolName/test perm bots:update Run a tool
POST /api/bots/tools/reload admin Reload tools. Refused in production

Tools

/api/tools, login required, tenant-scoped. See Tools.

Method Path Access Purpose
GET /api/tools login List tools
GET /api/tools/categories login Tool categories
GET /api/tools/validate login Validate loaded tools
POST /api/tools/validate-source login Check tool source before saving
GET /api/tools/:toolName login One tool, with source
POST /api/tools perm tools:create Create a tool
PUT /api/tools/:toolName perm tools:update Change a tool
DELETE /api/tools/:toolName perm tools:delete Delete a tool
POST /api/tools/:toolName/test login Run a tool with test parameters
POST /api/tools/generate-with-ai, /api/tools/edit-with-ai perm tools:create Draft or edit a tool with an LLM
POST /api/tools/reload admin Reload tools. Refused in production

Knowledge base

/api/documents and /api/collections, login required, tenant-scoped, outside the rate limit. See Knowledge base.

Method Path Access Purpose
POST /api/documents/upload perm documents:create Upload a file (multipart file)
POST /api/documents, /api/documents/batch perm documents:create Add text, one or many
GET /api/documents, /api/documents/:id perm documents:read List, read
PUT /api/documents/:id perm documents:update Change a document
DELETE /api/documents/:id, /api/documents/parent/:parentId perm documents:delete Delete one, or every chunk of an upload
POST /api/documents/search perm documents:read Semantic search
GET /api/collections perm collections:read List collections
POST /api/collections perm collections:create Create a collection
DELETE /api/collections/:name perm collections:delete Delete a collection
GET /api/collections/:name/documents, /:name/stats perm collections:read Contents and counts
GET /api/collections/reindex admin Rebuild vectors

Conversations and analytics

See Conversations and analytics.

Method Path Access Purpose
GET /api/conversations perm conversations:read List, paged and filtered
GET /api/conversations/:sessionId perm conversations:read Full transcript
GET /api/conversations/:sessionId/traces perm conversations:read Per-turn request traces
GET /api/conversations/export/:sessionId?format= perm conversations:read Export one conversation (json default)
GET /api/conversations/stats/summary perm conversations:read Counts for the same filters as the list
DELETE /api/conversations/:sessionId perm conversations:delete Delete one
POST /api/conversations/bulk-delete perm conversations:delete Delete up to 100: {"sessionIds":[...]}
GET /api/analytics/performance, /performance/:botId login System and per-bot performance
GET /api/analytics/slowest-operations, /response-timeline, /tool-performance login Latency views
GET /api/analytics/dashboard, /report login Dashboard data and report
GET /api/analytics/evidence?botId=&days= login Zip of one bot's config, conversations, traces and analytics for review
GET /api/chat/stats, /api/chat/analytics login Dashboard figures, from and to dates
GET /api/voice/stats login Active /voice sessions

Campaigns

/api/campaigns, present only when ENABLE_AUTO_DIALER=true. The full table is in Auto-dialer.

Admin and health

/api/admin needs the admin role on every route.

Method Path Purpose
GET /api/admin/providers/status Provider state
POST /api/admin/providers/:providerName/test Test one provider
POST /api/admin/providers/:providerName/hot-swap Change a provider's settings at runtime
POST /api/admin/providers/reinitialize Rebuild every provider
POST /api/admin/bots/:botId/reload Reload one bot
POST /api/admin/prompts/:filename/reload Reload one prompt file
GET /api/admin/hot-reload/status File watcher state
GET /api/admin/config/status, /config/environment Configuration state and non-secret settings
POST /api/admin/setup Create the external config directories
GET /api/admin/files/:type List files in an external config directory
POST /api/admin/files/validate Validate a config file
GET /health/detail MongoDB, vector store and version detail. 403 {"status":"forbidden"} for other roles

Voice gateway and visual builder

Method Path Access Purpose
GET /api/voice-gateway/config login Gateway voice mode settings for the dashboard (Voice)
GET /api/visual-builder/status public Whether the visual editor is on
GET /api/visual-builder/templates, /templates/:name public Flow templates
POST /api/visual-builder/validate, /convert public Check a flow, or convert it to a bot config
POST /api/chat/preview login Run an unsaved bot config (Visual flows)

The visual builder routes exist only when ENABLE_VISUAL_EDITOR=true, and they take no credential. They do not touch saved bots, but block them at your proxy if the dashboard is not public.

Where to go next