0 (v0, v1, v2, …). Each version has an independent ingestion pipeline state and its own sections and chunks. Only the document’s active version is used by default for search and retrieval.
Pipeline state
After ingestion is triggered, thepipeline_state field in system_metadata tracks progress:
PipelineStatus | Meaning |
|---|---|
pending | Ingestion workflow has been queued but not started |
processing | Ingestion is actively running |
completed | Ingestion finished successfully |
failed | Ingestion failed; see pipeline_state.error for details |
cancelled | Ingestion was cancelled |
Version actions
TheDocumentVersionAction enum currently supports one action:
| Value | Description |
|---|---|
reembed | Re-run vector embedding for all chunks in this version |
Create version
POST https://api-staging.knowledgestack.ai/v1/documents/{document_id}/versions
Create a new empty version for a document. The version number is automatically incremented. Use this when you want to populate content manually rather than through file ingestion.
Path parameters
The document to create a new version for.
Response 200
Returns a DocumentVersionResponse.
Document version ID.
Underlying path part ID.
Version number (0, 1, 2, …).
Auto-generated name (e.g.
v0, v1).The parent document’s path part ID.
Full path from root.
Whether this version is system-managed.
Owning tenant.
Creation timestamp (ISO 8601).
Last update timestamp (ISO 8601).
Time-limited URL to download the source document.
null until ingestion completes.Time-limited URL to download a plain-text export of the document.
null until ingestion completes.Pipeline state, artifact URLs, and document statistics.
Example
List versions
GET https://api-staging.knowledgestack.ai/v1/document_versions
List all versions for a document.
Query parameters
The document whose versions to list.
Page size.
Pagination offset.
Response 200
Returns a paginated list of DocumentVersionResponse objects.
Example
Get version
GET https://api-staging.knowledgestack.ai/v1/document_versions/{version_id}
Get a single document version by ID.
Path parameters
The document version ID.
Response 200
Returns a DocumentVersionResponse. See Create version for field descriptions.
Example
Delete version
DELETE https://api-staging.knowledgestack.ai/v1/document_versions/{version_id}
Delete a document version and all of its sections and chunks.
You cannot delete the document’s active version. To delete the active version, first promote a different version using
PATCH /v1/documents/{document_id}.Path parameters
The version ID to delete.
Response 200
Returns an empty {} on success.
Example
Version action
POST https://api-staging.knowledgestack.ai/v1/document_versions/{version_id}
Perform an action on a document version.
Path parameters
The version to act on.
Query parameters
The action to perform. Currently supported:
reembed.Response 200
Returns a DocumentVersionActionResponse.
The version ID the action was applied to.
The action performed.
Workflow ID for tracking the background job.
Example
Update version metadata
PATCH https://api-staging.knowledgestack.ai/v1/document_versions/{version_id}/metadata
Partially update the system_metadata of a document version. Only the provided fields are merged into the existing metadata — omitted fields are left unchanged.
You typically do not need to call this endpoint directly — the ingestion pipeline updates version metadata automatically. Use it when you need to manually correct document statistics or pipeline state.
Path parameters
The version ID to update.
Request body (DocumentVersionMetadataUpdate)
All fields are optional. Provide only the fields you want to update.
Updated pipeline execution state object.
Total number of pages in the document.
Total number of sections created by ingestion.
Total number of chunks created by ingestion.
Base64-encoded SHA-256 hash of the source file.
Response 200
Returns the updated DocumentVersionResponse.
Example
Get version contents
GET https://api-staging.knowledgestack.ai/v1/document_versions/{version_id}/contents
Get the top-level contents of a document version as a paginated list of sections and chunks. Each item is a discriminated union of SectionContentItem or ChunkContentItem, identified by the part_type field.
Path parameters
The version whose contents to retrieve.
Query parameters
Restrict contents to a specific section.
Filter by content type (
SECTION or CHUNK).Page size.
Pagination offset.
Response 200
Returns a paginated list of SectionContentItem | ChunkContentItem discriminated by part_type.
Example
Clear version contents
DELETE https://api-staging.knowledgestack.ai/v1/document_versions/{version_id}/contents
Delete all top-level sections and chunks belonging to a document version. The version record itself is preserved.
This permanently removes all content under the version. It is typically used before re-ingesting a version to start fresh.
Path parameters
The version whose contents to clear.
Response 200
Returns a ClearVersionContentsResponse.
Number of top-level children (sections or chunks) deleted.