Publish the working set as a new version
POST /v1/knowledge-bases/{knowledge_base_id}/versions
| Property | Value |
|---|---|
| Operation | publish_knowledge_base_version |
| 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.version.publish (mutation) |
| Released in | 1.53.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Freezes the configuration of the draft that If-Match names and a manifest of the latest indexed revision of every Document as the next version (1.53.0; knowledge-bases.md section 9). It refuses with one 422 validation_failed listing every issue (KnowledgePublishIssueCode): a pending Document unless exclude_pending is set, no indexed Document, an embedding space the Organization may not use, or a failed retrieval-quality gate. With activate the version becomes the active one. It emits the Webhook event knowledge_base.version.published. From the second part of the slice the version takes the gate of the Evaluation evaluation_id names, or of the newest current Evaluation of the working set: needed whenever the corpus holds a query (knowledge_evaluation_required), a failed gate refused with one retrieval_gate_failed per failing check, and not_run only with an empty corpus.
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/kb_.../versions" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H 'If-Match: "1"' \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'const response = await fetch(`${process.env.VOCAL_API}/v1/knowledge-bases/kb_.../versions`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'If-Match': '"1"',
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/knowledge-bases/kb_.../versions",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"If-Match": '"1"',
"Idempotency-Key": str(uuid.uuid4()),
},
json={},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
knowledge_base_id | path | KnowledgeBaseId | yes | The id of a Knowledge base: kb_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log. |
if-match | header | string | yes | The revision the change was made against, quoted as the ETag returns it, or * to overwrite. |
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: KnowledgeBaseVersionPublishRequest.
| Field | Type | Required | Description |
|---|---|---|---|
activate | boolean | no | Make the new version the active one; false when omitted. |
evaluation_id | KnowledgeEvaluationId | no | The completed Evaluation of the working set whose gate the version takes (1.53.0, second part); the newest current one when omitted. Needed whenever the corpus holds a query. |
exclude_pending | boolean | no | Publish without the Documents still pending, which the version lists, instead of refusing; false when omitted. |
notes | string | no | Why this version exists. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | KnowledgeBaseVersion | |
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 | knowledge_base_archived, idempotency_in_progress, idempotency_key_reused |
412 | application/json | ErrorEnvelope | revision_mismatch |
422 | application/json | ErrorEnvelope | validation_failed |
428 | application/json | ErrorEnvelope | precondition_required |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is KnowledgeBaseVersion.
| Field | Type | Required | Description |
|---|---|---|---|
active | boolean | yes | True for the active version, the one bindings that track active resolve at dispatch. |
chunk_count | integer | yes | |
config | KnowledgeBaseConfig | yes | |
config_sha256 | string | yes | The SHA-256 of the canonical configuration, in lowercase hex. |
document_count | integer | yes | |
evaluation_id | KnowledgeEvaluationId or null | yes | The Evaluation the gate read, or null when none ran. |
excluded_document_count | integer | yes | The pending Documents exclude_pending left out; 0 when it was not set. |
excluded_document_ids | array of KnowledgeDocumentId | yes | The first 100 of them (a target), in id order. |
gate | KnowledgeGateOutcome | yes | |
knowledge_base_id | KnowledgeBaseId | yes | |
notes | string or null | yes | |
object | "knowledge_base_version" | yes | |
published_at | Timestamp | yes | |
published_by | ActorRef or null | yes | Who published it; null when auto_publish published it after an Ingestion run. |
retired_at | Timestamp or null | yes | |
source_revision | integer | yes | The draft revision whose configuration the version froze. |
status | KnowledgeBaseVersionStatus | yes | |
version | integer | yes | The snapshot number, from 1. |