# Files

> Upload the images, videos and documents a study shows, and the data files an audience is built from.

Source: https://imario.ai/docs/api/reference/files

Base URL `https://api.imario.ai/v1`. Each call needs a key that holds the scope shown and acts with at least the role shown ([Authentication](https://imario.ai/docs/api/authentication)). Errors are described in [API errors](https://imario.ai/docs/api/errors).

## Upload a file

`POST /v1/files`

**Scope** `library:write` · **Role** editor or above

Upload one file (editor or above). Returns the file object `{filename, content_type, size, kind: image|video|document, purpose, duration_seconds (videos), download_url}`. Limits: 50 MB for images and documents, 100 MB and 3 minutes for a video (MP4, MOV, WebM), 100 MB for audience data. A study-material file also appears in the Library.

**Request body**

Send it as `multipart/form-data`.

| Field | Type | Required | Description |
|---|---|---|---|
| `file` | `file` | Yes | The file (multipart/form-data). |
| `purpose` | `string` | No | study_material (images, videos, documents a study shows or reads) or audience_data (tables, transcripts). One of `study_material`, `audience_data`. Default `"study_material"`. |

**Example**

```bash
curl https://api.imario.ai/v1/files \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -F file=@concept.png \
  -F purpose=study_material
```

## List files, newest first

`GET /v1/files`

**Scope** `library:read` · **Role** any member

The workspace's files (uploaded here, in the app, or by an agent), without download links: retrieve a file for its `download_url`.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `limit` | query | `integer` | No | How many objects to return (1-100). Default `20`. |
| `cursor` | query | `string` | No | The `next_cursor` of the previous page. Up to 200 characters. |
| `purpose` | query | `string` | No | One of `study_material`, `audience_data`. |

**Example**

```bash
curl https://api.imario.ai/v1/files \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

**Response**

Returns a list: `{"object": "list", "data": [...], "has_more": false, "next_cursor": null}`. See [Pagination](https://imario.ai/docs/api/pagination).

## Retrieve a file

`GET /v1/files/{file_id}`

**Scope** `library:read` · **Role** any member

The file and a `download_url`, a presigned link valid one hour (`expires_at`); ask again for a fresh one. A test key's own files keep metadata only (`download_url` null).

**Example**

```bash
curl https://api.imario.ai/v1/files/FILE_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

## Delete a file

`DELETE /v1/files/{file_id}`

**Scope** `library:write` · **Role** editor or above

Soft, like the Library's delete: the file and its Library item are no longer listed or offered to new studies; a study already set up with it keeps its copy.

**Example**

```bash
curl -X DELETE https://api.imario.ai/v1/files/FILE_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```
