# list()

Canonical URL: https://developers.iagenify.com/sdk/ref/files/list/
Language: en

`api.files.list() → Promise<File[]>`

Every file on the account, as plain records. No content, no size limit on the call — this is the inventory.

Status: GET /api/files · free · an array

## Returns {#returns}

```javascript
[
  {
    id: "…",
    name: "report.md",
    category: "document",
    mimeType: "text/markdown",
    size: 2048,
    storageId: "…",
    status: "done",
    createdAt: "2026-10-07T11:02:08.400Z"
  }
]
```

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | What [get()](/sdk/ref/files/get), `update()` and `delete()` take. |
| `name` | string |  | As you named it. |
| `category` | string |  | `image` · `data` · `document` · `video` · `audio`. |
| `mimeType` | string |  | The type it was saved with. |
| `size` | integer |  | Bytes. Read this before fetching something large. |
| `storageId` | string |  | Which storage holds it. |
| `status` | string |  | `done` when it is there. |
| `createdAt` | string |  | When it was saved. |

An array, directly — not an envelope. The content is not in it: this call stays cheap however many files you have, and reading one is [get()](/sdk/ref/files/get).

## It returns everything {#everything}

There is no limit and no cursor, so an account with thousands of files answers with thousands. Filter and sort on your side.

```javascript
const files = await api.files.list();

// What is actually taking the space
const heaviest = [...files].sort((a, b) => b.size - a.size).slice(0, 10);

// How much, in total and per storage
const total = files.reduce((sum, f) => sum + (f.size || 0), 0);

const perStorage = new Map();
for (const f of files) {
  perStorage.set(f.storageId, (perStorage.get(f.storageId) || 0) + (f.size || 0));
}
```

## Picking one to read {#picking}

```javascript
const files = await api.files.list();

const latest = files
  .filter((f) => f.category === "document")
  .sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt))[0];

const file = await api.files.get(latest.id);
```

> **Names are not unique**
>
> Saving twice under one name gives two files. Match on id, and treat the name as a label for people.

## A tidy-up that is safe to run {#tidy}

```javascript
const files = await api.files.list();
const month = Date.now() - 30 * 24 * 60 * 60 * 1000;

const temporary = files.filter(
  (f) => f.name.startsWith("tmp-") && Date.parse(f.createdAt) < month,
);

for (const f of temporary) await api.files.delete(f.id);
```

Narrow by something you control — a prefix your own code writes — rather than by age alone. Age is not a signal that a file is finished with.

- [get()](/sdk/ref/files/get): Reading one, with its content.
- [delete()](/sdk/ref/files/delete): Removing one.

```python
[
    {
        "id": "…",
        "name": "report.md",
        "category": "document",
        "mimeType": "text/markdown",
        "size": 2048,
        "storageId": "…",
        "status": "done",
        "createdAt": "2026-10-07T11:02:08.400Z",
    }
]
```

```python
from collections import Counter

files = api.files.list()

# What is actually taking the space
heaviest = sorted(files, key=lambda f: f.get("size") or 0, reverse=True)[:10]

# How much, in total and per storage
total = sum(f.get("size") or 0 for f in files)

per_storage = Counter()
for f in files:
    per_storage[f["storageId"]] += f.get("size") or 0
```

```python
files = api.files.list()

latest = max((f for f in files if f["category"] == "document"), key=lambda f: f["createdAt"])

file = api.files.get(latest["id"])
```

```python
from datetime import datetime, timedelta, timezone

files = api.files.list()
month = datetime.now(timezone.utc) - timedelta(days=30)

temporary = [f for f in files
             if f["name"].startswith("tmp-")
             and datetime.fromisoformat(f["createdAt"].replace("Z", "+00:00")) < month]

for f in temporary:
    api.files.delete(f["id"])
```
