> ## Documentation Index
> Fetch the complete documentation index at: https://visaflo.ca/knowledge-base/llms.txt
> Use this file to discover all available pages before exploring further.

# Files and Forms

> Upload case documents, retrieve case files, and monitor form automation through the VisaFlo API.

## Upload a Case File

`POST /api/public/case/:caseId/file/upload`

The endpoint accepts one file as `multipart/form-data`. VisaFlo stores it in a virtual `api` folder on the case, creating that folder when needed.

```bash theme={null}
curl -X POST "https://api.visaflo.app/api/public/case/VFLO_CASE_ID/file/upload" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@/path/to/passport.pdf"
```

The maximum upload size is 50 MB per request.

```json theme={null}
{
  "success": true,
  "data": {
    "fileRegistryId": "NEW_FILE_REGISTRY_ID",
    "originalName": "passport.pdf",
    "size": 245678,
    "logicalPath": "api/passport.pdf"
  }
}
```

## Retrieve Case Files

`GET /api/public/case/download-files/:caseId`

Use the VisaFlo case ID returned from case creation or case search. Confirm the ID before downloading files; do not substitute the human-readable case number.

## Form Generation and Autofill

| Method | Endpoint                                   | Purpose                                     |
| ------ | ------------------------------------------ | ------------------------------------------- |
| `POST` | `/api/public/case/:caseId/generate-forms`  | Start generation for configured case forms. |
| `GET`  | `/api/public/case/:caseId/autofill-status` | Read the current autofill status.           |

Treat form generation as asynchronous. Start the work, then poll the status endpoint from your server until the result reaches a terminal state. Avoid rapid polling; use a backoff interval.

<Tip>
  For document intake, search for the case first, then upload with its `caseId`. This avoids attaching a file to the wrong matter when your source system only has a file number or client email.
</Tip>
