• English
  • Knowledge bases API

    Use the Knowledge Bases API to create document collections that agents search in chat. Most people should start from the web UI; this page is for automating the same flow.

    /api/knowledge-bases

    Anyone signed in can list bases they own or that are Shared. Creating, uploading, and deleting require that you own the base (administrators can manage any base). An administrator must enable knowledge bases in the web UI before indexing works.

    Create a knowledge base

    curl -X POST http://127.0.0.1:8088/api/knowledge-bases \
      -H 'Authorization: Bearer $TOKEN' \
      -H 'Content-Type: application/json' \
      -d '{
        "name": "Team handbook",
        "description": "Onboarding docs",
        "max_documents": 500,
        "shared": true,
        "default_open": false
      }'

    shared lets other signed-in users read the base. default_open attaches it to your new chats only. max_documents sets this base's document limit. Omit it for the default 100, set 0 for no per-base limit, or choose any value up to 10000.

    Upload a document

    curl -X POST http://127.0.0.1:8088/api/knowledge-bases/<kb_id>/documents \
      -H 'Authorization: Bearer $TOKEN' \
      -F 'upload=@handbook.pdf'

    Supported files: text (.md, .txt, .rst, .html, .json, .jsonl, .yaml, .csv, .tsv), spreadsheets (.xls, .xlsx, .xlsm), plus .pdf, .docx, .pptx. With OCR enabled, also .png, .jpg, .jpeg, .webp and scanned PDFs. Indexing starts after the upload. The response includes upload progress while the file is accepted.

    To create markdown or text without uploading a file:

    curl -X POST http://127.0.0.1:8088/api/knowledge-bases/<kb_id>/documents/text \
      -H 'Authorization: Bearer $TOKEN' \
      -H 'Content-Type: application/json' \
      -d '{
        "name": "notes",
        "format": "md",
        "content": "# Welcome\n\nTeam handbook goes here."
      }'

    Knowledge bases

    MethodPathWho can call itWhat it does
    GET/knowledge-basessigned inList bases you can see
    POST/knowledge-basesownerCreate a base
    GET/knowledge-bases/default-opensigned inIDs of bases that open in your new chats
    GET/knowledge-bases/{kb_id}signed inGet one base
    PATCH/knowledge-bases/{kb_id}ownerRename, share, change default-open, or change max_documents
    DELETE/knowledge-bases/{kb_id}ownerDelete a base

    Documents and folders

    MethodPathWho can call itWhat it does
    GET/knowledge-bases/{kb_id}/documentssigned inList files and folders
    POST/knowledge-bases/{kb_id}/documentsownerUpload a file
    POST/knowledge-bases/{kb_id}/documents/textownerCreate a markdown or text file
    POST/knowledge-bases/{kb_id}/foldersownerCreate a folder
    PATCH/knowledge-bases/{kb_id}/documents/{doc_id}ownerRename a file or folder
    GET/knowledge-bases/{kb_id}/documents/{doc_id}/previewsigned inPreview in the original layout
    GET/knowledge-bases/{kb_id}/documents/{doc_id}/filesigned inDownload the original (Content-Disposition: attachment) or inline preview
    GET/knowledge-bases/{kb_id}/documents/{doc_id}/contentsigned inRead text content
    PUT/knowledge-bases/{kb_id}/documents/{doc_id}/contentownerSave an in-page text edit (re-indexes)
    DELETE/knowledge-bases/{kb_id}/documents/{doc_id}ownerDelete a file or folder

    Each owner can create up to 20 bases. Each base has its own document limit: the default is 100, 0 means unlimited, and the maximum accepted value is 10000. Upload size follows the server file-size cap (default 100 MB).

    Enable indexing (administrators)

    Turn the feature on in Knowledge Bases → Knowledge base settings, or call these routes after you pick a local or online embedding model:

    MethodPathWhat it does
    GET/knowledge-bases/capabilityWhether the feature is on and ready
    GET/knowledge-bases/embedding-optionsAvailable local and online models
    PUT/knowledge-bases/featureEnable or disable knowledge bases (can set OCR at the same time)
    GET/knowledge-bases/ocr-optionsList OCR backends (local RapidOCR / online vision models)
    POST/knowledge-bases/onnx-downloadDownload a local model
    GET/knowledge-bases/onnx-download-statusDownload progress
    POST/knowledge-bases/onnx-activateSwitch to a downloaded local model