Create a Knowledge base
POST /v1/knowledge-bases
| Property | Value |
|---|---|
| Operation | create_knowledge_base |
| Group | Knowledge bases |
| Scope | knowledge:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited knowledge.knowledge_base.create (mutation) |
| Released in | 1.53.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates a Knowledge base draft at revision 1 with no Source and no version (1.53.0). The embedding Provider must serve the model at its embeddings stage and be allowed by the Compliance profile; every issue is a detail of 422 validation_failed (KnowledgeBaseIssueCode). phi_content: per_person is reserved and refused with capability_not_available.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the knowledge:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/knowledge-bases" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"name": "clinic-patient-faq",
"embedding": {
"provider": "mock",
"model": "<model>"
}
}'const response = await fetch(`${process.env.VOCAL_API}/v1/knowledge-bases`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "clinic-patient-faq",
"embedding": {
"provider": "mock",
"model": "<model>"
}
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/knowledge-bases",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"name": "clinic-patient-faq",
"embedding": {
"provider": "mock",
"model": "<model>",
},
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: KnowledgeBaseCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
auto_publish | KnowledgeAutoPublish | no | |
chunking | KnowledgeChunkingInput | no | |
description | string | no | |
embedding | KnowledgeEmbeddingInput | yes | |
language | LanguageTag | no | |
name | KnowledgeBaseName | yes | |
phi_content | KnowledgePhiContent | no | |
retrieval_defaults | KnowledgeRetrievalDefaultsInput | no | |
sensitive_content | KnowledgeSensitiveContentInput | no |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | KnowledgeBase | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
404 | application/json | ErrorEnvelope | not_found |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed, capability_not_available |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is KnowledgeBase.
| Field | Type | Required | Description |
|---|---|---|---|
active_version | integer or null | yes | The version bindings that track active resolve at dispatch, or null when none is active. |
archived_at | Timestamp or null | yes | When DELETE archived the Knowledge base, or null. An archived Knowledge base takes no write, upload, sync or publish (409 knowledge_base_archived). |
auto_publish | KnowledgeAutoPublish | yes | |
chunking | KnowledgeChunking | yes | |
created_at | Timestamp | yes | |
description | string or null | yes | |
document_count | integer | no | The Documents of the Knowledge base that are not removed, whatever their status (1.54.0); absent from an api before 1.54.0. |
embedding | KnowledgeEmbedding | yes | |
id | KnowledgeBaseId | yes | |
language | LanguageTag | yes | |
latest_version | integer or null | yes | The highest published version, or null before the first publish. |
name | KnowledgeBaseName | yes | |
object | "knowledge_base" | yes | |
organization_id | OrganizationId | yes | |
phi_content | KnowledgePhiContent | yes | |
retrieval_defaults | KnowledgeRetrievalDefaults | yes | |
revision | integer | yes | Counts writes to the draft; returned as the ETag and required in If-Match. |
sensitive_content | KnowledgeSensitiveContent | yes | |
source_count | integer | no | The Sources of the Knowledge base that are not deleted (1.54.0); absent from an api before 1.54.0. |
updated_at | Timestamp | yes |