Skip to main content

API Reference

RAG-DocBot exposes a RESTful HTTP API. Interactive documentation (Swagger UI) is available at http://<host>:8000/docs.


Endpoints

Health

MethodEndpointAuthDescription
GET/api/healthPublicReturns service health status

Authentication

MethodEndpointAuthDescription
POST/api/auth/loginPublicLogin and receive access + refresh tokens
POST/api/auth/refreshPublicExchange a refresh token for a new access token
GET/api/auth/meRequiredGet the current authenticated user
GET/api/auth/usersAdminList all users
POST/api/auth/usersAdminCreate a new user
GET/api/auth/users/{id}AdminGet a specific user
PUT/api/auth/users/{id}AdminUpdate a user's password or role
DELETE/api/auth/users/{id}AdminDelete a user
PUT/api/auth/passwordRequiredChange the current user's password

Chat

MethodEndpointAuthDescription
POST/api/chatRequiredSend a message and receive an AI response grounded in indexed documents. Supports SSE streaming via Accept: text/event-stream.

Standard (JSON) response

Add Content-Type: application/json or omit the Accept header to receive a single JSON object.

Response fields (selected):

FieldTypeDescription
answerstringThe AI-generated answer
sourcesarraySource chunks used to ground the answer
token_budgetobject | nullToken budget diagnostics (see below)
retrieval_settingsobjectEffective retrieval settings used for this query
timingobjectPer-stage timing information (classify, retrieve, generate)

token_budget object:

FieldTypeDescription
limitintegerMaximum tokens allowed in the context window
estimated_promptintegerEstimated tokens consumed by the assembled prompt
reserved_completionintegerTokens reserved for the model's completion
chunks_droppedintegerNumber of low-relevance chunks trimmed to fit the budget

token_budget is null when budget management was not applied (e.g. the prompt fit within the limit with no trimming needed).

SSE streaming response

Set Accept: text/event-stream to receive the answer as a stream of Server-Sent Events. The request body is identical to the standard JSON mode.

POST /api/chat HTTP/1.1
Accept: text/event-stream
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: application/json

{"query": "What is the refund policy?", "conversation_id": "..."}

Each event carries a JSON payload:

Event typePayloadDescription
delta{"text": "..."}Next token(s) from the LLM
done{"sources": [...], "token_budget": {...}, "retrieval_settings": {...}, "timing": {...}}Stream complete — same metadata fields as the JSON response
error{"detail": "..."}Pipeline error; stream is closed after this event

Conversation history is persisted after the stream completes, identical to non-streaming mode.

Documents

MethodEndpointAuthDescription
POST/api/docs/uploadEditor+Upload a document for indexing
GET/api/docsRequiredList all indexed documents
DELETE/api/docs/{id}Editor+Delete a document
DELETE/api/docs/bulkEditor+Delete multiple documents

Connectors

MethodEndpointAuthDescription
GET/api/connectorsRequiredList connectors
POST/api/connectorsAdminCreate a connector
GET/api/connectors/{id}RequiredGet a connector
PUT/api/connectors/{id}AdminUpdate a connector
DELETE/api/connectors/{id}AdminDelete a connector
POST/api/connectors/{id}/scanEditor+Trigger a connector scan
POST/api/connectors/sync-allEditor+Sync all connectors

Metadata Rules

MethodEndpointAuthDescription
GET/api/metadata/{source_id}/rulesRequiredList all metadata extraction rules for a source
POST/api/metadata/{source_id}/rulesEditor+Create a new metadata rule
PUT/api/metadata/{source_id}/rules/{rule_id}Editor+Update a metadata rule
DELETE/api/metadata/{source_id}/rules/{rule_id}Editor+Delete a metadata rule
POST/api/metadata/{source_id}/test-ruleEditor+Test a pattern against sample text without saving
POST/api/metadata/{source_id}/refreshEditor+Re-apply rules to existing chunks (async job)

source_id can be either a connector ID or an integration ID.

Metadata Rules endpoints require a Pro plan or higher.

Metadata rule fields:

FieldTypeRequiredDescription
field_namestringYesThe metadata key to extract (e.g. artikel, entity_id)
patternstringYesPython regex with one capture group — used during document ingestion
query_patternstring | nullNoOptional separate regex used at query-time classification. When omitted, pattern is used for both ingestion and queries
scopestringYesWhere to search: full, header, or filename
levelstringYesdocument (once per document) or chunk (per chunk with inheritance)
chunk_boundarybooleanNoWhen true, rule matches act as document pre-split boundaries during indexing. Default false.
priorityintegerNoHigher numbers are evaluated first; default 0
source_idstringResponseSource identifier in responses (connector or integration ID)
source_typestringResponseSource type in responses: connector or integration

Analytics

All Analytics endpoints require a Pro plan or higher.

MethodEndpointAuthDescription
GET/api/analytics/{source_id}/chunk-size-distributionRequiredHistogram of chunk character lengths with summary stats
GET/api/analytics/{source_id}/metadata-hit-rateRequiredPer-rule match rate across documents/chunks
GET/api/analytics/{source_id}/metadata-coverageRequiredPer-field metadata coverage ratio
GET/api/analytics/{source_id}/chunks-per-documentRequiredChunks produced per document with summary stats
GET/api/analytics/{source_id}/inheritance-ratioRequiredSelf-matched vs inherited vs empty breakdown for chunk-level rules
GET/api/analytics/{source_id}/empty-metadataRequiredCount of chunks with no metadata and sample document IDs
GET/api/analytics/{source_id}/rule-priority-auditRequiredRule winner counts for overlapping field priorities

Index

MethodEndpointAuthDescription
GET/api/index/statsRequiredView vector index statistics
POST/api/index/rebuildEditor+Rebuild the entire vector index

Jobs

MethodEndpointAuthDescription
GET/api/jobsRequiredList background jobs
GET/api/jobs/{id}RequiredGet a specific job
POST/api/jobs/{id}/cancelEditor+Cancel a running job

Integrations

MethodEndpointAuthDescription
GET/api/integrationsRequiredList integrations
POST/api/integrationsAdminCreate an integration
GET/api/integrations/{id}RequiredGet an integration
PUT/api/integrations/{id}AdminUpdate an integration
DELETE/api/integrations/{id}AdminDelete an integration
POST/api/integrations/{id}/syncEditor+Trigger an integration sync

Job Schedules

Job Schedules endpoints require a Pro plan or higher.

MethodEndpointAuthDescription
GET/api/schedulesAdminList all configured job schedules
POST/api/schedulesAdminCreate a new schedule (connector or integration sync)
GET/api/schedules/{id}AdminGet a specific schedule
PUT/api/schedules/{id}AdminUpdate a schedule (cron expression, enabled flag)
DELETE/api/schedules/{id}AdminDelete a schedule

Schedule fields:

FieldTypeDescription
source_typestringconnector or integration
source_idstringID of the connector or integration to sync
cronstringCron expression (e.g. 0 2 * * * for daily at 02:00 UTC)
enabledbooleanWhether the schedule is active
last_runstring | nullISO-8601 timestamp of the last triggered run
next_runstring | nullISO-8601 timestamp of the next scheduled run

Audit Log

Audit Log endpoints require an Enterprise plan.

MethodEndpointAuthDescription
GET/api/auditAdminQuery the audit log (supports filtering by event type, user, and date range)
GET/api/audit/{id}AdminGet a specific audit log entry
GET/api/audit/configAdminGet current retention policy configuration
PUT/api/audit/configAdminUpdate the retention policy

Audit event types:

EventDescription
chat.queryUser submitted a chat query
sync.allSync-all triggered (connector or integration)
config.updateSystem configuration changed
license.applyLicense key applied or updated
user.create / user.deleteUser created or deleted

Audit entries are append-only — individual records cannot be modified or deleted. The retention policy controls the maximum age of entries kept in Postgres.

Conversations

MethodEndpointAuthDescription
GET/api/conversationsRequiredList conversations
GET/api/conversations/{id}RequiredGet a specific conversation

Branding

MethodEndpointAuthDescription
GET/api/brandingPublicGet branding configuration
GET/api/branding/logoPublicGet branding logo
PUT/api/brandingAdminUpdate branding configuration
POST/api/branding/logoAdminUpload a branding logo

License

MethodEndpointAuthDescription
GET/api/licenseRequiredGet license information and current plan
POST/api/licenseAdminApply or update the license key

Hardware & Model

MethodEndpointAuthDescription
GET/api/hardwareRequiredGet hardware information (CPU, GPU, memory)
GET/api/model-infoRequiredGet loaded model information

Interactive API Docs

Swagger UI is available at http://<host>:8000/docs and provides a full interactive reference with request/response schemas and the ability to test endpoints directly in the browser.