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. Each newly imported file creates an asset in the processing status and is downloaded asynchronously. If you import a file that was already imported through this account, the platform returns the existing asset with its current status, which may be ready, without downloading the file again. The response returns one entry per requested file, in request order.

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. Each sourceId 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 Drive file identifier.

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 any item was rejected before an asset was created. When true, inspect the error object of each item to identify the rejected ones.
itemsImportItem[]One entry per requested file, in request order.

The ImportItem object contains the following properties:

NameTypeDescription
sourceIdstringThe identifier of the file at the provider. For Google Drive, this is the Drive file identifier.
assetIdstringThe unique identifier of the asset created for this 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. See the Error codes page for details. Possible values include source_unavailable, source_not_authorized, unsupported_media_type, video_filesize_too_large, audio_filesize_too_large, and media_filesize_too_large.
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 that omits the items array. To see the status of each file, 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 creating the connection, copied when the import was created. Present only when a value is set for the customId field.
itemCountnumberThe number of files requested in this import. If an imported asset is later deleted, it is omitted from the items array in the Retrieve an import response, 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, including the current status of each asset in 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 the import belongs to.
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 imported file, with the current status of its asset. For the properties of each ImportItem object, see Import files.

API Reference

Retrieve an import.