Knowledge store items

Use these methods to add assets to a knowledge store as items, and to organize those items into named collections.

Knowledge store items

The KnowledgeStoreItems class provides methods to add and manage the items in a knowledge store.

Create a knowledge store item

Description: This method adds an asset to a knowledge store for processing. The operation is asynchronous. The item is created immediately with the queued status and processed in the background.

The asset must not exceed 5 GB.

Function signature and example:

1create(
2 knowledgeStoreId: string,
3 request: TwelvelabsApi.KnowledgeStoreItemsCreateRequest,
4 requestOptions?: KnowledgeStoreItems.RequestOptions
5): Promise<TwelvelabsApi.KnowledgeStoreItem>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
assetIdstringYesThe unique identifier of the asset to add to the knowledge store.
assetTypeKnowledgeStore
ItemAssetType
NoThe type of item to create. Values: video, image.
metadataRecord
<string, string>
NoCustom metadata for the item. Both keys and values must be strings.
requestOptionsKnowledgeStoreItems.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a KnowledgeStoreItem object. The KnowledgeStoreItem object contains the following properties:

NameTypeDescription
idstringThe unique identifier of the knowledge store item.
assetTypeKnowledgeStore
ItemAssetType
The type of item. Values: video, image.
assetIdstringThe unique identifier of the source asset.
statusKnowledgeStore
ItemStatus
The processing status of the item. Values: queued, pending, processing, ready, failed. For the meaning of each value, see the Item statuses section on The knowledge store item object page.
systemMetadataKnowledgeStore
ItemSystemMetadata
System-generated media metadata for the source asset. Its assetType field always matches the item’s top-level assetType field.
metadataRecord
<string, string>
Custom metadata for the item.
createdAtstringThe date and time when the item was created, in the RFC 3339 format.
updatedAtstringThe date and time when the item was last updated, in the RFC 3339 format.

API Reference

Create a knowledge store item.

Add assets to a knowledge store.

List knowledge store items

Description: This method returns a list of items in the specified knowledge store.

Function signature and example:

1list(
2 knowledgeStoreId: string,
3 request?: TwelvelabsApi.KnowledgeStoreItemsListRequest,
4 requestOptions?: KnowledgeStoreItems.RequestOptions
5): Promise<core.Page<TwelvelabsApi.KnowledgeStoreItem>>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
sortByKnowledgeStore
ItemsListRequestSortBy
NoThe field to sort on. The following options are available:
- created_at: Sorts by the time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the item was created.
- updated_at: Sorts by the time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the item was last updated. Default: created_at.
sortOptionstringNoThe sorting direction. The following options are available:
- asc
- desc Default: desc.
statusKnowledgeStore
ItemsListRequestStatusItem[]
NoFilter by one or more item processing statuses. Values: queued, pending, processing, ready, failed. For the meaning of each value, see the Item statuses section on The knowledge store item object page.
requestOptionsKnowledgeStoreItems.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a Page<KnowledgeStoreItem> object that allows you to iterate through the paginated list of items. For the properties of each KnowledgeStoreItem object, see Create a knowledge store item.

API Reference

List knowledge store items.

Retrieve a knowledge store item

Description: This method retrieves the details of a specific knowledge store item.

Function signature and example:

1retrieve(
2 knowledgeStoreId: string,
3 itemId: string,
4 requestOptions?: KnowledgeStoreItems.RequestOptions
5): Promise<TwelvelabsApi.KnowledgeStoreItem>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
itemIdstringYesThe unique identifier of the knowledge store item.
requestOptionsKnowledgeStoreItems.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a KnowledgeStoreItem object. For its properties, see Create a knowledge store item.

API Reference

Retrieve a knowledge store item.

Delete a knowledge store item

Description: This method deletes the specified knowledge store item.

Function signature and example:

1delete(
2 knowledgeStoreId: string,
3 itemId: string,
4 requestOptions?: KnowledgeStoreItems.RequestOptions
5): Promise<void>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
itemIdstringYesThe unique identifier of the knowledge store item.
requestOptionsKnowledgeStoreItems.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

This method does not return a value.

API Reference

Delete a knowledge store item.

Item collections

The KnowledgeStoreItemCollections class provides methods to organize items into named collections that you can reference together.

Create an item collection

Description: This method creates an item collection in the specified knowledge store. An item collection is a named collection of items. Use item collections to organize and reference subsets of items together.

Function signature and example:

1create(
2 knowledgeStoreId: string,
3 request: TwelvelabsApi.KnowledgeStoreItemCollectionsCreateRequest,
4 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
5): Promise<TwelvelabsApi.KnowledgeStoreItemCollection>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
namestringYesThe name of the item collection. Must be unique within the knowledge store.
descriptionstringNoAn optional description of the item collection.
metadataRecord
<string, string>
NoCustom metadata for the item collection. Both keys and values must be strings.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a KnowledgeStoreItemCollection object. The KnowledgeStoreItemCollection object contains the following properties:

NameTypeDescription
idstringThe unique identifier of the item collection.
knowledgeStoreIdstringThe unique identifier of the knowledge store this collection belongs to.
namestringThe name of the item collection.
descriptionstringThe description of the item collection.
metadataRecord
<string, string>
Custom metadata for the item collection.
memberCountnumberThe number of items in the collection.
createdAtstringThe date and time when the item collection was created, in the RFC 3339 format.
updatedAtstringThe date and time when the item collection was last updated, in the RFC 3339 format.

API Reference

Create an item collection.

List item collections

Description: This method returns a list of the item collections in the specified knowledge store.

Function signature and example:

1list(
2 knowledgeStoreId: string,
3 request?: TwelvelabsApi.KnowledgeStoreItemCollectionsListRequest,
4 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
5): Promise<core.Page<TwelvelabsApi.KnowledgeStoreItemCollection>>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
sortByKnowledgeStoreItem
CollectionsList
RequestSortBy
NoThe field to sort on. The following options are available:
- created_at: Sorts by the time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the item collection was created.
- updated_at: Sorts by the time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the item collection was last updated.
- name: Sorts alphabetically by the name of the item collection. Default: created_at.
sortOptionstringNoThe sorting direction. The following options are available:
- asc
- desc Default: desc.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a Page<KnowledgeStoreItemCollection> object that allows you to iterate through the paginated list of item collections. For the properties of each KnowledgeStoreItemCollection object, see Create an item collection.

API Reference

List item collections.

Retrieve an item collection

Description: This method retrieves the details of a specific item collection.

Function signature and example:

1retrieve(
2 knowledgeStoreId: string,
3 collectionId: string,
4 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
5): Promise<TwelvelabsApi.KnowledgeStoreItemCollection>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
collectionIdstringYesThe unique identifier of the knowledge store item collection.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a KnowledgeStoreItemCollection object. For its properties, see Create an item collection.

API Reference

Retrieve an item collection.

Update an item collection

Description: This method updates the name, description, and metadata fields of the specified item collection.

Function signature and example:

1update(
2 knowledgeStoreId: string,
3 collectionId: string,
4 request?: TwelvelabsApi.KnowledgeStoreItemCollectionsUpdateRequest,
5 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
6): Promise<TwelvelabsApi.KnowledgeStoreItemCollection>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
collectionIdstringYesThe unique identifier of the knowledge store item collection.
namestringNoThe name of the item collection. Must be unique within the knowledge store.
descriptionstringNoAn optional description of the item collection.
metadataRecord
<string, string>
NoCustom metadata for the item collection. Both keys and values must be strings. To remove all metadata, set this field to an empty object ({}).
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a KnowledgeStoreItemCollection object. For its properties, see Create an item collection.

API Reference

Update an item collection.

Delete an item collection

Description: This method deletes the specified item collection. The items themselves remain in the knowledge store.

Function signature and example:

1delete(
2 knowledgeStoreId: string,
3 collectionId: string,
4 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
5): Promise<void>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
collectionIdstringYesThe unique identifier of the knowledge store item collection.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

This method does not return a value.

API Reference

Delete an item collection.

List items in an item collection

Description: This method returns a list of the items in the specified item collection.

Function signature and example:

1listItems(
2 knowledgeStoreId: string,
3 collectionId: string,
4 request?: TwelvelabsApi.KnowledgeStoreItemCollectionsListItemsRequest,
5 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
6): Promise<core.Page<TwelvelabsApi.KnowledgeStoreItem>>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
collectionIdstringYesThe unique identifier of the knowledge store item collection.
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a Page<KnowledgeStoreItem> object that allows you to iterate through the paginated list of items in the collection. For the properties of each KnowledgeStoreItem object, see Create a knowledge store item.

API Reference

List items in an item collection.

Add items to an item collection

Description: This method adds one or more items to the specified item collection. This operation is idempotent — items already in the collection are skipped. Every identifier must reference an existing item in the knowledge store.

Function signature and example:

1addItems(
2 knowledgeStoreId: string,
3 collectionId: string,
4 request: TwelvelabsApi.KnowledgeStoreItemCollectionsAddItemsRequest,
5 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
6): Promise<TwelvelabsApi.KnowledgeStoreItemCollection>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
collectionIdstringYesThe unique identifier of the knowledge store item collection.
itemIdsstring[]YesThe unique identifiers of the items to add to the collection. Include up to 500 identifiers per request.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns a KnowledgeStoreItemCollection object. For its properties, see Create an item collection.

API Reference

Add items to an item collection.

Remove items from an item collection

Description: This method removes one or more items from the specified item collection. This operation is idempotent — identifiers that do not match a member of the collection are ignored. The items themselves remain in the knowledge store.

Function signature and example:

1removeItems(
2 knowledgeStoreId: string,
3 collectionId: string,
4 request: TwelvelabsApi.KnowledgeStoreItemCollectionsRemoveItemsRequest,
5 requestOptions?: KnowledgeStoreItemCollections.RequestOptions
6): Promise<void>

Parameters

NameTypeRequiredDescription
knowledgeStoreIdstringYesThe unique identifier of the knowledge store.
collectionIdstringYesThe unique identifier of the knowledge store item collection.
itemIdsstring[]YesThe unique identifiers of the items to remove from the collection. Include up to 500 identifiers per request.
requestOptionsKnowledgeStoreItem
Collections.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

This method does not return a value.

API Reference

Remove items from an item collection.