> ## Documentation Index
> Fetch the complete documentation index at: https://api-tools.memories.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Download Asset

> Download an asset file by its ID.

<Info>
  **Product**: Visual Intelligence — Asset Management
  **Use case**: Upload, manage, and download video/image assets used by other Visual Intelligence APIs
  **Host**: `https://mavi-backend.memories.ai/serve/api/v2`
  **Auth**: `Authorization: sk-mavi-...` (no `Bearer` prefix)
</Info>

Download an asset by its `asset_id`. The response body is a **binary file stream** — not JSON. On error, the response is JSON.

<Note>
  **Pricing:** \$0.12 / GB downloaded
</Note>

### Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://mavi-backend.memories.ai/serve/api/v2/re_657739295220518912/download \
    --header 'Authorization: sk-mavi-...' \
    --remote-name \
    --remote-header-name
  ```

  ```python Python theme={null}
  import requests, re

  url = "https://mavi-backend.memories.ai/serve/api/v2/re_657739295220518912/download"
  headers = {"Authorization": "sk-mavi-..."}

  response = requests.get(url, headers=headers, stream=True)

  if not response.ok:
      raise Exception(response.json().get("msg", "Download failed"))

  cd = response.headers.get("Content-Disposition", "")
  m = re.search(r'filename[^;=\n]*=(([\'"]).*?\2|[^;\n]*)', cd)
  filename = m.group(1).strip("'\"") if m else "download"

  with open(filename, "wb") as f:
      for chunk in response.iter_content(chunk_size=8192):
          if chunk:
              f.write(chunk)

  print(f"Saved to: {filename}")
  ```

  ```javascript fetch theme={null}
  const assetId = "re_657739295220518912";
  const response = await fetch(
    `https://mavi-backend.memories.ai/serve/api/v2/${assetId}/download`,
    { headers: { Authorization: "sk-mavi-..." } }
  );

  if (!response.ok) {
    const err = await response.json();
    throw new Error(err.msg || "Download failed");
  }

  const cd = response.headers.get("Content-Disposition") ?? "";
  const m = cd.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
  const filename = m ? m[1].replace(/['"]/g, "") : "download";

  const blob = await response.blob();
  const a = Object.assign(document.createElement("a"), {
    href: URL.createObjectURL(blob),
    download: filename,
  });
  a.click();
  URL.revokeObjectURL(a.href);
  ```
</CodeGroup>

### Path Parameters

| Parameter  | Type   | Required | Description                 |
| ---------- | ------ | -------- | --------------------------- |
| `asset_id` | string | Yes      | ID of the asset to download |

### Response

**Success (200):** Binary file stream. Response headers include:

* `Content-Type` — MIME type (e.g. `video/mp4`)
* `Content-Disposition: attachment; filename="..."` — original filename
* `Content-Length` — file size in bytes

**Error:** JSON with `code`, `msg`, `success: false`, `failed: true`.

### Notes

* Use `stream=True` (Python) or `responseType: 'stream'` (axios) to avoid loading the entire file into memory.
* The original filename is in the `Content-Disposition` header.
* This is irreversible — once deleted an asset cannot be downloaded.
