# POST /files/upload

**Resource:** [Files](./files.md)  
**Scopes:** `files:write`  
**Write operation:** yes

Upload a file via base64 content. "type" determines storage backend: "image" stores on public R2/CDN (returns r2_url), "document" stores in private Supabase bucket, "secure" stores in private Supabase bucket with confidential access. Size limits: image=10MB, document=25MB, secure=50MB.

## Parameters

| Name | In | Type | Required | Description |
|------|----|------|----------|-------------|
| `base64` | body | string | yes | Base64-encoded file content. Data URI prefix (e.g. "data:image/png;base64,") is accepted and auto-stripped. |
| `name` | body | string | yes | Filename with extension (e.g. "report.pdf") |
| `type` | body | string | yes | Storage type: "document", "image", or "secure" |
| `mime_type` | body | string | no | MIME type (default: application/octet-stream) |
| `folder` | body | string | no | Folder name to organise the file |
| `description` | body | string | no | Optional description |
| `category` | body | string | no | Category for image files (e.g. images, documents, videos) |
| `document_type` | body | string | no | Document type category (type=document only) |
| `file_category` | body | string | no | File category (type=secure only) |

---
Base URL: `https://api.trustpager.com/functions/v1/api/v1` — Auth: `Authorization: Bearer YOUR_API_KEY`