Imports

The Imports class provides methods to import files from a connected account into the platform as assets and to review past imports. For the end-to-end workflow, see the Data connectors page.

Methods

Import files

Description: This method imports one or more files from the connected provider account into the platform as assets. Video files can be up to 10 GB, audio files up to 4 GB, and images up to 32 MB. For each newly imported file, the platform creates an asset in the processing status and fetches the file asynchronously. If you import a file that was already imported through this account, the platform returns the existing asset with its current status, without fetching the file again. If the earlier fetch had failed, the platform fetches the file again. The response contains one entry per requested file, in request order. Use the action property of each entry to identify which files were newly imported and which were already imported.

Function signature and example:

1importFiles(
2 connectionId: string,
3 request: TwelvelabsApi.ImportFilesRequest,
4 requestOptions?: Imports.RequestOptions
5): Promise<TwelvelabsApi.ImportResult>

Parameters

NameTypeRequiredDescription
connectionIdstringYesThe unique identifier of the connection to import through.
itemsImportFilesRequest
ItemsItem[]
YesThe files to import. Provide an array of one item for a single import, or multiple items for a batch import. A maximum of 100 items can be imported per request. The sourceId field of each item must be unique within a request.
requestOptionsImports.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

The ImportFilesRequestItemsItem object contains the following property:

NameTypeRequiredDescription
sourceIdstringYesThe identifier of the file at the provider. For Google Drive, this is the identifier Google Drive assigns to the file.

Return value

Returns an ImportResult object. The ImportResult object contains the following properties:

NameTypeDescription
idstringThe unique identifier of the import created for this request.
hasFailuresbooleanWhether at least one item was rejected before an asset was created. When true, inspect the error object of each item to identify the rejected ones. An item the platform skipped as a duplicate is not a failure.
itemsImportItem[]One entry per requested file, in request order, with its action value and the current status of its asset.

The ImportItem object contains the following properties:

NameTypeDescription
sourceIdstringThe identifier of the file at the provider. For Google Drive, this is the identifier Google Drive assigns to the file.
actionImportItemActionThe action taken for this file. Values: created, skipped, retried, rejected. The platform sets this value while processing the request, and the value does not change afterward. The importFiles method always returns this property. The retrieveImport method omits it for imports from before this property existed. Treat an absent value as unknown rather than as a specific action. The skipped and retried values both mean the file was already imported through this account: for the skipped action, the platform returns the existing asset; for the retried action, the earlier fetch had failed, so the platform fetches the file again. See The import object for the meaning of each value.
assetIdstringThe unique identifier of the asset for this file. When the action property is created, this identifies a new asset; when it is skipped or retried, this identifies the asset from the earlier import of the same file. Absent when the item was rejected before an asset was created.
statusImportItemStatusThe status of the asset. Values: processing, ready, failed. Absent when the item was rejected before an asset was created, in which case an error object is present.
errorImportItemErrorDetails of the rejection. Present when the item was rejected before an asset was created, in which case the status field is absent.

The ImportItemError object contains the following properties:

NameTypeDescription
codestringA string representing the code associated with the error. For the possible values, see the Error codes page.
messagestringA human-readable string describing the error, intended to be suitable for display in a user interface.

API Reference

Import files.

List imports

Description: This method returns a list of the imports for the specified connection. The platform returns the imports sorted by creation date, with the newest at the top of the list. Each import in the list is a summary and does not include the per-file details. To see them, use the retrieveImport method.

Function signature and example:

1listImports(
2 connectionId: string,
3 request?: TwelvelabsApi.ListImportsRequest,
4 requestOptions?: Imports.RequestOptions
5): Promise<TwelvelabsApi.ListImportsResponse>

Parameters

NameTypeRequiredDescription
connectionIdstringYesThe unique identifier of the connection to list imports for.
pagenumberNoA number that identifies the page to retrieve. Default: 1.
pageLimitnumberNoThe number of items to return on each page. Default: 10. Max: 50.
requestOptionsImports.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

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

NameTypeDescription
dataImport[]An array containing the imports.
pageInfoPageInfoAn object that provides information about pagination. Contains the page, limitPerPage, totalPage, and totalResults fields.

The Import object contains the following properties:

NameTypeDescription
idstringThe unique identifier of the import.
connectionIdstringThe unique identifier of the connection the files were imported through.
providerImportProviderThe data connector provider. Values: google_drive.
customIdstringThe label you supplied when you authorized the connection, copied when the import was created. Present only when you supplied one.
itemCountnumberThe number of files requested in this import. If an imported asset is later deleted, it is omitted from the items array returned by the retrieveImport method, so the items array can contain fewer entries than itemCount.
createdAtDateThe date and time, in the RFC 3339 format (“YYYY-MM-DDTHH:mm:ssZ”), when the import was created.

API Reference

List imports.

Retrieve an import

Description: This method retrieves a single import. For each file, the response includes the action property, which indicates the outcome of the import operation, and the status property, which reflects the current status of the asset each time you retrieve the import.

Function signature and example:

1retrieveImport(
2 connectionId: string,
3 importId: string,
4 requestOptions?: Imports.RequestOptions
5): Promise<TwelvelabsApi.ImportDetail>

Parameters

NameTypeRequiredDescription
connectionIdstringYesThe unique identifier of the connection to retrieve the import from.
importIdstringYesThe unique identifier of the import to retrieve.
requestOptionsImports.
RequestOptions
NoPer-call SDK settings such as timeout, retries, and headers. For all fields, see Request options.

Return value

Returns an ImportDetail object. The ImportDetail object contains all the properties of the Import object (see List imports), plus the following:

NameTypeDescription
itemsImportItem[]One entry per requested file, in request order, with its action value and the current status of its asset. For the properties of each ImportItem object, see Import files.

API Reference

Retrieve an import.