# File upload API

> Upload files directly to storage with one-time URLs, then reference them in a submission.

Source: https://docs.formclick.io/api-reference/file-upload-api

`formclick.min.js` handles uploads for you. If you build your own client (a mobile app, a custom uploader), follow the same three steps.

> **Note:** File uploads are available on the Pro and Business plans. Each file can be up to 5 MB.

## 1. Request an upload URL

```bash
curl -X POST https://api.formclick.io/preupload \
  -H "Content-Type: application/json" \
  -d '{
    "accessKey": "YOUR_ACCESS_KEY",
    "fileName": "jane-smith-cv.pdf",
    "contentType": "application/pdf",
    "fileSize": 248133
  }'
```

```json
{
  "success": true,
  "fileId": "f_9c1e…",
  "key": "uploads/…/jane-smith-cv.pdf",
  "uploadUrl": "https://…"
}
```

The upload URL is valid for **5 minutes** and works once.

## 2. Upload the file

Send the raw file bytes with `PUT`, using the same `Content-Type` you declared.

```js
await fetch(uploadUrl, {
  method: 'PUT',
  headers: { 'Content-Type': file.type },
  body: file,
});
```

## 3. Submit with the file reference

```json
{
  "access_key": "YOUR_ACCESS_KEY",
  "name": "Jane Smith",
  "resume": {
    "id": "f_9c1e…",
    "key": "uploads/…/jane-smith-cv.pdf",
    "name": "jane-smith-cv.pdf",
    "size": 248133,
    "type": "application/pdf"
  }
}
```

For a field with several files, send a list of these objects.

## Allowed file types

| Group | Types |
| --- | --- |
| Images | JPEG, PNG, GIF, WebP, SVG, TIFF |
| Documents | PDF, Word (`.doc`, `.docx`), Excel (`.xls`, `.xlsx`), PowerPoint (`.ppt`, `.pptx`) |
| Text & data | Plain text, CSV |
| Archives | ZIP |
