Overview
The Documents API allows you to create, retrieve, update, and delete documents in your Sorcia knowledge base.
Create Document
POST /api/documents
curl -X POST https://api.sorcia.ai/api/documents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": "custom-app",
"external_id": "doc-123",
"title": "Product Roadmap Q1 2024",
"content": "Our Q1 priorities include...",
"url": "https://app.example.com/docs/123",
"metadata": {
"author": "product@company.com",
"updated_at": "2024-01-15T10:00:00Z",
"category": "roadmap"
}
}'
Request Parameters
Integration identifier (e.g., “slack”, “custom-crm”)
Unique ID in source system
Link to original document
Additional metadata (author, date, tags, etc.)
Response
{
"id": "doc_abc123",
"source": "custom-app",
"external_id": "doc-123",
"title": "Product Roadmap Q1 2024",
"indexed_at": "2024-01-15T10:30:00Z",
"status": "indexed"
}
Get Document
GET /api/documents/:id
curl https://api.sorcia.ai/api/documents/doc_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
Update Document
PUT /api/documents/:id
curl -X PUT https://api.sorcia.ai/api/documents/doc_abc123 \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"content": "Updated content..."}'
Delete Document
DELETE /api/documents/:id
curl -X DELETE https://api.sorcia.ai/api/documents/doc_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
List Documents
GET /api/documents
curl "https://api.sorcia.ai/api/documents?source=custom-app&limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"
Query Parameters
Filter by integration source
Number of results (max 100)
Batch Operations
POST /api/documents/batch
Create multiple documents at once:
await fetch('https://api.sorcia.ai/api/documents/batch', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
documents: [
{ source: 'crm', external_id: '1', title: 'Doc 1', content: '...' },
{ source: 'crm', external_id: '2', title: 'Doc 2', content: '...' },
// ... up to 100 documents
]
})
});
Error Codes
| Code | Meaning |
|---|
| 400 | Invalid request body |
| 401 | Unauthorized |
| 404 | Document not found |
| 409 | Document already exists |
| 429 | Rate limit exceeded |
Next Steps