Manage assets

The AssetsClient class provides methods to work with assets after you upload them. Use these methods to retrieve and list assets, manage their user-defined metadata, retrieve transcriptions, and delete assets you no longer need.

To create an asset, see the Direct uploads or Multipart uploads page.

Methods

List assets

Description: This method returns a list of assets in your account.

The platform returns your assets sorted by creation date, with the newest at the top of the list.

Function signature and example:

1list(
2 request?: TwelvelabsApi.AssetsListRequest,
3 requestOptions?: Assets.RequestOptions
4): Promise<core.Page<TwelvelabsApi.AssetDetail>>

Parameters

NameTypeRequiredDescription
requestTwelvelabsApi.AssetsListRequestYesParameters for creating the index.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsListRequest interface has the following properties:

NameTypeRequiredDescription
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
assetIdsstring | string[]NoFilters the response to include only assets with the specified IDs. Provide one or more asset IDs. When you specify multiple IDs, the platform returns all matching assets.
assetTypesTwelvelabsApi.AssetsListRequestAssetTypesItem | TwelvelabsApi.AssetsListRequestAssetTypesItem[]NoFilters the response to include only assets of the specified types. Provide one or more asset types. When you specify multiple types, the platform returns all matching assets. Values: image, video, audio.
filenamestringNoFilters the response to include only assets whose filename contains the specified string. The match is case-insensitive and supports partial matching.

Return value

Returns a Promise that resolves to a Page<TwelvelabsApi.AssetDetail> object that allows you to iterate through the paginated asset results. The AssetDetail interface extends Asset with additional fields for HLS streaming and thumbnail details. For details about the TwelvelabsApi.AssetDetail interface, see the Retrieve an asset section below.

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.asyncIteratorAsyncIterator<T>Allows iteration through all items across all pages using for await loops.

API Reference

List assets

Retrieve an asset

Description: This method retrieves details about the specified asset.

Function signature and example:

1retrieve(
2 assetId: string,
3 requestOptions?: Assets.RequestOptions
4): core.HttpResponsePromise<TwelvelabsApi.AssetDetail>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset to retrieve.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

Return value

Returns an HttpResponsePromise that resolves to a TwelvelabsApi.AssetDetail object containing details about the specified asset.

The TwelvelabsApi.AssetDetail interface extends TwelvelabsApi.Asset (documented in the Create an asset section above) with the following additional properties:

NameTypeDescription
hlsTwelvelabsApi.AssetHlsHLS streaming details for the asset. Present only when HLS generation has been requested.
thumbnailTwelvelabsApi.AssetThumbnailThumbnail details for the asset. Present only when thumbnail generation has been requested.
technicalMetadataTwelvelabsApi.TechnicalMetadataTechnical metadata read from the media file of the asset, covering the container, the individual video and audio streams, image properties, and derived attributes.

The platform populates this object asynchronously after the upload completes. It is omitted from the response while the status of the asset is processing, and it may be partially populated when the status is failed. A field is absent when it does not apply to the media type of the asset, or when the source file did not carry the corresponding information.

The TwelvelabsApi.AssetHls interface contains the following properties:

NameTypeDescription
manifestUrlstringThe URL of the HLS manifest file for streaming. Only present when the status is ready.
statusTwelvelabsApi.AssetHlsStatusThe status of the HLS stream. Values: pending (the platform has not yet started HLS generation), processing (the platform is generating HLS segments), ready (the HLS stream is ready for playback), error (HLS generation failed).

The TwelvelabsApi.AssetThumbnail interface contains the following properties:

NameTypeDescription
representativeUrlstringThe URL of the representative thumbnail image. Only present when the status is ready.
statusTwelvelabsApi.AssetThumbnailStatusThe status of the thumbnail. Values: pending (the platform has not yet started thumbnail generation), processing (the platform is generating the thumbnail), ready (the thumbnail is ready), error (thumbnail generation failed).

The TwelvelabsApi.TechnicalMetadata interface contains the following properties:

NameTypeDescription
fileSizeBytesnumberThe size of the source media file in bytes.
fileMimeTypestringThe MIME type detected for the source media file.
fileContainerFormatstringThe container format of the source media file. When a container maps to several format names, the platform reports them as a comma-separated list.
containerCreationTimeDateThe creation time recorded in the media container, in RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when present.
videoStreamsTwelvelabsApi.VideoStream[]The video streams contained in the media file.
videoCodecstringThe codec of the primary video stream.
videoWidthnumberThe pixel width of the primary video stream.
videoHeightnumberThe pixel height of the primary video stream.
videoFpsnumberThe frame rate of the primary video stream, in frames per second.
videoDurationSecondsnumberThe duration of the primary video stream, in seconds.
videoBitrateBpsnumberThe bit rate of the primary video stream, in bits per second.
audioStreamsTwelvelabsApi.AudioStream[]The audio streams contained in the media file.
audioCodecstringThe codec of the primary audio stream.
audioSampleRatenumberThe sample rate of the primary audio stream, in hertz.
audioChannelsnumberThe number of channels in the primary audio stream.
audioDurationSecondsnumberThe duration of the primary audio stream, in seconds.
startTimecodestringThe starting SMPTE timecode of the media, when present.
timecodeSourcestringThe source from which the starting timecode was derived.
dropFramebooleanWhether the timecode uses drop-frame numbering.
imageWidthnumberThe pixel width of the image.
imageHeightnumberThe pixel height of the image.
imageFormatstringThe format of the image.
imageOrientationnumberThe EXIF orientation value of the image.
imageColorSpacestringThe color space of the image.
imageBitDepthnumberThe bit depth per channel of the image.
isHdrbooleanWhether the media is high dynamic range (HDR).
hasAudiobooleanWhether the media contains at least one audio stream.
hasAlphabooleanWhether the image contains an alpha (transparency) channel.
isAnimatedbooleanWhether the image is animated (for example, an animated GIF or WebP).
totalVideoStreamsnumberThe total number of video streams in the media file.
totalAudioStreamsnumberThe total number of audio streams in the media file.
storageAspectRationumberThe storage aspect ratio of the video (pixel width divided by pixel height).
geospatialLatitudenumberThe GPS latitude embedded in the source media, in decimal degrees. Present only when the source media carries location metadata.
geospatialLongitudenumberThe GPS longitude embedded in the source media, in decimal degrees. Present only when the source media carries location metadata.
geospatialAltitudeMetersnumberThe GPS altitude embedded in the source media, in meters. Present only when the source media carries location metadata.

The TwelvelabsApi.VideoStream interface contains the following properties:

NameTypeDescription
indexnumberThe zero-based index of the stream within the media file.
codecstringThe codec of the video stream.
widthnumberThe pixel width of the video stream.
heightnumberThe pixel height of the video stream.
fpsnumberThe nominal frame rate of the video stream, in frames per second.
avgFpsnumberThe average frame rate of the video stream, in frames per second.
durationSecondsnumberThe duration of the video stream, in seconds.
bitrateBpsnumberThe bit rate of the video stream, in bits per second.
rotationnumberThe rotation applied to the video stream, in degrees.
pixelAspectRatiostringThe pixel (sample) aspect ratio of the video stream.
displayAspectRatiostringThe display aspect ratio of the video stream.
scanTypestringThe scan type of the video stream (for example, progressive or interlaced).
pixelFormatstringThe pixel format of the video stream.
bitDepthnumberThe bit depth per color component of the video stream.
colorRangestringThe color range of the video stream.
colorTransferstringThe color transfer characteristics of the video stream.
colorSpacestringThe color space of the video stream.
colorPrimariesstringThe color primaries of the video stream.

The TwelvelabsApi.AudioStream interface contains the following properties:

NameTypeDescription
indexnumberThe zero-based index of the stream within the media file.
codecstringThe codec of the audio stream.
codecLongstringThe descriptive long name of the audio codec.
sampleRatenumberThe sample rate of the audio stream, in hertz.
bitDepthnumberThe bit depth of the audio stream.
channelsnumberThe number of channels in the audio stream.
channelLayoutstringThe channel layout of the audio stream.
bitrateBpsnumberThe bit rate of the audio stream, in bits per second.
languagestringThe language of the audio stream, when present.
durationSecondsnumberThe duration of the audio stream, in seconds.

API Reference

Retrieve an asset

Delete an asset

Description: This method deletes the specified asset. This action cannot be undone. By default, the platform checks whether any indexed assets reference the asset. If references exist, the request fails with a 409 Conflict error. Set the force parameter to true to delete the asset regardless.

Function signature and example:

1delete(
2 assetId: string,
3 request?: TwelvelabsApi.AssetsDeleteRequest,
4 requestOptions?: Assets.RequestOptions
5): core.HttpResponsePromise<void>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset to delete.
requestTwelvelabsApi.AssetsDeleteRequestNoParameters for deleting an asset.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsDeleteRequest interface has the following properties:

NameTypeRequiredDescription
forcebooleanNoWhen set to true, the platform deletes the asset even if indexed assets reference it. When set to false or omitted, the request fails with 409 Conflict if references exist. Default: false.

Return value

Returns an HttpResponsePromise that resolves to void.

API Reference

Delete asset

Delete the user-defined metadata of an asset

Description: This method deletes the user-defined metadata of the specified asset. To achieve the same result, you can also send an empty object ({}) in the user_metadata field of the replaceUserMetadata method.

This action cannot be undone.

Function signature and example:

1deleteUserMetadata(
2 assetId: string,
3 requestOptions?: Assets.RequestOptions
4): core.HttpResponsePromise<void>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset whose user-defined metadata to delete.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

Return value

Returns an HttpResponsePromise that resolves to void.

API Reference

Delete the user-defined metadata of an asset

Update the user-defined metadata of an asset

Description: This method updates the user-defined metadata of the specified asset. The platform merges your changes with the existing metadata:

  • A key with a value creates or replaces that key.
  • A key set to null deletes that key.
  • A key set to an empty string ("") is ignored.
  • A key you omit from the request keeps its current value.

To replace all metadata in a single call, use the replaceUserMetadata method instead.

Function signature and example:

1updateUserMetadata(
2 assetId: string,
3 request: TwelvelabsApi.AssetsUpdateUserMetadataRequest,
4 requestOptions?: Assets.RequestOptions
5): core.HttpResponsePromise<void>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset whose user-defined metadata to update.
requestTwelvelabsApi.AssetsUpdateUserMetadataRequestYesParameters for updating asset user metadata.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsUpdateUserMetadataRequest interface has the following properties:

NameTypeRequiredDescription
userMetadataTwelvelabsApi.UserMetadataYesThe metadata to set or update. Keys must be of type string, and values can be of the following types: string, integer, float, or boolean.

Return value

Returns an HttpResponsePromise that resolves to void.

API Reference

Update the user-defined metadata of an asset

Replace the user-defined metadata of an asset

Description: This method replaces the entire user-defined metadata of the specified asset. Unlike the updateUserMetadata method, which merges your changes with the existing metadata, this method overwrites the stored value in full:

  • A key with a value creates or replaces that key.
  • A key set to an empty string ("") or null is ignored.
  • A key you omit from the request body is removed.

To clear all metadata, send an empty object ({}) in the user_metadata field. This produces the same result as the deleteUserMetadata method.

Function signature and example:

1replaceUserMetadata(
2 assetId: string,
3 request: TwelvelabsApi.AssetsReplaceUserMetadataRequest,
4 requestOptions?: Assets.RequestOptions
5): core.HttpResponsePromise<void>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset whose user-defined metadata to replace.
requestTwelvelabsApi.AssetsReplaceUserMetadataRequestYesParameters for replacing asset user metadata.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsReplaceUserMetadataRequest interface has the following properties:

NameTypeRequiredDescription
userMetadataTwelvelabsApi.UserMetadataYesThe metadata to set. Keys must be of type string, and values can be of the following types: string, integer, float, or boolean.

Return value

Returns an HttpResponsePromise that resolves to void.

API Reference

Replace the user-defined metadata of an asset

Error codes

This section lists the most common error messages you may encounter while performing asset-related operations.

  • content_type_invalid
    • The content type {content_type} is not supported. Please use multipart/form-data.
  • multipart_boundary_missing
    • Multipart boundary is missing. Please provide the boundary in the Content-Type header.
  • invalid_multipart
    • Invalid multipart form. Please check your implementation and try again.
  • echo bind error
    • (Returns the raw bind error message)
  • echo validate error
    • (Returns a validator-generated message, for example: Key: 'CreateAssetRequest.Method' Error:Field validation for 'Method' failed on the 'oneof' tag)
  • parameter_not_provided
    • The file parameter is required but was not provided. file is required when method is direct.
    • The url parameter is required but was not provided. url is required when method is url.
  • parameter_invalid
    • The method parameter is invalid. To upload in parts, use the /assets/multipart-uploads endpoint.
    • The file parameter is invalid. Unable to process the uploaded file. Please try uploading again.
    • The file parameter is invalid. Unsupported asset type: {asset_type}.
    • The image parameter is invalid. Image dimensions {current_dimensions} are below the minimum {minimum_dimensions}.
    • The image parameter is invalid. Invalid image file. Please check the format and dimensions.
  • media_url_unsupported_format
    • The file at the provided URL is not a supported media format. Detected format: {detected_format}. Please provide a valid asset file.
  • media_url_not_accessible
    • Cannot access the media URL {url}. The server responded with an error. Please verify the URL is correct and publicly accessible.
  • media_url_file_broken
    • Cannot read the media file at the specified URL. Please verify the file is valid and try again.
  • media_filesize_too_large
    • The media file is too large. Please upload a file smaller than {maximum_size}. The current size is {current_size}.
  • video_file_broken
    • Unable to process video file. Please check if the file is valid and try again.
  • video_file_live
    • Live video streams are not supported. Please provide a URL that is not a live stream.
  • video_resolution_too_low
    • The resolution of the video is too low. Please upload a video with a resolution between {minimum_resolution} and {maximum_resolution}. Current resolution is {current_resolution}.
  • video_resolution_too_high
    • The resolution of the video is too high. Please upload a video with a resolution between {minimum_resolution} and {maximum_resolution}. Current resolution is {current_resolution}.
  • video_resolution_invalid_aspect_ratio
    • The aspect ratio of the video is invalid. Please upload a video with an aspect ratio between 1:1 and {maximum_aspect_ratio}. Current resolution is {current_resolution}.
  • video_duration_too_short
    • The video is too short. Please use a video with a duration of at least {minimum_duration} seconds. Current duration is {current_duration} seconds.
  • video_duration_too_long
    • The video is too long. Please use a video with a duration between {minimum_duration} and {maximum_duration} seconds. Current duration is {current_duration} seconds.
  • video_filesize_too_large
    • The video is too large. Please use a video with a size less than {maximum_size}. The current size is {current_size}.
  • audio_file_broken
    • Unable to process audio file. Please check if the file is valid and try again.
  • audio_duration_too_short
    • The audio is too short. Please use an audio file with a duration of at least {minimum_duration} seconds. Current duration is {current_duration} seconds.
  • audio_duration_too_long
    • The audio is too long. Please use an audio file with a duration between {minimum_duration} and {maximum_duration} seconds. Current duration is {current_duration} seconds.
  • audio_filesize_too_large
    • The audio is too large. Please use an audio file with a size less than {maximum_size}. The current size is {current_size}.
  • audio_format_unsupported
    • The audio format {format} is not supported. Please use one of the following formats: {supported_formats}.
  • asset_transcription_not_found
    • Transcription for asset {asset_id} does not exist.
  • resource_not_exists
    • The requested asset with the identifier {asset_id} does not exist.

For a list of general errors that apply to all endpoints, see the Error codes page.

Retrieve the transcription of an asset

Description: This method retrieves the transcription of a video or audio asset. An asset that has a transcription returns 200 with the current transcription status. The endpoint returns 404 when the asset cannot be found or has no transcription.

The platform generates transcriptions asynchronously. Poll this endpoint to monitor the transcription status.

When the status is ready, the response contains the segmentations you requested that the transcription supports. A transcription does not always support every segmentation, so read the segmentations the response returns rather than assuming every requested one is present.

Function signature and example:

1retrieveTranscription(
2 assetId: string,
3 request?: TwelvelabsApi.AssetsRetrieveTranscriptionRequest,
4 requestOptions?: Assets.RequestOptions
5): core.HttpResponsePromise<TwelvelabsApi.AssetTranscriptionResponse>

Parameters

NameTypeRequiredDescription
assetIdstringYesThe unique identifier of the asset.
requestTwelvelabsApi.AssetsRetrieveTranscriptionRequestNoParameters for retrieving a transcription.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

The TwelvelabsApi.AssetsRetrieveTranscriptionRequest interface has the following properties:

NameTypeRequiredDescription
includeAssetsRetrieveTranscriptionRequestIncludeItem | AssetsRetrieveTranscriptionRequestIncludeItem[]NoSpecifies the transcriptions to return. Each value segments the transcription differently: words returns one entry for each word, sentences returns one entry for each chunk the speech recognition model detects as a sentence, and utterances returns one entry for each speaker turn. Default: words.

Return value

Returns an HttpResponsePromise that resolves to an AssetTranscriptionResponse object containing the transcription status and the transcriptions you requested.

The AssetTranscriptionResponse interface has the following properties:

NameTypeDescription
statusAssetTranscriptionStatusThe current status of the transcription. Values: pending (the platform has not started the transcription), processing (the platform is transcribing the asset), ready (the transcription is available), failed (the platform could not transcribe the asset).
wordsAssetTranscriptionEntry[]One entry for each word. Present when the status is ready, the include parameter lists words, and the transcription supports word-level segmentation.
sentencesAssetTranscriptionEntry[]One entry for each chunk the speech recognition model detects as a sentence. Present when the status is ready, the include parameter lists sentences, and the transcription supports sentence-level segmentation.
utterancesAssetTranscriptionUtterance[]One entry for each speaker turn. Present when the status is ready, the include parameter lists utterances, and the transcription supports speaker-turn segmentation.
errorAssetTranscriptionErrorDetails about the failure. Present when the status is failed.

The AssetTranscriptionEntry interface has the following properties:

NameTypeDescription
startnumberThe start timestamp in seconds.
endnumberThe end timestamp in seconds.
valuestringThe recognized text in this time range.

The AssetTranscriptionUtterance interface has the following properties:

NameTypeDescription
startnumberThe start timestamp in seconds.
endnumberThe end timestamp in seconds.
valuestringThe recognized text in this speaker turn.
speakerstringThe speaker identifier when available.

The AssetTranscriptionError interface has the following properties:

NameTypeDescription
messagestringA human-readable message describing the failure. The exact text is not part of the contract. Do not parse it.

API Reference

Retrieve the transcription of an asset