Collections API
Manage document collections programmatically.
List Collections
Endpoint
GET /v1/collections
Response
{
"data": [
{
"id": "col_abc123",
"name": "Engineering Docs",
"description": "Technical documentation",
"documentCount": 1234,
"embeddingModel": "text-embedding-3-small",
"createdAt": "2024-01-15T10:00:00Z"
}
]
}
Create Collection
Endpoint
POST /v1/collections
Request Body
{
"name": "Sales Materials",
"description": "Sales presentations and proposals",
"embeddingModel": "text-embedding-3-small"
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Collection name |
description | string | No | Description |
embeddingModel | string | No | Model for embeddings |
Response
{
"data": {
"id": "col_xyz789",
"name": "Sales Materials",
"documentCount": 0,
"createdAt": "2024-01-15T10:00:00Z"
}
}
Get Collection
Endpoint
GET /v1/collections/{id}
Response
{
"data": {
"id": "col_abc123",
"name": "Engineering Docs",
"description": "Technical documentation",
"documentCount": 1234,
"embeddingCount": 5678,
"connectors": ["conn_a", "conn_b"],
"embeddingModel": "text-embedding-3-small",
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-20T14:00:00Z"
}
}
Update Collection
Endpoint
PUT /v1/collections/{id}
Request Body
{
"name": "Updated Name",
"description": "Updated description"
}
Delete Collection
Endpoint
DELETE /v1/collections/{id}
warning
Deleting a collection removes all documents and embeddings in it.
Collection Stats
Endpoint
GET /v1/collections/{id}/stats
Response
{
"data": {
"documentCount": 1234,
"embeddingCount": 5678,
"storageBytes": 104857600,
"lastSync": "2024-01-20T14:00:00Z"
}
}
Example Usage
Create Collection
const collection = await client.collections.create({
name: 'Product Docs',
description: 'Product documentation'
});
List Collections
const collections = await client.collections.list();
Next Steps
- Connectors API - Manage data sources
- Documents API - Document operations