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

# Get Upload Signed URL

> Generate a pre-signed URL for direct file upload

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

This endpoint generates a pre-signed URL that allows you to upload files directly to cloud storage.

<Note>
  **Pricing:**

  * API calls are free
  * Storage fee: \$0.001/1GB per day
</Note>

### Code Examples

<CodeGroup>
  ```javascript fetch theme={null}
  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  const response = await fetch(`${BASE_URL}/upload/signed-url`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': API_KEY
    },
    body: JSON.stringify({
      original_filename: 'video.mp4'
    })
  });

  const data = await response.json();
  console.log(data);

  // Then upload the file using the signed URL
  const formData = new FormData();
  formData.append('file', file);

  await fetch(data.data.signed_url, {
    method: 'POST',
    body: formData
  });
  ```

  ```javascript axios theme={null}
  import axios from 'axios';

  const BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2";
  const API_KEY = "sk-mavi-...";

  // Step 1: Get signed URL
  const { data } = await axios.post(`${BASE_URL}/upload/signed-url`, {
    original_filename: 'video.mp4'
  }, {
    headers: {
      'Authorization': API_KEY
    }
  });

  // Step 2: Upload file using signed URL
  const formData = new FormData();
  formData.append('file', file);

  await axios.post(data.data.signed_url, formData);
  ```

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

  BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2"
  API_KEY = "sk-mavi-..."
  HEADERS = {
      "Authorization": f"{API_KEY}"
  }

  def upload_signed_url(original_filename):
      url = f"{BASE_URL}/upload/signed-url"
      data = {"original_filename": original_filename}
      response = requests.post(url, json=data, headers=HEADERS)
      return response.json()

  def upload_by_signed_url(signed_url_info, file_path):
      upload_url = signed_url_info['data']["signed_url"]
      fields = signed_url_info.get("fields", {})
      with open(file_path, "rb") as f:
          files = {"file": (file_path, f)}
          data = fields
          resp = requests.post(upload_url, data=data, files=files)
      return resp.status_code, resp.text

  # Usage example
  signed_url_info = upload_signed_url("video.mp4")
  status, response = upload_by_signed_url(signed_url_info, "path/to/video.mp4")
  print(f"Upload status: {status}")
  ```
</CodeGroup>

### Request Body

| Field              | Type   | Required | Description                                              |
| ------------------ | ------ | -------- | -------------------------------------------------------- |
| original\_filename | string | Yes      | The original filename with extension (e.g., "video.mp4") |

### Response

Returns a signed URL and associated metadata for file upload.

<ResponseExample>
  ```json theme={null}
  {
    "code": 200,
    "msg": "success",
    "data": {
      "asset_id": "re_660736410386149376",
      "signed_url": "https://storage.googleapis.com/...",
      "expires_in": 93600
    },
    "success": true,
    "failed": false
  }
  ```
</ResponseExample>

### Response Parameters

| Parameter        | Type    | Description                                                          |
| ---------------- | ------- | -------------------------------------------------------------------- |
| code             | string  | Response code indicating the result status                           |
| msg              | string  | Response message describing the operation result                     |
| data             | object  | Response data object containing the signed URL and asset information |
| data.asset\_id   | string  | Unique identifier of the asset that will be created after upload     |
| data.signed\_url | string  | Pre-signed URL for direct file upload to cloud storage               |
| data.expires\_in | integer | Validity period of the signed URL in seconds                         |
| success          | boolean | Indicates whether the operation was successful                       |
| failed           | boolean | Indicates whether the operation failed                               |

### Notes

* The signed URL expires after the time specified in `expires_in` (in seconds)
* Upload the file before the URL expires to avoid upload failures
* The `expires_in` value indicates how long the signed URL remains valid from the time it was generated


## OpenAPI

````yaml POST /upload/signed-url
openapi: 3.1.0
info:
  title: MAVI API Reference
  description: REST APIs for memory management, search, and entity operations
  version: v1.0.1
servers:
  - url: https://mavi-backend.memories.ai/serve/api/v2
security:
  - ApiKeyAuth: []
paths:
  /upload/signed-url:
    post:
      summary: Get Upload Signed URL
      operationId: upload_signed_url
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                original_filename:
                  type: string
                  description: The original filename with extension
                  example: video.mp4
              required:
                - original_filename
      responses:
        '200':
          description: Signed URL generated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: 200
                    description: Response code indicating the result status
                  msg:
                    type: string
                    example: success
                    description: Response message describing the operation result
                  data:
                    type: object
                    properties:
                      asset_id:
                        type: string
                        example: re_660736410386149376
                        description: >-
                          Unique identifier of the asset that will be created
                          after upload
                      signed_url:
                        type: string
                        example: https://storage.googleapis.com/...
                        description: Pre-signed URL for direct file upload to cloud storage
                      expires_in:
                        type: integer
                        example: 93600
                        description: Validity period of the signed URL in seconds
                    description: >-
                      Response data object containing the signed URL and asset
                      information
                  success:
                    type: boolean
                    example: true
                    description: Indicates whether the operation was successful
                  failed:
                    type: boolean
                    example: false
                    description: Indicates whether the operation failed
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````