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

# Upload File

> Upload a file to the cache for use as an attachment or inline image across multiple emails.

Upload files to Unosend's file cache and reuse them across multiple email sends without re-uploading. Cached files are referenced by their `file_cache_key` in subsequent API calls.

<ParamField query="name" type="string" required>
  The filename including extension (e.g., `logo.png`, `invoice.pdf`).
</ParamField>

<ParamField body="file" type="binary" required>
  The file content as multipart/form-data.
</ParamField>

### Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.unosend.co/v1/files?name=logo.png" \
    -H "Authorization: Bearer un_xxxxxxxxxx" \
    -F "file=@/path/to/logo.png"
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append('file', fileBlob, 'logo.png');

  await fetch('https://api.unosend.co/v1/files?name=logo.png', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer un_xxxxxxxxxx'
    },
    body: formData
  });
  ```

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

  with open('logo.png', 'rb') as f:
      requests.post(
          'https://api.unosend.co/v1/files?name=logo.png',
          headers={'Authorization': 'Bearer un_xxxxxxxxxx'},
          files={'file': ('logo.png', f, 'image/png')}
      )
  ```
</CodeGroup>

### Response

```json 200 theme={null}
{
  "message": "OK",
  "data": {
    "file_cache_key": "fc_1a2b3c4d5e6f",
    "name": "logo.png",
    "size": 24576,
    "content_type": "image/png",
    "created_at": "2026-01-15T10:30:00.000Z"
  }
}
```

## Using Cached Files in Emails

Reference the `file_cache_key` when sending emails:

```json theme={null}
{
  "from": {"address": "hello@yourdomain.com", "name": "Your App"},
  "to": [{"email_address": {"address": "user@example.com"}}],
  "subject": "Your Invoice",
  "htmlbody": "<p>Please find your invoice attached.</p>",
  "attachments": [
    {
      "file_cache_key": "fc_1a2b3c4d5e6f",
      "name": "invoice.pdf"
    }
  ]
}
```

### Inline Images

Use `cid` to embed images inline in HTML:

```json theme={null}
{
  "htmlbody": "<img src='cid:logo' />",
  "inline_images": [
    {
      "file_cache_key": "fc_1a2b3c4d5e6f",
      "cid": "logo"
    }
  ]
}
```

<Note>
  * Maximum file size: **10 MB**
  * Total email size (headers + body + attachments): **15 MB**
  * Cached files are stored for **30 days** from last use
</Note>
