# Download

## Get Status

`client.assets.download.getStatus(stringjobID, DownloadGetStatusParamsquery?, RequestOptionsoptions?): DownloadGetStatusResponse`

**get** `/assets/download/{jobId}`

Retrieve the status and the url of a batch download assets request

### Parameters

- `jobID: string`

- `query: DownloadGetStatusParams`

  - `projectId?: string`

    The projectId used for ownership resource management. Either to assert ownership or to set the owner of the resource(s)

### Returns

- `DownloadGetStatusResponse`

  - `jobId: string`

    The job id associated with the download request

  - `jobStatus: string`

    The current job status

  - `downloadUrl?: string`

    The download url

### Example

```typescript
import Scenario from '@scenario-labs/sdk';

const client = new Scenario({
  apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted
});

const response = await client.assets.download.getStatus('jobId');

console.log(response.jobId);
```

#### Response

```json
{
  "jobId": "jobId",
  "jobStatus": "jobStatus",
  "downloadUrl": "downloadUrl"
}
```

## Request

`client.assets.download.request(stringassetID, DownloadRequestParamsparams, RequestOptionsoptions?): DownloadRequestResponse`

**post** `/assets/{assetId}/download`

Request a link to download the given `assetId` in the given `targetFormat`

### Parameters

- `assetID: string`

- `params: DownloadRequestParams`

  - `projectId?: string`

    Query param: The projectId used for ownership resource management. Either to assert ownership or to set the owner of the resource(s)

  - `targetFormat?: "gif" | "heif" | "jpeg" | 12 more`

    Body param: The format to download the asset in. If omitted, the original file is returned. Audio and video assets only accept their stored format.

    - `"gif"`

    - `"heif"`

    - `"jpeg"`

    - `"jpg"`

    - `"png"`

    - `"svg"`

    - `"webp"`

    - `"avif"`

    - `"tif"`

    - `"tiff"`

    - `"glb"`

    - `"fbx"`

    - `"obj"`

    - `"mp3"`

    - `"mp4"`

### Returns

- `DownloadRequestResponse`

  - `url: string`

    The signed URL to download the asset in the requested format, or its original file when `targetFormat` is omitted

  - `mimeType?: string`

    Mime type of the file served at `url`

### Example

```typescript
import Scenario from '@scenario-labs/sdk';

const client = new Scenario({
  apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted
});

const response = await client.assets.download.request('assetId');

console.log(response.url);
```

#### Response

```json
{
  "url": "url",
  "mimeType": "mimeType"
}
```

## Request Batch

`client.assets.download.requestBatch(DownloadRequestBatchParamsparams, RequestOptionsoptions?): DownloadRequestBatchResponse`

**post** `/assets/download`

Request a link to batch download assets (batch limited to 1000 assets)

### Parameters

- `params: DownloadRequestBatchParams`

  - `options: Options`

    Body param

    - `fileNameTemplate: string`

      A file naming convention as a string with the following available parameters:
      <seed> (seed used to generate the asset)
      <num> (index of the asset in the inference)
      <prompt> (slug of the inference prompt: lower-cased, function words removed, max 8 words, joined with `_`)
      <generator> (name of the generator)
      <id> (asset id)
      <description> (slug of the asset description or caption: lower-cased, function words removed, max 8 words, joined with `_`. Does not fall back to the prompt.)
      A `/` in the template creates a subdirectory (e.g. `<prompt>/<id>` → `cat_dancing/asset_….png`).
      Later occurrences of the same dynamic token are dropped together with their preceding separator.
      The filename, including the extension, is capped at 128 characters; each template directory segment is capped at 64. Prompt and description are truncated first.
      Example: "<description>-<id>"

    - `archiveName?: string`

      Name of the downloaded zip file, without the `.zip` extension.
      Defaults to `<YYYYMMDD>-export`.

    - `flat?: boolean`

      Flag to prevent grouping assets in directories and store them flat

    - `preferOriginal?: boolean`

      Flag to archive the file as it was originally uploaded, for assets whose
      upload was re-encoded on creation (e.g. a .mov stored as mp4). Each
      archived file is named with the extension of the format it contains.

      Assets that have no preserved original (every image, and anything uploaded
      in a format we serve as-is) are archived unchanged, so this is a preference
      and never fails a download.

  - `query: Query`

    Body param

    - `assetIds: Array<string>`

      Every individual assets specified will be included in the archive

    - `inferenceIds: Array<string>`

      All assets issued from the provided inference ids will be included in the archive

    - `modelIds: Array<string>`

      All assets issued from the provided model ids will be included in the archive

  - `dryRun?: "true" | "api"`

    Query param: Estimate the operation instead of running it: the call returns a 269 response carrying the creative units cost. `api` estimates at the API tier.

    - `"true"`

    - `"api"`

  - `projectId?: string`

    Query param: The projectId used for ownership resource management. Either to assert ownership or to set the owner of the resource(s)

### Returns

- `DownloadRequestBatchResponse`

  - `jobId: string`

    The job id associated with the download request

### Example

```typescript
import Scenario from '@scenario-labs/sdk';

const client = new Scenario({
  apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted
});

const response = await client.assets.download.requestBatch({
  options: { fileNameTemplate: 'fileNameTemplate' },
  query: {
    assetIds: ['string'],
    inferenceIds: ['string'],
    modelIds: ['string'],
  },
});

console.log(response.jobId);
```

#### Response

```json
{
  "jobId": "jobId"
}
```

## Domain Types

### Download Get Status Response

- `DownloadGetStatusResponse`

  - `jobId: string`

    The job id associated with the download request

  - `jobStatus: string`

    The current job status

  - `downloadUrl?: string`

    The download url

### Download Request Response

- `DownloadRequestResponse`

  - `url: string`

    The signed URL to download the asset in the requested format, or its original file when `targetFormat` is omitted

  - `mimeType?: string`

    Mime type of the file served at `url`

### Download Request Batch Response

- `DownloadRequestBatchResponse`

  - `jobId: string`

    The job id associated with the download request
