Chunk types
TheChunkType enum classifies the content of a chunk:
| Value | Description |
|---|---|
TEXT | Plain text content |
TABLE | Tabular data |
IMAGE | Image (the content field holds a description or alt text; visual assets are linked in asset_urls) |
HTML | HTML markup |
UNKNOWN | Unclassified content |
Search types
TheSearchType enum controls the retrieval strategy for chunk search:
| Value | Description |
|---|---|
dense_only | Dense vector (semantic) search using cosine similarity |
full_text | Full-text keyword search using BM25 |
Create chunk
POST https://api-staging.knowledgestack.ai/v1/chunks
Create a new chunk with content. The chunk is attached to a parent section or document version and is positioned within the sibling list.
Request body
path_part_id of the parent. Must be a DOCUMENT_VERSION or SECTION type path part.Chunk text content. Minimum 1 character. For
IMAGE chunks, this is typically a description or extracted alt text.Type of the chunk. One of
TEXT, TABLE, IMAGE, HTML, UNKNOWN.Metadata object for the chunk. Pass
{} if no metadata is needed. Key optional fields:summary(string) — LLM-generated summary used to enrich embeddings forTABLEandHTMLchunkspolygons(array) — bounding box references in the source documentasset_urls(string[]) — ordered URLs to visual assetssheet_name(string) — worksheet name (XLSX only)cell_range(string) — cell range e.g.A1:D10(XLSX only)
Insert after this sibling
path_part_id. Omit to append to the end of the sibling list.Response 200
Returns a ChunkResponse.
Chunk ID.
Underlying path part ID.
ID of the content record (content is deduplicated by hash).
Chunk text content.
Chunk type enum value.
Chunk metadata object.
Token count of the content.
Parent path part ID.
Previous sibling path part ID.
Next sibling path part ID.
Full path from root.
Whether this chunk is system-managed.
Owning tenant.
Creation timestamp (ISO 8601).
Last update timestamp (ISO 8601).
Time-limited URLs to visual assets. Populated for
IMAGE, TABLE, and HTML chunks.Lightweight ancestor document info. Populated when
with_document=true is passed on GET requests.Lightweight ancestor version info. Populated when
with_document=true.Example
Search chunks
POST https://api-staging.knowledgestack.ai/v1/chunks/search
Search chunks using dense vector (semantic) or BM25 full-text retrieval. Returns ranked results with similarity scores.
Request body
The search query. Minimum 1 character.
Retrieval strategy. One of
dense_only (semantic, default) or full_text (BM25 keyword).Restrict search to descendants of these path part IDs. Defaults to the tenant’s shared root if omitted.
Filter results to chunks that have all of the specified tags (AND logic).
Filter by chunk types. Only chunks matching one of the listed types are returned.
Only return chunks ingested after this ISO 8601 timestamp.
When
true (default), only chunks from the document’s active version are returned.Maximum number of results to return. Range 1–50. Defaults to
5.Minimum similarity score. Results below this threshold are excluded. Defaults to
0.3.Include ancestor
document_id and document_version_id in each result. Defaults to false.Response 200
Returns an array of ScoredChunkResponse objects sorted by descending score.
Cosine similarity score (range 0–1 for dense search, BM25 score for full-text).
ChunkResponse. See Create chunk for field descriptions.
Example
Get chunks (bulk)
GET https://api-staging.knowledgestack.ai/v1/chunks/bulk
Fetch multiple chunks by ID in a single request. Returns ChunkBulkResponse objects that include the full path_part_id_segments — the ordered ancestor chain from root to the chunk.
Non-existent IDs are silently skipped.
Query parameters
Comma-separated list of chunk IDs.
Response 200
Returns an array of ChunkBulkResponse objects. Identical to ChunkResponse plus:
Ordered list of ancestor path part IDs from root to this chunk.
Example
Get chunk IDs for a version
GET https://api-staging.knowledgestack.ai/v1/chunks/version-chunk-ids
Get all chunk IDs belonging to a document version. Useful for pipeline operations that need to enumerate chunks without fetching full content.
Query parameters
The document version ID.
Response 200
Returns a VersionChunkIdsResponse.
All chunk IDs in the specified document version.
Example
Get chunk
GET https://api-staging.knowledgestack.ai/v1/chunks/{chunk_id}
Get a single chunk by ID, including its full content.
Path parameters
The chunk ID.
Query parameters
Include ancestor document and version info in the response. Defaults to
false.Response 200
Returns a ChunkResponse. See Create chunk for field descriptions.
Example
Update chunk metadata
PATCH https://api-staging.knowledgestack.ai/v1/chunks/{chunk_id}
Update a chunk’s metadata or move it to a different parent or position in the sibling list. Metadata is shallow-merged — only the keys you provide are updated.
Path parameters
The chunk ID to update.
Request body
Metadata fields to merge into the existing
chunk_metadata. Partial updates are supported.Reparent to this path part ID. Must be a
DOCUMENT_VERSION or SECTION within the same document version.Move after this sibling path part ID.
Set to
true to move to the head of the sibling list. Defaults to false.Response 200
Returns the updated ChunkResponse.
Example
Delete chunk
DELETE https://api-staging.knowledgestack.ai/v1/chunks/{chunk_id}
Delete a chunk. The underlying content record may be preserved if shared by other chunks.
Path parameters
The chunk ID to delete.
Response 200
Returns an empty {} on success.
Example
Get chunk neighbors
GET https://api-staging.knowledgestack.ai/v1/chunks/{chunk_id}/neighbors
Walk the sibling linked list backward and forward from a given chunk to retrieve surrounding context. Useful for expanding a search result with adjacent content.
The response returns items in order: preceding siblings → anchor chunk → succeeding siblings. Each item is a discriminated union of ChunkContentItem or SectionContentItem, identified by part_type.
Path parameters
The anchor chunk ID.
Query parameters
Number of preceding siblings to retrieve. Defaults to
0.Number of succeeding siblings to retrieve. Defaults to
0.When
true, skip section items and return only chunks. Defaults to false.Response 200
Returns a ChunkNeighborsResponse.
Ordered list of siblings and the anchor chunk. Each item has a
part_type field (CHUNK or SECTION).The index of the anchor chunk in the
items array.Example
Update chunk content
PATCH https://api-staging.knowledgestack.ai/v1/chunks/{chunk_id}/content
Replace a chunk’s text content. This creates a new content row — the previous content is preserved in the content history but the chunk points to the new version.
After updating content, the chunk’s embedding is stale. Re-trigger embedding by running a
reembed action on the parent document version.Path parameters
The chunk ID to update.
Request body
New chunk text content. Minimum 1 character.
Response 200
Returns the updated ChunkResponse.