Skip to main content

Knowledge API

Knowledge API

import { CodeBoltClient } from '@codebolt/clientsdk';

const client = new CodeBoltClient();

Quick Reference

MethodDescription
addDocumentFromUrlAdds a document to a collection by fetching it from a URL.
addDocumentsAdds one or more documents to a knowledge collection.
createCollectionCreates a new knowledge collection.
deleteCollectionDeletes a knowledge collection and all its documents.
deleteDocumentDeletes a document and all its associated chunks.
getCollectionRetrieves a specific knowledge collection by its ID.
getDocumentRetrieves a specific document by its ID.
getSettingsRetrieves the settings for a knowledge collection.
getStrategiesRetrieves all available chunking strategies.
getStrategyOptionsRetrieves the configurable options for a specific chunking strategy.
listCollectionsLists all knowledge collections.
listDocumentsLists all documents in a knowledge collection.
rechunkDocumentRe-chunks a document using updated chunking settings.
updateChunkUpdates a specific chunk's content or metadata.
updateCollectionUpdates a knowledge collection's properties.
updateSettingsUpdates the settings for a knowledge collection.

Methods


addDocumentFromUrl

client.knowledge.addDocumentFromUrl(id: string, data: AddKnowledgeDocumentFromUrlRequest): Promise<unknown>

Adds a document to a collection by fetching it from a URL.

Downloads the content at the specified URL and adds it as a document to the collection. The content is automatically parsed and chunked.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the target collection
dataAddKnowledgeDocumentFromUrlRequestYesRequest specifying the URL and optional metadata

Returns: Promise<unknown> — A promise that resolves when the document has been fetched and added

Full reference →


addDocuments

client.knowledge.addDocuments(id: string, data: AddKnowledgeDocumentsRequest): Promise<unknown>

Adds one or more documents to a knowledge collection.

Uploads documents that will be automatically processed, chunked, and indexed for retrieval. Supports multiple documents in a single request.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the target collection
dataAddKnowledgeDocumentsRequestYesThe documents to add, including their content and metadata

Returns: Promise<unknown> — A promise that resolves when the documents have been added and processing has begun

Full reference →


createCollection

client.knowledge.createCollection(data: CreateKnowledgeCollectionRequest): Promise<KnowledgeCollection>

Creates a new knowledge collection.

A collection is a named container for related documents. Documents added to a collection are automatically chunked and indexed for retrieval by agents.

ParameterTypeRequiredDescription
dataCreateKnowledgeCollectionRequestYesCollection creation payload including name and configuration

Returns: Promise<KnowledgeCollection> — A promise that resolves to the newly created

Full reference →


deleteCollection

client.knowledge.deleteCollection(id: string): Promise<unknown>

Deletes a knowledge collection and all its documents.

Permanently removes the collection, its documents, and all associated chunks. This action cannot be undone.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the collection to delete

Returns: Promise<unknown> — A promise that resolves when deletion is complete

Full reference →


deleteDocument

client.knowledge.deleteDocument(documentId: string): Promise<unknown>

Deletes a document and all its associated chunks.

Permanently removes the document from its collection. The collection itself is not affected.

ParameterTypeRequiredDescription
documentIdstringYesThe unique identifier of the document to delete

Returns: Promise<unknown> — A promise that resolves when deletion is complete

Full reference →


getCollection

client.knowledge.getCollection(id: string): Promise<KnowledgeCollection>

Retrieves a specific knowledge collection by its ID.

Returns the full details of a collection including its metadata, document count, and configuration.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the knowledge collection

Returns: Promise<KnowledgeCollection> — A promise that resolves to the

Full reference →


getDocument

client.knowledge.getDocument(documentId: string): Promise<KnowledgeDocument>

Retrieves a specific document by its ID.

Returns the full details of a document including its metadata, processing status, and chunk count.

ParameterTypeRequiredDescription
documentIdstringYesThe unique identifier of the document

Returns: Promise<KnowledgeDocument> — A promise that resolves to the

Full reference →


getSettings

client.knowledge.getSettings(id: string): Promise<KnowledgeCollectionSettings>

Retrieves the settings for a knowledge collection.

Returns the collection's chunking configuration, embedding settings, and other processing parameters.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the collection

Returns: Promise<KnowledgeCollectionSettings> — A promise that resolves to the

Full reference →


getStrategies

client.knowledge.getStrategies(): Promise<KnowledgeStrategy[]>

Retrieves all available chunking strategies.

Returns the list of chunking algorithms that can be used when processing documents (e.g., fixed-size, sentence-based, semantic).

No parameters.

Returns: Promise<KnowledgeStrategy[]> — A promise that resolves to an array of descriptors

Full reference →


getStrategyOptions

client.knowledge.getStrategyOptions(strategy: string): Promise<KnowledgeStrategyOptions>

Retrieves the configurable options for a specific chunking strategy.

Returns the parameter schema for the strategy, including defaults and valid ranges. Use this to build dynamic configuration UIs.

ParameterTypeRequiredDescription
strategystringYesThe name of the chunking strategy

Returns: Promise<KnowledgeStrategyOptions> — A promise that resolves to the for the strategy

Full reference →


listCollections

client.knowledge.listCollections(params?: Record<string, unknown>): Promise<KnowledgeCollection[]>

Lists all knowledge collections.

Returns every collection in the system. Use optional parameters to filter or paginate the results.

ParameterTypeRequiredDescription
paramsRecord<string, unknown>NoOptional query parameters for filtering or pagination

Returns: Promise<KnowledgeCollection[]> — A promise that resolves to an array of objects

Full reference →


listDocuments

client.knowledge.listDocuments(id: string, params?: Record<string, unknown>): Promise<KnowledgeDocument[]>

Lists all documents in a knowledge collection.

Returns the documents belonging to the specified collection with their metadata. Does not include chunk-level content.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the collection
paramsRecord<string, unknown>NoOptional query parameters for filtering or pagination

Returns: Promise<KnowledgeDocument[]> — A promise that resolves to an array of objects

Full reference →


rechunkDocument

client.knowledge.rechunkDocument(documentId: string, data?: RechunkDocumentRequest): Promise<unknown>

Re-chunks a document using updated chunking settings.

Discards existing chunks and re-processes the document with the current or specified chunking strategy. Useful after changing collection settings or chunking parameters.

ParameterTypeRequiredDescription
documentIdstringYesThe unique identifier of the document to re-chunk
dataRechunkDocumentRequestNoOptional parameters specifying the new chunking configuration

Returns: Promise<unknown> — A promise that resolves when re-chunking is complete

Full reference →


updateChunk

client.knowledge.updateChunk(chunkId: string, data: UpdateKnowledgeChunkRequest): Promise<unknown>

Updates a specific chunk's content or metadata.

Modifies an individual chunk within a document. Useful for correcting chunking artifacts or adding manual annotations.

ParameterTypeRequiredDescription
chunkIdstringYesThe unique identifier of the chunk to update
dataUpdateKnowledgeChunkRequestYesThe fields to update on the chunk

Returns: Promise<unknown> — A promise that resolves when the chunk has been updated

Full reference →


updateCollection

client.knowledge.updateCollection(id: string, data: UpdateKnowledgeCollectionRequest): Promise<KnowledgeCollection>

Updates a knowledge collection's properties.

Modifies collection settings such as name, description, or chunking configuration.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the collection to update
dataUpdateKnowledgeCollectionRequestYesThe fields to update

Returns: Promise<KnowledgeCollection> — A promise that resolves to the updated

Full reference →


updateSettings

client.knowledge.updateSettings(id: string, data: UpdateKnowledgeSettingsRequest): Promise<KnowledgeCollectionSettings>

Updates the settings for a knowledge collection.

Modifies chunking strategy, chunk size, overlap, and other processing parameters. Existing documents are not automatically re-chunked; use to apply new settings to existing content.

ParameterTypeRequiredDescription
idstringYesThe unique identifier of the collection
dataUpdateKnowledgeSettingsRequestYesThe settings to update

Returns: Promise<KnowledgeCollectionSettings> — A promise that resolves to the updated

Full reference →