Documents API
Manage indexed documents programmatically.
List Documents
Endpoint
GET /v1/documents
Query Parameters
| Parameter | Type | Description |
|---|---|---|
collection | string | Filter by collection |
source | string | Filter by connector |
status | string | Filter by status |
page | number | Page number |
limit | number | Items per page |
Response
{
"data": [
{
"id": "doc_abc123",
"title": "Getting Started Guide",
"status": "indexed",
"collection": "Documentation",
"source": "Confluence",
"createdAt": "2024-01-15T10:00:00Z",
"metadata": {
"author": "John Doe",
"lastModified": "2024-01-14T15:30:00Z"
}
}
],
"meta": {
"page": 1,
"limit": 20,
"total": 1234
}
}
Get Document
Endpoint
GET /v1/documents/{id}
Response
{
"data": {
"id": "doc_abc123",
"title": "Getting Started Guide",
"content": "Full document content...",
"status": "indexed",
"collection": "Documentation",
"source": "Confluence",
"metadata": {
"author": "John Doe",
"url": "https://...",
"pages": 5
},
"semanticUnits": [
{
"id": "su_xyz",
"content": "Section content...",
"position": 1
}
]
}
}
Delete Document
Endpoint
DELETE /v1/documents/{id}
Response
{
"data": {
"id": "doc_abc123",
"deleted": true
}
}
Document Status
| Status | Description |
|---|---|
pending | Waiting for processing |
processing | Currently being indexed |
indexed | Successfully indexed |
failed | Indexing failed |
deleted | Removed from index |
Example Usage
List Documents
const docs = await client.documents.list({
collection: 'col_abc123',
status: 'indexed',
limit: 50
});
Get Document
const doc = await client.documents.get('doc_xyz789');
console.log(doc.title, doc.content);
Delete Document
await client.documents.delete('doc_xyz789');
Next Steps
- Collections API - Manage collections
- Search API - Search documents