Skip to main content

Knowledge Base API

The Knowledge Base Service provides a centralized repository for managing and accessing personal data through files and documents. This service enables document storage, retrieval, and management while integrating with the AI backend for intelligent search capabilities.

Base URL

All endpoints are prefixed with /api/v1/kb

Authentication

All endpoints require authentication via Bearer token:

Architecture Overview

The Knowledge Base Service is built on a Node.js backend with ArangoDB for graph-based data persistence. The service consists of several key components:
  • Record Management - Core document storage and metadata handling
  • File Storage Integration - Connects with external storage services
  • Event Broadcasting - Kafka-based events for system integration
  • AI Indexing - Automatic content indexing for search capabilities
The service integrates with these components:
  • Storage Service - Handles actual file storage and versioning
  • AI Backend - Processes and indexes content for search
  • Enterprise Search - Provides search capabilities across the knowledge base
  • IAM Service - Handles user authentication and authorization
  • Configuration Manager - Manages application settings

Data Models

Records

Records represent the core entities in the knowledge base:
  • Metadata about stored content (name, type, source)
  • References to physical files in storage
  • Versioning information
  • Indexing status and history

File Records

File Records contain file-specific metadata:
  • File format information (extension, MIME type)
  • Size and storage information
  • Access URLs and paths
  • Checksum and integrity information

Knowledge Base

Knowledge Base represents a collection of records:
  • Organizational grouping of records
  • Permission structure
  • Metadata about the collection

API Endpoints

Manage knowledge base instances including creation, listing, updates, and deletion.
Create a new knowledge base for organizing documents.
Endpoint: POST /api/v1/kb/Request Body Parameters:
Retrieve all knowledge bases accessible to the user with filtering and pagination.
Endpoint: GET /api/v1/kb/Query Parameters:
Retrieve a specific knowledge base by its ID.
Endpoint: GET /api/v1/kb/:kbIdPath Parameters:
Update knowledge base properties.
Endpoint: PUT /api/v1/kb/:kbIdPath Parameters:Request Body Parameters:
Soft-delete a knowledge base and all its contents.
Endpoint: DELETE /api/v1/kb/:kbIdPath Parameters:
Manage individual records within knowledge bases including creation, retrieval, updates, and deletion.
Retrieve all records accessible to the user across all knowledge bases.
Endpoint: GET /api/v1/kb/recordsQuery Parameters:
Retrieve all records within a specific knowledge base.
Endpoint: GET /api/v1/kb/:kbId/recordsPath Parameters:Query Parameters: Same as “Get All Records” endpoint
Retrieve a specific record by its ID with full metadata.
Endpoint: GET /api/v1/kb/record/:recordIdPath Parameters:
Update a record with new metadata or file content.
Endpoint: PUT /api/v1/kb/record/:recordIdPath Parameters:Request Body Parameters:Content-Type: multipart/form-data (when uploading file)File Constraints:
  • Maximum file size: 30MB
  • Supported MIME types: Based on extensionToMimeType mapping
  • File extension must match existing record’s extension for versioned updates
Soft-delete a record by setting its deleted flag.
Endpoint: DELETE /api/v1/kb/record/:recordIdPath Parameters:
Stream the actual file content of a record for download.
Endpoint: GET /api/v1/kb/stream/record/:recordIdPath Parameters:
Force reindexing of a record by the AI backend.
Endpoint: POST /api/v1/kb/reindex/record/:recordIdPath Parameters:
Upload files and folders to knowledge bases with support for bulk operations and folder structures.
Upload files directly to a knowledge base, creating records and folder structures as needed.
Endpoint: POST /api/v1/kb/:kbId/uploadPath Parameters:Request Body Parameters:Content-Type: multipart/form-dataFile Constraints:
  • Maximum files per upload: 1000
  • Maximum file size: 30MB per file
  • Supported MIME types: Based on extensionToMimeType mapping
  • File paths must be unique and not contain invalid characters
Upload files to a specific folder within a knowledge base.
Endpoint: POST /api/v1/kb/:kbId/folder/:folderId/uploadPath Parameters:Request Body Parameters: Same as “Upload to Knowledge Base”
Manage folder structures within knowledge bases including content retrieval, updates, and deletion.
Retrieve all records and subfolders within a specific folder.
Endpoint: GET /api/v1/kb/:kbId/folder/:folderId/recordsPath Parameters:Query Parameters: Same filtering and pagination parameters as record endpoints
Update folder properties such as name.
Endpoint: PUT /api/v1/kb/:kbId/folder/:folderIdPath Parameters:Request Body Parameters:
Delete a folder and all its contents.
Endpoint: DELETE /api/v1/kb/:kbId/folder/:folderIdPath Parameters:
Administrative endpoints for managing connectors, bulk operations, and system maintenance.
Retrieve statistics for a specific connector.Access Control: Admin users only
Endpoint: GET /api/v1/kb/stats/:connectorPath Parameters:
Force reindexing of all failed records for a specific connector.Access Control: Admin users only
Endpoint: POST /api/v1/kb/reindex-all/connectorRequest Body Parameters:
Force resynchronization of all records for a specific connector.Access Control: Admin users only
Endpoint: POST /api/v1/kb/resync/connectorRequest Body Parameters:

Event System

The Knowledge Base Service broadcasts events through Kafka to notify other services about record changes. These events trigger actions like content indexing, search updates, and audit logging.

Event Types

Event Payload Structure

Schema Definitions

Error Handling

All endpoints return structured error responses with specific HTTP status codes:
Common Error Codes:
  • 400 Bad Request - Invalid request parameters, file validation errors
  • 401 Unauthorized - Missing or invalid authentication
  • 403 Forbidden - Insufficient permissions
  • 404 Not Found - Resource not found
  • 413 Payload Too Large - File size exceeds limit
  • 422 Unprocessable Entity - Validation errors
  • 500 Internal Server Error - Server errors, backend service failures
File Upload Specific Errors:
  • File extension mismatch for versioned updates
  • Unsupported MIME types
  • File size exceeds 30MB limit
  • Invalid file path characters
  • Duplicate file paths in upload

Integration with AI Indexing

When a record is created or updated, the Knowledge Base Service:
  1. Stores the file metadata in ArangoDB
  2. Uploads the file content to the Storage Service
  3. Publishes a Kafka event with the file metadata and download URL
  4. The AI Backend consumes these events and:
    • Downloads the file content
    • Extracts text and structured data
    • Processes the content for search indexing
    • Updates the indexing status in the Knowledge Base
This integration enables Enterprise Search to provide intelligent search capabilities across the entire knowledge base.

Security and Permissions

  • All endpoints require valid JWT authentication
  • Admin endpoints require additional role verification
  • File uploads are validated for MIME type and size
  • Access control is enforced at the organization level
  • File content is streamed securely through signed URLs
  • Upload paths are sanitized to prevent directory traversal

Rate Limits and Constraints

  • File Upload: Maximum 30MB per file, 1000 files per upload
  • Pagination: Maximum 100 items per page
  • Search Terms: Maximum 100 characters
  • Knowledge Base Names: 1-255 characters
  • File Paths: Must not contain invalid characters or be duplicated