# Upload a file to attach to an email

Source: https://docs.vlayers.ai/reference/messages/upload-attachment

`POST /v1/attachments` · scope `messages:send`

Send the file itself as the request body (any content type), with its name in the `x-file-name` header (URL-encoded). The answer's `uploadId` stands for the kept file for one hour: pass it as `{ "uploadId" }` in `attachments` when you send, reply, forward or write a draft. A program or script is refused at once, and a file over the workspace's limit is refused with 413. Nothing is sent by uploading.

Requires an API key with the `messages:send` scope.

## Request

cURL:

```bash
curl -X POST https://api.vlayers.ai/v1/attachments \
  -H "Authorization: Bearer $VOICELAYER_API_KEY"
```

TypeScript:

```ts
import { VoiceLayer } from '@voicelayer/api';

const voicelayer = new VoiceLayer();

await voicelayer.messages.uploadAttachment();
```

Python:

```python
from voicelayer import VoiceLayer

vl = VoiceLayer()

vl.messages.upload_attachment()
```

## Response `201`

```json
{
  "upload": {
    "id": "upload",
    "name": "quote.pdf",
    "contentType": "application/pdf",
    "sizeBytes": 48211,
    "uploadId": "eyJ2IjoxLCJwIjoib3JnXzEifQ.3f2a",
    "expiresAt": "2026-10-20T15:04:05.000Z"
  },
  "summary": "\"quote.pdf\" is ready to attach. It stays available for one hour."
}
```
