Direct uploads

The Assets interface provides methods to upload your media files to the platform. This method creates an asset that you can use in different workflows.

Workflow

1

Upload your file using the assets.create method. You receive the asset ID in the response.

2

Monitor the indexing status using the assets.retrieve method until it’s ready.

3

What you do next depends on your use case:

  • For creating embeddings (videos, audio, images): Use the asset ID with the Embed API v2.
  • For entity search (images): Use the asset ID to create entities.
  • For search and analysis (videos): Index your asset using the asset ID.

Methods

Create an asset

Description: This method creates an asset by uploading a file to the platform. Assets are media files that you can use in downstream workflows, including indexing, analyzing video content, and creating entities.

Supported content: Video, audio, and images.

Upload methods:

  • Local file: Set the method parameter to direct and use the file parameter to specify the file.
  • Publicly accessible URL: Set the method parameter to url and use the url parameter to specify the URL of your file.

File size: 200MB maximum for local file uploads, 4GB maximum for URL uploads.

Additional requirements depend on your workflow:

Function signature and example:

1create(
2 request: TwelvelabsApi.AssetsCreateRequest,
3 requestOptions?: Assets.RequestOptions
4): core.HttpResponsePromise<TwelvelabsApi.Asset>

Parameters:

NameTypeRequiredDescription
methodTwelvelabsApi.AssetsCreateRequestMethodYesSpecifies the upload method for the asset. Use direct to upload a local file or url for a publicly accessible URL.
fileFile | fs.ReadStream | Blob | undefinedNoThe local file to upload. This parameter is required when method is set to direct.
urlstringNoThe publicly accessible URL of a media file to upload. This parameter is required when method is set to url.

URL uploads have a maximum limit of 4GB.
filenamestringNoThe optional filename of the asset. If not provided, the platform determines the filename from the file or URL.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to an Asset object representing the created asset.

The Asset interface contains the following properties:

NameTypeDescription
idstringThe unique identifier of the asset.
methodTwelvelabsApi.AssetMethodIndicates how you uploaded the asset. Values: direct (uploaded from your local file system), url (uploaded from a publicly accessible URL).
statusTwelvelabsApi.AssetStatusIndicates the current status of the asset. Values: waiting (the platform is preparing to process the upload), processing (the platform is processing the uploaded file), ready (the asset is ready to use).
filenamestringThe name of the file used to create the asset.
fileTypestringThe MIME type of the asset file.
urlstringThe URL to access your asset. Use this URL to preview or download the asset.

This URL expires after the time specified in the urlExpiresAt field. After expiration, you must retrieve the asset again to obtain a new URL.
urlExpiresAtDateThe date and time, in RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the URL expires. After this time, the URL in the url field becomes invalid. Retrieve the asset again to obtain a new URL.
createdAtDateThe date and time, in RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the asset was created.

API Reference: Create an asset

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.Asset>>

Parameters:

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.
requestOptionsAssets.RequestOptionsNoRequest-specific configuration.

Return value: Returns a Promise that resolves to a Page<Asset> object that allows you to iterate through the paginated asset results. For details about the Asset interface see the Create an asset section above.

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.

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.Asset>

Parameters:

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

Return value: Returns a Promise that resolves to an Asset object containing details about the specified asset. For details about the Asset interface see the Create an asset section above.

API Reference: Retrieve an asset

Delete an asset

Description: This method deletes the specified asset. This action cannot be undone.

Function signature and example:

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

Parameters:

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

Return value: Returns a Promise that resolves to void.

API Reference: Delete asset