# Files API

All of these need your access key. Names are 1 to 128 characters of letters, digits, `.`, `_`, `-`, starting with a letter or digit.

## Upload

`PUT /files/{name}` takes the raw bytes as the body. They are streamed to disk, so large files do not fill memory.

```sh {tab="Upload"}
curl -H "Authorization: Bearer $FUZZY_KEY" \
  -T report.pdf "https://fuzzyshare.com/files/report.pdf?ttl=7d"
```

```sh {tab="From a pipe"}
echo '{"a":1}' | curl -H "Authorization: Bearer $FUZZY_KEY" \
  -T - "https://fuzzyshare.com/files/data.json?ttl=1h"
```

```sh {tab="Public"}
curl -H "Authorization: Bearer $FUZZY_KEY" \
  -T report.pdf "https://fuzzyshare.com/files/report.pdf?visibility=public"
```

| Parameter | Meaning |
|---|---|
| `ttl` | Lifetime, or header `X-Fuzzy-TTL`. Default 24h, max 14d |
| `visibility` | `private` (default) or `public`, or header `X-Fuzzy-Visibility`. Public also returns `public_url` and `raw_url` |
| `Content-Type` | Used for type detection, then the extension, then the first bytes |

`201` for a new file, `200` when it replaced one. Replacing resets the lifetime and revokes the old file's links.

```json
{"name":"report.pdf","size":184320,"content_type":"application/pdf","kind":"pdf",
 "uploaded_at":"2026-12-02T19:11:17Z","expires_at":"2026-12-09T19:11:17Z",
 "url":"https://fuzzyshare.com/files/report.pdf","uploaded_by":{"id":"k_2457f6de2af3","name":"default"},
 "visibility":"private","links":0}
```

Errors: `400` for a bad name or ttl or an interrupted upload, `413` when the file is over the size limit or the upload would exceed your 1 GB, `403` for `visibility=public` when public links are off.

## List

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" https://fuzzyshare.com/files
```

Returns `{"files":[...]}`, newest first. Each item has `name`, `size`, `content_type`, `kind`, `uploaded_at`, `expires_at`, `url`, `uploaded_by`, `visibility`, `links`, and `public_url` and `raw_url` when public.

## Download

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" -O https://fuzzyshare.com/files/report.pdf
```

`GET` and `HEAD` work, and `Range` is honored. An expired or missing file returns `404`.

## Delete

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" -X DELETE https://fuzzyshare.com/files/report.pdf
```

The file and its links are removed now.

## Change visibility

`PUT /files/{name}/visibility` with `{"visibility":"public"}` or `{"visibility":"private"}`.

```sh
curl -H "Authorization: Bearer $FUZZY_KEY" -X PUT \
  -d '{"visibility":"private"}' https://fuzzyshare.com/files/report.pdf/visibility
```

Public ensures one public link and returns `{visibility, public_url, raw_url}`. Private revokes the file's public links and leaves its private links alone.
