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/knowledgeBase

Authentication

All endpoints require authentication via Bearer token:

Architecture Overview

The Knowledge Base Service is built on a Node.js backend, with graph-based data persistence in whichever graph database the instance is configured to use (Neo4j by default, ArangoDB as an alternative). 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/knowledgeBase/Request Body Parameters:
Retrieve all knowledge bases accessible to the user with filtering and pagination.
Endpoint: GET /api/v1/knowledgeBase/Query Parameters:
Retrieve a specific knowledge base by its ID.
Endpoint: GET /api/v1/knowledgeBase/:kbIdPath Parameters:
Update knowledge base properties.
Endpoint: PUT /api/v1/knowledgeBase/:kbIdPath Parameters:Request Body Parameters:
Delete a knowledge base, with all its folders and records. Only the knowledge base’s owner can delete it, and it can’t be undone.
  • First, PipesHub lists the knowledge base’s uploaded files and schedules their removal. If either step fails, nothing is deleted and the request returns 503; try again.
  • A 200 means the folders and records are gone from the graph. The indexing service then removes their search index (embeddings) and stored files.
  • Retries. If storage can’t remove a file, or the file’s record can’t be checked, the removal is retried until it succeeds, with no time limit. If a record still lists the file, the removal is retried for up to one day, then the file is kept, because that record was never deleted (see the Deletion note on the Storage page).
  • Shared content. If a record in another knowledge base or connector has identical content, that record’s uploaded file and the shared search index stay. If the processed copy of that content was filed under the deleted knowledge base, it is moved to the surviving record’s storage location and keeps its document ID, so the surviving record isn’t re-indexed. If that handover fails, nothing is deleted from the knowledge base’s storage, and the release is retried until it succeeds.
Endpoint: DELETE /api/v1/knowledgeBase/:kbIdPath Parameters:
Manage individual records within knowledge bases including creation, retrieval, updates, and deletion.
Retrieve a specific record by its ID with full metadata.
Endpoint: GET /api/v1/knowledgeBase/record/:recordIdPath Parameters:
Update a record with new metadata or file content.
Endpoint: PUT /api/v1/knowledgeBase/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
Duplicate names: a rename is refused with 409 Conflict, and the file keeps its old name, when another file of the same type in the same folder (or the knowledge base root) already has the new name. Names are compared ignoring case, so Report.pdf and report.pdf count as the same. A file of a different type may use the same name.
When you attach a file, the record is renamed after that file, without its extension: uploading updated_policy.pdf names the record updated_policy, and any recordName you send with the file is ignored. To rename a record, send recordName on its own, without a file.
Move a file or folder to another folder in the same knowledge base, or to the knowledge base root.
Endpoint: PUT /api/v1/knowledgeBase/:kbId/record/:recordId/movePath Parameters:Request Body Parameters:
Duplicate names: a move is refused with 409 Conflict, and the record stays where it was, when the destination folder (or the knowledge base root) already holds:
  • for a file, a file with the same name (ignoring case) and the same type. A file of a different type may share the name.
  • for a folder, a folder with the same name (ignoring case).
Delete a file from a knowledge base. Only files uploaded to a knowledge base can be deleted here: a record synced from a connector is refused with 403 Forbidden, and is removed by deleting the item in the source app.The result depends on the Labs setting Move Deleted Records to the Trash:
  • Off (the default): the record is removed from the graph database and can’t be restored.
    • First, PipesHub schedules the removal of the record’s uploaded file. If that fails, nothing is deleted and the request returns 503; try again.
    • A 200 means the record is gone from the graph. The indexing service then removes its search index (embeddings) and uploaded file.
    • Retries. If storage can’t remove a file, or the file’s record can’t be checked, the removal is retried until it succeeds, with no time limit. If a record still lists the file, the removal is retried for up to one day, then the file is kept, because that record was never deleted (see the Deletion note on the Storage page).
    • Shared content. If another record has identical content, the shared search index and processed content stay until the last copy is deleted.
  • On: the record goes to the trash. It disappears from search, chat and listings at once, and its uploaded file is kept until the scheduled cleanup. Until then, it can be restored with POST /record/:recordId/restore or from the collection’s Recently deleted page; see How long items stay. The response has softDeleted: true and the delete’s batchId.
Endpoint: DELETE /api/v1/knowledgeBase/record/:recordIdPath Parameters:
List one page of a collection’s deleted items that can still be restored, newest first. Each item is one delete, which a restore brings back whole: a folder deleted with its contents is one item, and so is a multi-select delete. itemCount is the number of records an item holds. For a multi-select delete, rootCount is how many items were selected, and otherRootNames names up to three of them besides name. To restore an item, pass its id to POST /record/:recordId/restore.Needs Move Deleted Records to the Trash on in Labs. The list holds only what the caller may restore: owners and writers see every item, file organizers see single files only, and other roles get 403 Forbidden. OAuth apps need the kb:delete scope.
Endpoint: GET /api/v1/knowledgeBase/:kbId/trashPath Parameters:Query Parameters:
Restore a record from the trash, with everything deleted in the same action: a folder with its contents, a file with its attachments, a multi-select delete with every item it removed. Pass the id of any item from that delete.Needs Move Deleted Records to the Trash on in Labs, and the role the delete needed: OWNER, WRITER or FILEORGANIZER for a single file, OWNER or WRITER for a folder or several items. OAuth apps need the kb:delete scope.
Endpoint: POST /api/v1/knowledgeBase/record/:recordId/restorePath Parameters:
Restore up to 100 records, each the way POST /record/:recordId/restore does. If several ids belong to one delete, that delete is restored once. Each id gets its own outcome in results, so one refusal doesn’t block the others, and the response is 200 whatever the outcomes.
Endpoint: POST /api/v1/knowledgeBase/records/restoreRequest Body:
Stream the actual file content of a record for download.
Endpoint: GET /api/v1/knowledgeBase/stream/record/:recordIdPath Parameters:
Force reindexing of a record by the AI backend.
Endpoint: POST /api/v1/knowledgeBase/reindex/record/:recordIdPath Parameters:
Upload files and folders to knowledge bases with support for bulk operations and folder structures.
Upload files to the root of a knowledge base, or into one of its folders, creating records and folder structures as needed.
Endpoint: POST /api/v1/knowledgeBase/:kbId/uploadPath Parameters:Query 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
  • A file is skipped when its name (ignoring case) and type match a file already in its destination folder, or another file in the same upload going to that folder. Files with the same name going to different folders, such as docs/Report.pdf and archive/Report.pdf, are both created. In the upload’s event stream (text/event-stream), a skipped file gets a file:failed event with reason: "DUPLICATE_NAME", stage: "index" and errors: ["A file named \"<name>\" already exists in this location; it was skipped."]. The rest of the upload goes ahead, each file with its own event (file:succeeded when added), and the stream ends with done.
To upload into a folder instead, add its ID as a query parameter: /api/v1/knowledgeBase/kb123456/upload?folderId=folder456.
Manage folder structures within knowledge bases including updates and deletion.
Update folder properties such as name.
Endpoint: PUT /api/v1/knowledgeBase/:kbId/folder/:folderIdPath Parameters:Request Body Parameters:
Delete a folder and all its contents, including sub-folders. Nothing outside the folder is touched.
  • With Move Deleted Records to the Trash off (the default): PipesHub first schedules the removal of every uploaded file in the folder; if that fails, nothing is deleted and the request returns 503. A 200 means the folder and its contents are gone from the graph for good. Their embeddings and stored files are removed afterwards, with the same retries as DELETE /record/:recordId.
  • With Move Deleted Records to the Trash on in Labs: the folder and its contents go to the trash as one item, which can be restored from the collection’s Recently deleted page. Their uploaded files are kept until the scheduled cleanup.
Endpoint: DELETE /api/v1/knowledgeBase/:kbId/folder/:folderIdPath Parameters:
Connector statistics, reindexing and resync are not part of the Knowledge Base API. They are in the Connectors API, under /api/v1/connectors, and take a connector instance ID:
  • GET /api/v1/connectors/:connectorId/stats - Indexing statistics for a connector. Needs only the ID.
  • POST /api/v1/connectors/:connectorId/reindex - Reindex a connector’s records. The body is optional: send { "statusFilters": [...] } to reindex only the records with those indexing statuses.
  • POST /api/v1/connectors/:connectorId/resync - Resync a connector’s records. The body must include connectorName (the connector’s name), and may include fullSync: true for a full resync. A request without connectorName is refused.
The Knowledge Base API’s old stats/:connector, reindex-all/connector and resync/connector endpoints no longer exist.

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

This event removes the record’s search index and processed content. If the event is lost, the indexing service’s periodic orphan sweep removes them. The uploaded file is removed by a separate event, scheduled before the record is deleted.

Schema Definitions

Error Handling

All endpoints return structured error responses with specific HTTP status codes:
requestId identifies the request in the server’s logs, so include it when you report a problem. 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
  • 409 Conflict - Name already in use: a file of the same type, or a folder, already has that name in that location
  • 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 name: a file whose name and type match a file in its destination folder, or another file in the same upload going there, is skipped with a file:failed stream event, reason DUPLICATE_NAME. The rest of the upload goes ahead.

Integration with AI Indexing

When a record is created or updated, the Knowledge Base Service:
  1. Stores the file metadata in the graph database
  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 by default (set in platform settings), 1000 files per upload
  • Pagination: Maximum 100 items per page
  • Search Terms: Maximum 1000 characters
  • Knowledge Base Names: 1-255 characters
  • File Paths: Must not contain invalid characters or be duplicated