> ## 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 Component Asset

> Upload an asset to a component

## Path Parameters

<ParamField path="organizationId" type="string" required>
  Organization ID
</ParamField>

<ParamField path="projectId" type="string" required>
  Project ID
</ParamField>

<ParamField path="componentId" type="string" required>
  Component ID
</ParamField>

## Request

Content-Type: `multipart/form-data`

<ParamField body="file" type="file" required>
  Asset file to upload
</ParamField>

<ParamField body="metadata" type="string">
  JSON string with asset metadata
</ParamField>

<ParamField body="tags" type="string[]">
  Array of tags for categorization
</ParamField>

## Response

Returns the created Asset object.

```json theme={null}
{
  "id": "asset123",
  "name": "logo-2x.png",
  "type": "image/png",
  "url": "https://cdn.metabind.ai/org123/proj456/components/c123/latest/assets/asset123/logo-2x.png",
  "size": 24576,
  "status": "active",
  "metadata": {
    "width": 200,
    "height": 100,
    "format": "png"
  },
  "tags": ["logo", "brand"],
  "createdAt": "2024-03-20T10:00:00Z",
  "updatedAt": "2024-03-20T10:00:00Z"
}
```

## Error Responses

### File Too Large

```json theme={null}
{
  "error": {
    "code": "FILE_TOO_LARGE",
    "message": "File exceeds maximum size limit",
    "details": {
      "maxSize": "10MB",
      "providedSize": "15MB"
    }
  }
}
```

### Unsupported File Type

```json theme={null}
{
  "error": {
    "code": "UNSUPPORTED_FILE_TYPE",
    "message": "File type not supported",
    "details": {
      "type": "application/exe",
      "supportedTypes": ["image/*", "font/*", "application/json"]
    }
  }
}
```

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/projects/proj456/components/c123/assets" \
    -H "Authorization: Bearer YOUR_JWT" \
    -F "file=@logo-2x.png" \
    -F "tags=[\"logo\", \"brand\"]"
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append('file', fileInput.files[0]);
  formData.append('tags', JSON.stringify(['logo', 'brand']));

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

  const asset = await response.json();
  console.log(`Uploaded asset: ${asset.url}`);
  ```
</CodeGroup>
