curl -X POST "https://your-domain.com/api/v1/knowledge/create" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
}
]
}'
import requests
url = "https://your-domain.com/api/v1/knowledge/create"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
}
]
}
response = requests.post(url, headers=headers, json=payload)
knowledge_base = response.json()
print(f"Created knowledge base: {knowledge_base['id']}")
{
"id": "kb_abc123",
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"user_id": "user_456def",
"data": {},
"created_at": 1678901234,
"updated_at": 1678901234
}
Knowledge
Manage Document Collections
Create and manage knowledge base collections for RAG
POST
/
api
/
v1
/
knowledge
/
create
curl -X POST "https://your-domain.com/api/v1/knowledge/create" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
}
]
}'
import requests
url = "https://your-domain.com/api/v1/knowledge/create"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
}
]
}
response = requests.post(url, headers=headers, json=payload)
knowledge_base = response.json()
print(f"Created knowledge base: {knowledge_base['id']}")
{
"id": "kb_abc123",
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"user_id": "user_456def",
"data": {},
"created_at": 1678901234,
"updated_at": 1678901234
}
Manage knowledge base collections including creation, updating, file management, and deletion. Each knowledge base serves as a container for related documents that can be queried together.
Create a new knowledge base collection.
Retrieve detailed information about a knowledge base including its files.
This will:
Admin only. Reindex all files across all knowledge bases. Useful after changing embedding models or chunking settings.
Remove all file associations and embeddings from a knowledge base without deleting the knowledge base itself.
Permanently delete a knowledge base and all its associations. Files are not deleted.
Admin only. Export all files in a knowledge base as a ZIP archive containing .txt files with extracted content.
Update who can access the knowledge base.
Create Knowledge Base
POST /api/v1/knowledge/create
Request Body
string
Custom identifier for the knowledge base (auto-generated if not provided)
string
required
Display name for the knowledge base
string
Description of the knowledge base content and purpose
object
Additional metadata to store with the knowledge base
array
curl -X POST "https://your-domain.com/api/v1/knowledge/create" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
}
]
}'
import requests
url = "https://your-domain.com/api/v1/knowledge/create"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
payload = {
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
}
]
}
response = requests.post(url, headers=headers, json=payload)
knowledge_base = response.json()
print(f"Created knowledge base: {knowledge_base['id']}")
{
"id": "kb_abc123",
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"user_id": "user_456def",
"data": {},
"created_at": 1678901234,
"updated_at": 1678901234
}
Update Knowledge Base
POST /api/v1/knowledge/{knowledge_id}/update
Request Body
Same fields as create endpoint. All fields are optional - only provided fields will be updated.curl -X POST "https://your-domain.com/api/v1/knowledge/kb_abc123/update" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Documentation (Updated)",
"description": "Updated description for the knowledge base"
}'
Get Knowledge Base Details
GET /api/v1/knowledge/{knowledge_id}
{
"id": "kb_abc123",
"name": "Product Documentation",
"description": "Knowledge base for product guides and manuals",
"user_id": "user_456def",
"data": {},
"files": [
{
"id": "file_xyz789",
"filename": "user_guide.pdf",
"meta": {
"name": "user_guide.pdf",
"size": 1234567
}
}
],
"write_access": true,
"created_at": 1678901234,
"updated_at": 1678901234
}
Manage Files in Knowledge Base
List Files
GET /api/v1/knowledge/{knowledge_id}/files?page=1&query=search_term
integer
default:"1"
Page number for pagination
string
Search term to filter files by name
string
Filter by view option
string
Field to sort by (e.g., “name”, “created_at”)
string
Sort direction: “asc” or “desc”
Remove File from Knowledge Base
POST /api/v1/knowledge/{knowledge_id}/file/remove
string
required
ID of the file to remove
boolean
default:"true"
Whether to delete the file entirely or just remove from this knowledge base
curl -X POST "https://your-domain.com/api/v1/knowledge/kb_abc123/file/remove?delete_file=false" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"file_id": "file_xyz789"}'
import requests
url = "https://your-domain.com/api/v1/knowledge/kb_abc123/file/remove"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
params = {"delete_file": False} # Keep file, just remove from KB
data = {"file_id": "file_xyz789"}
response = requests.post(url, headers=headers, params=params, json=data)
print("File removed from knowledge base")
Update File in Knowledge Base
Reprocess a file and update its embeddings:POST /api/v1/knowledge/{knowledge_id}/file/update
string
required
ID of the file to reprocess
- Remove existing embeddings for the file
- Re-extract content from the file
- Re-chunk and re-embed the content
- Update the vector database
Reindex Knowledge Base
POST /api/v1/knowledge/reindex
Reset Knowledge Base
POST /api/v1/knowledge/{knowledge_id}/reset
curl -X POST "https://your-domain.com/api/v1/knowledge/kb_abc123/reset" \
-H "Authorization: Bearer YOUR_TOKEN"
Delete Knowledge Base
DELETE /api/v1/knowledge/{knowledge_id}/delete
curl -X DELETE "https://your-domain.com/api/v1/knowledge/kb_abc123/delete" \
-H "Authorization: Bearer YOUR_TOKEN"
import requests
url = "https://your-domain.com/api/v1/knowledge/kb_abc123/delete"
headers = {"Authorization": "Bearer YOUR_TOKEN"}
response = requests.delete(url, headers=headers)
if response.json():
print("Knowledge base deleted successfully")
Export Knowledge Base
GET /api/v1/knowledge/{knowledge_id}/export
Content-Type: application/zip
Content-Disposition: attachment; filename="Product_Documentation.zip"
[Binary ZIP file containing text files]
Update Access Control
POST /api/v1/knowledge/{knowledge_id}/access/update
Request Body
array
required
Array of access control rules (replaces existing grants)
curl -X POST "https://your-domain.com/api/v1/knowledge/kb_abc123/access/update" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"access_grants": [
{
"grantee_type": "group",
"grantee_id": "support_team",
"permission": "read"
},
{
"grantee_type": "user",
"grantee_id": "user_xyz",
"permission": "write"
}
]
}'
Notes
- Knowledge base IDs must be unique
- The creator automatically gets write access
- Access grants can be filtered by user permissions (e.g.,
sharing.public_knowledge) - Deleting a knowledge base removes it from associated models
- Files can belong to multiple knowledge bases
- Each knowledge base has its own vector collection for embeddings
- Metadata is embedded for semantic discovery of knowledge bases