The CosmoOps Knowledge Base API lets you create stores, ingest documents, and query them using RAG (Retrieval-Augmented Generation).
Base URL: https://kb.cosmoops.com
All API endpoints (except the health check) require a valid API key. Pass it via one of two headers:
# Option A — Authorization header (recommended)
curl https://kb.cosmoops.com/api/v1/store \
-H "Authorization: Bearer cmo_YOUR_API_KEY"# Option B — X-API-Key header
curl https://kb.cosmoops.com/api/v1/store \
-H "X-API-Key: cmo_YOUR_API_KEY"If the key is missing, expired, or revoked the API returns 401.
API keys are managed from the CosmoOps dashboard — there is no API endpoint to create them programmatically.
Keys use the format cmo_<32 random chars>. You can revoke keys at any time from the same settings page.
Returns the API status. No authentication required.
curl https://kb.cosmoops.com/api/v1/healthResponse:
{ "status": "ok" }Creates a new knowledge store to hold documents. Each store is scoped to your organization.
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | required | Display name for the store. |
| description | string | optional | Optional description. |
| source.id | string | required | External source identifier. |
| source.collection | string | required | Source collection name. |
curl -X POST https://kb.cosmoops.com/api/v1/store \
-H "Authorization: Bearer cmo_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Docs",
"description": "Public product documentation",
"source": {
"id": "product-docs",
"collection": "documentation"
}
}'Response 201:
{
"store": {
"id": "abc123",
"orgId": "org_xyz",
"name": "Product Docs",
"description": "Public product documentation",
"source": {
"id": "product-docs",
"collection": "documentation"
},
"documentCount": 0,
"customCount": 0,
"createdBy": "api:key_id",
"createdAt": "...",
"updatedAt": "..."
}
}Updates an existing store. Only the fields you include in the request body will be changed.
| Name | Type | Required | Description |
|---|---|---|---|
| storeId | string | required | The ID of the store to update. |
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | optional | New display name. |
| description | string | null | optional | New description (send null to clear). |
| source | object | optional | Updated source (id and collection). |
curl -X PUT https://kb.cosmoops.com/api/v1/store/abc123 \
-H "Authorization: Bearer cmo_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Docs v2",
"description": "Updated documentation store"
}'Response 200:
{
"store": {
"id": "abc123",
"name": "Product Docs v2",
"description": "Updated documentation store",
"...": "..."
}
}Permanently deletes a store and all its documents. This operation is idempotent — deleting an already-deleted store returns success.
curl -X DELETE https://kb.cosmoops.com/api/v1/store/abc123 \
-H "Authorization: Bearer cmo_YOUR_API_KEY"Response 200:
{ "deleted": true }CosmoOps uses a Retrieval-Augmented Generation (RAG) pipeline to answer queries against your knowledge stores. Here is what happens when you call the query endpoint:
topK results.enableRagEvaluation is turned on, an LLM judge evaluates whether the retrieved documents actually answer the query. It produces a relevance flag, confidence score, reasoning, and a synthesised answer.Performs a RAG query against a store and returns relevant documents with an AI-generated answer.
| Name | Type | Required | Description |
|---|---|---|---|
| storeId | string | required | The store to query. |
| query | string | required | Natural language query. |
| filters | Record<string, string> | optional | Key-value metadata filters for narrowing results. |
| topK | number | optional | Max documents to retrieve (1–50). Default: 10. |
| enableRagEvaluation | boolean | optional | Run LLM quality judgment. Default: false. |
curl -X POST https://kb.cosmoops.com/api/v1/query \
-H "Authorization: Bearer cmo_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"storeId": "abc123",
"query": "How do I configure SSO?",
"topK": 5,
"enableRagEvaluation": true
}'Response 200:
{
"answer": "To configure SSO, navigate to Settings → Identity ...",
"sources": [
{
"id": "doc_456",
"summary": "SSO configuration guide for enterprise accounts",
"score": 0.92,
"updatedAt": "2026-04-01T12:00:00Z"
}
],
"retrievedCount": 3,
"judgment": {
"relevant": true,
"confidence": 0.95,
"reasoning": "Documents contain a direct SSO setup guide.",
"answer": "To configure SSO, navigate to Settings → Identity ..."
}
}curl -X POST https://kb.cosmoops.com/api/v1/query \
-H "Authorization: Bearer cmo_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"storeId": "abc123",
"query": "deployment checklist"
}'Response 200:
{
"answer": "Retrieved 2 relevant documents.",
"sources": [
{
"id": "doc_789",
"summary": "Pre-deployment checklist for production releases",
"score": 0.87
},
{
"id": "doc_012",
"summary": "Infrastructure readiness template",
"score": 0.71
}
],
"retrievedCount": 2
}All errors return a JSON body with an error field and optional details.
| Status | Error Code | Meaning |
|---|---|---|
| 400 | Invalid request parameters | Validation failed — check the details array. |
| 401 | MISSING_API_KEY | No API key was provided in the request headers. |
| 401 | INVALID_API_KEY | The API key is invalid or has been revoked. |
| 403 | Forbidden | The API key does not have access to this resource. |
| 404 | Store not found | The specified store does not exist. |
| 500 | QUERY_ERROR | An internal error occurred during the RAG query flow. |
{
"error": "Invalid request parameters",
"details": [
{
"code": "too_small",
"minimum": 1,
"type": "string",
"inclusive": true,
"exact": false,
"message": "storeId is required",
"path": [
"storeId"
]
}
]
}