> ## 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 Video

> Download the original video file for a given video in your Private Video Library.

<Info>
  **Product**: Visual Search
  **Use case**: Upload videos and images, auto-index them, then search by natural language, image, or transcript phrase
  **Host**: `https://api.memories.ai/serve/api/v1`
  **Auth**: `Authorization: sk-mavi-...` (no `Bearer` prefix)
</Info>

Download the original video file for a given video in your Private Video Library. Returns a binary stream on success.

## Prerequisites

* You have [created a memories.ai API key](/visual-search/create-your-key).

## Endpoint

POST /serve/api/v1/download

## Authentication

Include your API key in the Authorization header.

```
Authorization: sk-mavi-...
```

## Request

**Content-Type:** `application/json`

```json theme={null}
{
  "video_no": "VI625239098370850816"
}
```

## Request Parameters

<ParamField body="video_no" type="string" required>
  The video identifier to download.
</ParamField>

## Python Example

```python theme={null}
import requests

headers = {"Authorization": "sk-mavi-..."}
payload = {
    "video_no": "VI625239098370850816"
}
url = "https://api.memories.ai/serve/api/v1/download"

# stream=True enables chunked download
resp = requests.post(url, json=payload, headers=headers, stream=True)
print("Status:", resp.status_code)

content_type = resp.headers.get("Content-Type", "")

if "application/json" in content_type.lower(): 
    # JSON means the download did not succeed; inspect the error payload 
    print(resp.json())
else: 
    # Binary stream (video) 
    with open("video.mp4", "wb") as f: 
        for chunk in resp.iter_content(chunk_size=8192): 
            if chunk: 
                f.write(chunk) 
    print("Download complete")
```

## cURL Example

```bash theme={null}
curl -X POST "https://api.memories.ai/serve/api/v1/download" \
  -H "Authorization: sk-mavi-..." \
  -H "Content-Type: application/json" \
  -d '{"video_no":"VI625239098370850816"}' \
  --output video.mp4
```

## Successful Response

On success, the server returns the video file as a binary stream:

* **Status:** 200
* **Content-Type:** `application/octet-stream`
* **Body:** Binary content of the video (mp4 — the first bytes are an `ftyp` ISO-BMFF box)

<Note>
  The download uses HTTP chunked transfer encoding, so **`Content-Length` is typically absent**. Don't use it for progress reporting; rely on `iter_content` chunk counts instead.
</Note>

## Error Response (JSON)

If the download cannot be fulfilled, a JSON payload is returned instead — same HTTP status (`200`) but `Content-Type: application/json`. The Python and cURL examples above already branch on the response content type.

Unknown or wrong-namespace `video_no`:

```json theme={null}
{
    "code": "0001",
    "msg": "download video error",
    "data": null,
    "success": false,
    "failed": true
}
```

Missing `video_no` in the request body:

```json theme={null}
{
    "code": "0001",
    "msg": "The video number cannot be empty！",
    "data": null,
    "success": false,
    "failed": true
}
```

<Note>
  Branch on `Content-Type` (or check `success: false`) rather than parsing `msg` text — the message strings are short, sometimes use full-width punctuation, and aren't a stable contract.
</Note>

## Tips

* **Stream downloads:** Always use `stream=True` (Python) to avoid loading the entire file into memory.


## OpenAPI

````yaml POST /serve/api/v1/download
openapi: 3.1.0
info:
  title: Memories Platform API (Docs Mapping)
  version: v1
  description: OpenAPI mapping used by Mintlify Try it for the platform docs.
servers:
  - url: https://api.memories.ai
security:
  - ApiKeyAuth: []
paths:
  /serve/api/v1/download:
    post:
      summary: Download Video
      operationId: download_video
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DownloadVideoRequest'
      responses:
        '200':
          $ref: '#/components/responses/BinaryDownloadResponse'
components:
  schemas:
    DownloadVideoRequest:
      type: object
      properties:
        video_no:
          type: string
          example: VI625239098370850816
      required:
        - video_no
    GenericJsonResponse:
      type: object
      properties:
        code:
          type:
            - string
            - integer
          example: '0000'
        msg:
          type: string
          example: success
        data:
          oneOf:
            - type: object
              additionalProperties: true
            - type: array
              items:
                type: object
                additionalProperties: true
            - type: string
            - type: 'null'
        success:
          type: boolean
          example: true
        failed:
          type: boolean
          example: false
      additionalProperties: true
  responses:
    BinaryDownloadResponse:
      description: Binary video stream or JSON error response
      content:
        application/octet-stream:
          schema:
            type: string
            format: binary
        application/json:
          schema:
            $ref: '#/components/schemas/GenericJsonResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````