Skip to main content

Documents

Upload documents to knowledge bases for indexing, manage document lifecycle, and configure URL/feed sources for automatic content ingestion.
All API requests require a valid JWT token in the Authorization: Bearer <token> header. The API Gateway decodes the JWT and forwards auth context (user-id, organization-id, user-email, x-platform-role, x-org-role) as headers to downstream services.
This endpoint incurs provider cost and records a billing event via record_external_cost_event(). Credits are deducted from the organization’s wallet based on the configured margin multiplier.

Upload Document

Upload a file to a knowledge base. The document is stored and queued for asynchronous processing (text extraction, chunking, embedding, and optional graph extraction).

Path Parameters

string
required
KB UUID.

Request Body

Multipart file upload. Send the file as a multipart/form-data request.

Supported File Types

Response (201)

object
The created document record.
string
BullMQ job ID for tracking processing progress.
string
Confirmation message.

Processing Pipeline

After upload, documents go through this async pipeline:
  1. Load: LlamaParse (for PDF/DOCX) or LangChain fallback loaders
  2. Chunk: Split into chunks (1000 characters, 200 overlap)
  3. Embed: Generate multimodal embeddings via Gemini Embedding 2 (3072 dimensions)
  4. Store: Upsert vectors to Pinecone (production) or ChromaDB (local)
  5. Graph (optional): Extract entities and relationships
  6. Summarize (optional): Generate document summary for KB map

Processing Statuses


List Documents

List all documents in a knowledge base.

Path Parameters

string
required
KB UUID.

Query Parameters

number
default:"50"
Maximum results.
number
default:"0"
Pagination offset.

Response (200)

object[]
Array of document objects.
number
Total document count.
number
Applied limit.
number
Applied offset.
curl

Delete Document

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

Path Parameters

string
required
KB UUID.
string
required
Document UUID.

Response (200)

string
Confirmation.
string
Deleted document UUID.
number
Number of chunk/vector rows removed.

Retry Failed Document

Re-queue a failed document for processing. Resets the status to pending and creates a new processing job.

Path Parameters

string
required
KB UUID.
string
required
Document UUID.

Response (200)

string
Confirmation.
string
Document UUID.
string
New processing job ID.

URL Sources

Add URL Source

Add a URL or feed source to a knowledge base. Content is fetched, processed, and indexed. Supports single URLs, RSS feeds, and web crawling.

Path Parameters

string
required
KB UUID.

Request Body

string
required
Source URL (webpage, RSS feed, or social media profile).
string
default:"url"
Source type: url, rss, linkedin, twitter, medium.
boolean
default:"false"
Enable automatic periodic re-sync.
number
default:"60"
Sync interval in minutes (when syncEnabled is true).
number
Maximum items to fetch from feeds.
number
Maximum pages to crawl.
number
Link crawl depth (0 = single page only).
string
Strategy for media content: native (embed directly) or transcription (convert to text first).
boolean
Enable visual entity extraction from images.

Light Scrape

Quick URL scrape for content preview. Fetches and extracts text from up to 10 URLs without full KB indexing. Used by the Creator Wizard for AI profile generation.

Request Body

object[]
required
Array of URLs to scrape (max 10).

Response (200)

object[]
Scrape results for each URL.
curl
Light scrape has a 10-second timeout per URL and returns a maximum of 2000 characters of text per URL. For full content indexing, use the document upload or URL source endpoints.

Text Extraction

Extract text and images from an uploaded file without indexing it into a knowledge base. Useful for previewing content or processing attachments.

Request Body

Multipart file upload.

Response (200)

Returns extracted text content and any images found in the document.