Documents

Upload, generate, list, and manage documents. Supports PDF, DOCX, TXT, and Markdown with automatic AI indexing.

POST

Upload Document

/documents/upload

Upload a document file to a knowledge base. The document is automatically processed and indexed by AI for search.

Request Parameters

filefile*The document file (PDF, DOCX, TXT, MD).
knowledgeDbIdstring*Target knowledge base ID.

Response Fields

messagestringUpload confirmation.
documentIdstringUnique document identifier.
filenamestringOriginal filename.
statusstringProcessing status (e.g., "processing").
ℹ️Documents are processed asynchronously. Poll the list endpoint to check status.
ℹ️Supported formats: PDF, DOCX, TXT, Markdown.
// POST /documents/upload
// Content-Type: multipart/form-data
// Authorization: Bearer <idToken>
// x-api-key: <apiKey>

FormData:
  file: <binary>
  knowledgeDbId: "kb_abc123"
POST

Generate Document

/documents/generate

Generate a new document using AI based on a prompt. The generated document is automatically added to the knowledge base.

Request Parameters

knowledgeDbIdstring*Target knowledge base ID.
promptstring*Prompt describing the document to generate.
titlestringOptional title for the generated document.
// POST /documents/generate
{
  "knowledgeDbId": "kb_abc123",
  "prompt": "Write a summary of machine learning basics",
  "title": "ML Basics"
}
GET

List Documents

/documents

Retrieve all documents in a knowledge base.

Response Fields

documentsarrayArray of document objects.
countnumberTotal document count.
// GET /documents?knowledgeDbId=kb_abc123
// 200 OK
{
  "documents": [
    {
      "documentId": "doc_xyz789",
      "filename": "report.pdf",
      "status": "completed",
      "fileSize": 245760,
      "chunkCount": 12,
      "createdAt": "2026-01-15T10:30:00Z"
    }
  ],
  "count": 1
}
GET

Get Document

/documents/{documentId}

Retrieve a specific document by its ID.

// GET /documents/{documentId}
// 200 OK
{
  "documentId": "doc_xyz789",
  "filename": "report.pdf",
  "status": "completed",
  "fileSize": 245760,
  "chunkCount": 12,
  "createdAt": "2026-01-15T10:30:00Z"
}
DELETE

Delete Document

/documents/{documentId}

Delete a document and its associated embeddings from the knowledge base.

// DELETE /documents/{documentId}
// Authorization: Bearer <idToken>
// x-api-key: <apiKey>
POST

Reindex Document

/documents/reindex

Re-process and re-index a document. Useful if indexing failed or you want to refresh the embeddings.

Request Parameters

documentIdstring*ID of the document to reindex.
// POST /documents/reindex
// Authorization: Bearer <idToken>
// x-api-key: <apiKey>
{
  "documentId": "doc_xyz789"
}