Index content

The Indexes.IndexedAssets interface provides methods to manage indexed assets within an index.

Workflow

Before you begin, create an index if you don’t have one.

1

Upload your content using direct or multipart uploads. The platform creates an asset and return its unique identifier.

2

Index your content using the indexes.indexedAssets.create method.

3

Monitor the indexing status until it shows ready using the indexes.indexedAssets.retrieve method.

4

Search or analyze your content.

Index an asset

Description: This method indexes an uploaded asset to make it searchable and analyzable. Indexing processes your content and extracts information that enables the platform to search and analyze your videos.

This operation is asynchronous. The platform returns an indexed asset ID immediately and processes your content in the background. Monitor the indexing status to know when your content is ready to use.

Your asset must meet the requirements based on your workflow:

If you want to both search and analyze your videos, the most restrictive requirements apply.

Function signature and example:

1create(
2 indexId: string,
3 request: TwelvelabsApi.indexes.IndexedAssetsCreateRequest,
4 requestOptions?: IndexedAssets.RequestOptions
5): core.HttpResponsePromise<TwelvelabsApi.indexes.IndexedAssetsCreateResponse>

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the asset will be indexed.
assetIdstringYesThe unique identifier of the asset to index.
enableVideoStreambooleanNoThis parameter indicates if the platform stores the video for streaming. When set to true, the platform stores the video, and you can retrieve its URL to access the stream over the HLS protocol.
requestOptionsIndexedAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to an IndexedAssetsCreateResponse object containing the indexed asset details.

The IndexedAssetsCreateResponse interface contains the following properties:

NameTypeDescription
idstringThe unique identifier of the indexed asset. Use it to monitor the indexing progress.

API Reference: Index an asset

Retrieve an indexed asset

Description: This method retrieves information about an indexed asset, including its status, metadata, and optional embeddings or transcription.

Use this method to:

  • Monitor the indexing progress:

    • Call this endpoint after creating an indexed asset
    • Check the status field until it shows ready
    • Once ready, your content is available for search and analysis
  • Retrieve the asset metadata:

    • Retrieve system metadata (duration, resolution, filename)
    • Access user-defined metadata
  • Retrieve the embeddings:

    • Include the embeddingOption parameter to retrieve video embeddings
    • Requires the Marengo video understanding model to be enabled in your index
  • Retrieve transcriptions:

    • Set the transcription parameter to true to retrieve spoken words from your video

Function signature and example:

1retrieve(
2 indexId: string,
3 indexedAssetId: string,
4 request?: TwelvelabsApi.indexes.IndexedAssetsRetrieveRequest,
5 requestOptions?: IndexedAssets.RequestOptions
6): core.HttpResponsePromise<TwelvelabsApi.IndexedAssetDetailed>

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the indexed asset has been uploaded.
indexedAssetIdstringYesThe unique identifier of the indexed asset to retrieve.
embeddingOptionTwelvelabsApi.indexes.IndexedAssetsRetrieveRequestEmbeddingOptionItem | TwelvelabsApi.indexes.IndexedAssetsRetrieveRequestEmbeddingOptionItem[]NoSpecifies which types of embeddings to retrieve. Values vary by model version:
- Marengo 3.0: visual, audio, transcription
- Marengo 2.7: visual-text, audio

To retrieve embeddings, the video must be indexed using the Marengo model.
transcriptionbooleanNoIndicates whether to retrieve a transcription of the spoken words for the indexed asset.
requestOptionsIndexedAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to an IndexedAssetDetailed object containing detailed information about the indexed asset.

The IndexedAssetDetailed interface extends IndexedAsset and contains the following additional properties:

NameTypeDescription
userMetadataRecord<string, any>User-generated metadata about the indexed asset.
hlsTwelvelabsApi.HlsObjectThe platform returns this object only for videos uploaded with the enableVideoStream parameter set to true.
embeddingTwelvelabsApi.IndexedAssetDetailedEmbeddingContains the embedding and the associated information. The platform returns this field when the embeddingOption parameter is specified in the request.
transcriptionTwelvelabsApi.TranscriptionDataItem[]A list of transcription segments. The platform returns this field when the transcription parameter is set to true.

The IndexedAssetDetailed interface also inherits all properties from IndexedAsset:

NameTypeDescription
idstringThe unique identifier of the indexed asset.
createdAtstringThe date and time, in RFC 3339 format, when the indexing task was created.
updatedAtstringThe date and time, in RFC 3339 format, when the indexing task was last updated.
indexedAtstringThe date and time, in RFC 3339 format, when the indexing task was completed.
statusTwelvelabsApi.IndexedAssetStatusThe status of the indexing task. Values: ready, pending, queued, indexing, failed.
systemMetadataTwelvelabsApi.IndexedAssetSystemMetadataSystem-generated metadata about the indexed asset.

The IndexedAssetSystemMetadata interface contains the following properties:

NameTypeDescription
filenamestringThe filename of the indexed asset.
durationnumberThe duration of the video in seconds.
fpsnumberThe frames per second of the video.
widthnumberThe width of the video in pixels.
heightnumberThe height of the video in pixels.
sizenumberThe size of the file in bytes.

The HlsObject interface contains the following properties:

NameTypeDescription
videoUrlstringThe URL of the video. You can use this URL to access the stream over the HLS protocol.
thumbnailUrlsstring[]An array containing the URLs of thumbnails.
statusTwelvelabsApi.HlsObjectStatusThe encoding status of the video file. Values: PROCESSING (video is being encoded), COMPLETE (encoding finished), CANCELED (encoding was canceled), ERROR (encoding error occurred).
updatedAtstringThe date and time, in RFC 3339 format, when the encoding status was last updated.

The TranscriptionDataItem interface contains the following properties:

NameTypeDescription
startnumberThe start of the time range, expressed in seconds.
endnumberThe end of the time range, expressed in seconds.
valuestringText representing the spoken words within this time range.

API Reference: Retrieve an indexed asset

List indexed assets

Description: This method returns a list of the indexed assets in the specified index. By default, the platform returns your indexed assets sorted by creation date, with the newest at the top of the list.

Function signature and example:

1list(
2 indexId: string,
3 request?: TwelvelabsApi.indexes.IndexedAssetsListRequest,
4 requestOptions?: IndexedAssets.RequestOptions
5): Promise<core.Page<TwelvelabsApi.IndexedAsset>>

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index for which the platform will retrieve the indexed assets.
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
sortBystringNoThe field to sort on. Values: updated_at, created_at. Default: created_at.
sortOptionstringNoThe sorting direction. Values: asc, desc. Default: desc.
statusTwelvelabsApi.indexes.IndexedAssetsListRequestStatusItem | TwelvelabsApi.indexes.IndexedAssetsListRequestStatusItem[]NoFilter by one or more indexing task statuses. Values: ready, pending, queued, indexing, failed.
filenamestringNoFilter by filename.
durationnumberNoFilter by duration. Expressed in seconds.
fpsnumberNoFilter by frames per second.
widthnumberNoFilter by width.
heightnumberNoFilter by height.
sizenumberNoFilter by size. Expressed in bytes.
createdAtstringNoFilter indexed assets by the creation date and time of their associated indexing tasks, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”).
updatedAtstringNoFilter indexed assets by the last update date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”). This filter applies only to indexed assets updated using the update method.
userMetadataRecord<string, any>NoFilter by custom user-defined metadata fields. To enable filtering, you must first add user-defined metadata to your video.
requestOptionsIndexedAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to a Page<IndexedAsset> object that allows you to iterate through the paginated indexed asset results.

The Page<T> interface contains the following properties and methods:

NameTypeDescription
dataT[]An array containing the current page of items.
hasNextPage()booleanReturns whether there is a next page to load.
getNextPage()Promise<Page<T>>Retrieves the next page and returns the updated Page object.
[Symbol.asyncIterator]()AsyncIterator<T>Allows iteration through all items across all pages using for await loops.

The IndexedAsset interface contains the following properties:

NameTypeDescription
idstringA string representing the unique identifier of your indexed asset.
createdAtstringA string indicating the date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), that the indexing task was created.
updatedAtstringA string indicating the date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), that the indexing task was last updated.
indexedAtstringA string indicating the date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), that the indexing task has been completed.
statusTwelvelabsApi.IndexedAssetStatusThe status of the indexing task. Values: ready, pending, queued, indexing, failed.
systemMetadataTwelvelabsApi.IndexedAssetSystemMetadataSystem-generated metadata about the indexed asset.

API Reference: List indexed assets

Update an indexed asset

Description: This method updates one or more fields of the metadata of an indexed asset. You can also delete a field by setting it to null.

Function signature and example:

1update(
2 indexId: string,
3 indexedAssetId: string,
4 request: TwelvelabsApi.indexes.IndexedAssetsUpdateRequest,
5 requestOptions?: IndexedAssets.RequestOptions
6): core.HttpResponsePromise<void>

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the indexed asset has been uploaded.
indexedAssetIdstringYesThe unique identifier of the indexed asset to update.
userMetadataRecord<string, any>NoUser-defined metadata to associate with the indexed asset. You can use strings, integers, floats, and booleans as values.
requestOptionsIndexedAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to void.

API Reference: Update indexed asset

Delete an indexed asset

Description: This method deletes all the information about the specified indexed asset. This action cannot be undone.

Function signature and example:

1delete(
2 indexId: string,
3 indexedAssetId: string,
4 requestOptions?: IndexedAssets.RequestOptions
5): core.HttpResponsePromise<void>

Parameters:

NameTypeRequiredDescription
indexIdstringYesThe unique identifier of the index to which the indexed asset has been uploaded.
indexedAssetIdstringYesThe unique identifier of the indexed asset to delete.
requestOptionsIndexedAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to void.

API Reference: Delete an indexed asset