Overview
Upload a document to your AI assistantβs knowledge base. This endpoint uploads the document to Ragie (AI knowledge platform), saves it to your database, and optionally links it to a specific AI assistant through folder association. Perfect for programmatically building and maintaining your AI assistantβs knowledge base with custom content.Use Cases
- Knowledge Base Building: Programmatically add content to AI assistants
- Content Sync: Import content from external systems (CMS, wikis, etc.)
- Bulk Upload: Upload multiple documents via API
- Dynamic Content: Add generated or user-submitted content
- Documentation Updates: Keep AI knowledge up-to-date with latest docs
- Multi-language Content: Upload translations and localized content
Authentication
This endpoint requires authentication using an API key. Include your API key in the request header:Request Body
Field | Type | Required | Description |
---|---|---|---|
content | string | Yes | The actual content/text of the document |
fileName | string | Yes | Name of the document file |
externalId | string | Yes | Your unique identifier for tracking this document |
folderId | string (UUID) | Yes | Folder ID where document will be stored |
assistantId | string (UUID) | No | Optional assistant ID to link folder with |
icon | string | No | Optional emoji/icon for the document (default: π) |
External ID: Use a unique identifier from your system to track documents.
This is used for updates and deletions.
What Happens When You Upload
- Upload to Ragie: Document content is uploaded to Ragie AI platform
- Save to Database: Document metadata saved with folder association
- Link to Assistant: If
assistantId
provided, folder is linked to that assistant - AI Processing: Ragie processes the document for AI retrieval
Response Structure
Field | Type | Description |
---|---|---|
ragieDocument | object | Document info from Ragie API |
savedDocument | object | Document info saved in database |
Ragie Document Object
Field | Type | Description |
---|---|---|
id | string (UUID) | Ragie document ID |
name | string | Document name |
status | string | Processing status |
chunk_count | number | Number of chunks for AI retrieval |
external_id | string | Your external ID |
created_at | string (ISO) | Creation timestamp |
Saved Document Object
Field | Type | Description |
---|---|---|
id | string (UUID) | Database document ID |
name | string | Document name |
icon | string | Document icon |
parent_folder_id | string (UUID) | Associated folder ID |
content | string | Document content |
client_id | string (UUID) | Your organization ID |
Example Request
Example Response
Common Use Cases
1. Upload FAQ Document
2. Bulk Upload Documents
3. Upload and Link to Assistant
4. Sync from External CMS
Content Format
Thecontent
field accepts plain text or markdown:
Plain Text:
External ID
TheexternalId
is YOUR identifier for the document:
- Must be unique within your organization
- Used for updates and deletions
- Can be any string (e.g.,
"doc-123"
,"cms-article-456"
) - Helps you track which documents youβve uploaded
Error Responses
Status Code | Description |
---|---|
400 | Bad Request - Invalid data or missing fields |
401 | Unauthorized - Invalid or missing API key |
404 | Not Found - Folder not found |
500 | Internal Server Error - Something went wrong |
Important Notes
- Required Subscription: This endpoint requires an active subscription
- Ragie Processing: Documents are processed asynchronously by Ragie
- External ID Tracking: Use consistent external IDs for updates/deletes
- Folder Required: Must specify a valid folder ID
- Content Limit: Very large documents may be rejected (keep under 1MB)
- Assistant Linking: Folder linked to assistant, not individual document
Related Endpoints
- GET /api/documents/assistant/folders - List available folders
- POST /api/documents/assistant/folders - Create a folder first
- DELETE /api/documents/assistant/ - Delete uploaded document
Best Practices
1. Use Descriptive External IDs
2. Organize with Icons
3. Handle Errors
Headers
API key needed to authorize the request
Body
application/json
The content of the document, the name of the file, the external id, folder id, optional assistant id and icon.
Response
Document created successfully.