---
title: "Files"
description: "`files.list`, `listAll`, `iterate`, `get`, `download`, `listLinks`, `listAllLinks`, `iterateLinks` and `delete`."
url: "https://openemail.uk/docs/sdk/files"
area: "SDK"
category: "Mailbox"
---

# Files

`files.list`, `listAll`, `iterate`, `get`, `download`, `listLinks`, `listAllLinks`, `iterateLinks` and `delete`.

## Every method

**files.ts**

```
import { writeFile } from 'node:fs/promises'

const page = await openemail.files.list({ kind: 'pdf', sort: 'largest' })
const file = page.items[0]!

await writeFile(file.filename, await openemail.files.download(file.id))

const links = await openemail.files.listAllLinks(file.id)
console.log(links.map((link) => [link.url, link.downloads]))

await openemail.files.delete(file.id)
```

Every attachment the mailbox holds, sent and received, the Files page of the app. `download` resolves with the bytes as a `Uint8Array`, and the links are the download links a large attachment went out as, with how often each was fetched.

> Reading needs `threads:read` and deleting needs `threads:write`, and only the workspace owner may delete. A key limited to particular addresses or domains sees only the files that arrived at them.
