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

# Upload Asset

> Upload a new media file to the project

Upload a new asset to the project. This endpoint accepts multipart/form-data for file uploads.

<Note>
  This endpoint uses `multipart/form-data`, not JSON. The file is sent as binary data.
</Note>

## Path Parameters

<ParamField path="organizationId" type="string" required>
  The unique identifier of the organization
</ParamField>

<ParamField path="projectId" type="string" required>
  The unique identifier of the project
</ParamField>

## Request Body

<ParamField body="file" type="file" required>
  The file to upload. Supported formats include images (JPEG, PNG, GIF, WebP, AVIF), videos (MP4, MOV, WebM), and documents (PDF).
</ParamField>

<ParamField body="metadata" type="string">
  JSON string containing metadata object. Will be parsed and stored with the asset.

  ```json theme={null}
  {
    "alt": "Hero image description",
    "caption": "Photo by John Doe"
  }
  ```
</ParamField>

<ParamField body="tags" type="string">
  JSON string array of tag IDs to associate with the asset.

  ```json theme={null}
  ["hero", "homepage", "featured"]
  ```
</ParamField>

## Response

Returns the created Asset object.

<ResponseField name="data" type="Asset">
  The newly created asset object with generated ID and CDN URL
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets" \
    -H "Authorization: Bearer YOUR_JWT" \
    -F "file=@/path/to/image.jpg" \
    -F 'metadata={"alt": "Product hero image"}' \
    -F 'tags=["hero", "product"]'
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append('file', fileInput.files[0]);
  formData.append('metadata', JSON.stringify({ alt: 'Product hero image' }));
  formData.append('tags', JSON.stringify(['hero', 'product']));

  const response = await fetch(
    'https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/assets',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_JWT'
      },
      body: formData
    }
  );
  const data = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "data": {
      "id": "asset789",
      "name": "image.jpg",
      "description": null,
      "type": "image/jpeg",
      "status": "active",
      "url": "https://cdn.metabind.ai/org123/proj456/assets/asset789/image.jpg",
      "size": 1536000,
      "metadata": {
        "width": 1920,
        "height": 1080,
        "format": "jpeg",
        "alt": "Product hero image"
      },
      "tags": ["hero", "product"],
      "createdAt": "2024-03-21T14:30:00Z",
      "updatedAt": "2024-03-21T14:30:00Z"
    }
  }
  ```

  ```json 400 theme={null}
  {
    "error": {
      "code": "BAD_REQUEST",
      "message": "File upload error: File type not supported"
    }
  }
  ```
</ResponseExample>
