Direct uploads
The Assets class provides methods to upload your media files to the platform. This method creates an asset that you can use in different workflows.
Workflow
Upload your file using the assets.create method. You receive the asset ID in the response.
For URL uploads larger than 200 MB, check the asset status using the assets.retrieve method until status is ready before proceeding.
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
methodparameter todirectand use thefileparameter to specify the file. - Publicly accessible URL: Set the
methodparameter tourland use theurlparameter to specify the URL of your file.
Upload limits:
- Video and audio, local files: Up to 200 MB
- Video and audio, public URLs: Up to 4 GB
- Images: Up to 5 MB
Additional requirements depend on your workflow:
- Search: Marengo requirements
- Video analysis: Pegasus requirements
- Entity search: Marengo image requirements
- Create embeddings: Marengo requirements
Note
This method is rate-limited. For details, see the Rate limits page.
Function signature and example:
Parameters
The TwelvelabsApi.AssetsCreateRequest interface has the following properties:
Return value
Returns an HttpResponsePromise that resolves to a TwelvelabsApi.Asset object representing the created asset.
The TwelvelabsApi.Asset interface contains the following properties:
API Reference
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:
Parameters
The TwelvelabsApi.AssetsListRequest interface has the following properties:
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:
API Reference
Retrieve an asset
Description: This method retrieves details about the specified asset.
Function signature and example:
Parameters
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:
The TwelvelabsApi.AssetHls interface contains the following properties:
The TwelvelabsApi.AssetThumbnail interface contains the following properties:
API Reference
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:
Parameters
The TwelvelabsApi.AssetsDeleteRequest interface has the following properties:
Return value
Returns an HttpResponsePromise that resolves to void.
API Reference
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:
Parameters
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
nulldeletes 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:
Parameters
The TwelvelabsApi.AssetsUpdateUserMetadataRequest interface has the following properties:
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 (
"") ornullis 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:
Parameters
The TwelvelabsApi.AssetsReplaceUserMetadataRequest interface has the following properties:
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 usemultipart/form-data.
- The content type
multipart_boundary_missing- Multipart boundary is missing. Please provide the boundary in the
Content-Typeheader.
- Multipart boundary is missing. Please provide the boundary in the
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)
- (Returns a validator-generated message, for example:
parameter_not_provided- The
fileparameter is required but was not provided.fileis required whenmethodisdirect. - The
urlparameter is required but was not provided.urlis required whenmethodisurl.
- The
parameter_invalid- The
methodparameter is invalid. To upload in parts, use the/assets/multipart-uploadsendpoint. - The
fileparameter is invalid. Unable to process the uploaded file. Please try uploading again. - The
fileparameter is invalid. Unsupported asset type:{asset_type}. - The
imageparameter is invalid. Image dimensions{current_dimensions}are below the minimum{minimum_dimensions}. - The
imageparameter is invalid. Invalid image file. Please check the format and dimensions.
- The
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.
- The file at the provided URL is not a supported media format. Detected format:
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.
- Cannot access the media URL
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}.
- The media file is too large. Please upload a file smaller than
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}.
- The resolution of the video is too low. Please upload a video with a resolution between
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}.
- The resolution of the video is too high. Please upload a video with a resolution between
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}.
- The aspect ratio of the video is invalid. Please upload a video with an aspect ratio between 1:1 and
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.
- The video is too short. Please use a video with a duration of at least
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.
- The video is too long. Please use a video with a duration between
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}.
- The video is too large. Please use a video with a size less than
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.
- The audio is too short. Please use an audio file with a duration of at least
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.
- The audio is too long. Please use an audio file with a duration between
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}.
- The audio is too large. Please use an audio file with a size less than
audio_format_unsupported- The audio format
{format}is not supported. Please use one of the following formats:{supported_formats}.
- The audio format
For a list of general errors that apply to all endpoints, see the Error codes page.