# Storage

Files for your application, kept sealed on disk. A file lives in a **bucket**, at a **path**, and belongs to the **organization** of whoever uploaded it. One organization never sees another's files.

All routes are under `https://api.rezincore.com/v1/storage` and carry your project key in `apikey`, with a user's token or (from your server) a secret key and `x-organization-id`.

## Upload

```
PUT /v1/storage/<bucket>/<path>
```

The file is the request body, stored as it is. Send its kind in `content-type`.

```
curl -s -X PUT $API/v1/storage/documents/reports/q1.pdf \
  -H "apikey: $KEY" -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/pdf" --data-binary @q1.pdf
```

```json
{ "bucket": "documents", "path": "reports/q1.pdf", "bytes": 48213, "contentType": "application/pdf" }
```

Uploading to a path that exists replaces the file. One file can be up to 25 MB.

## List

```
GET /v1/storage/<bucket>?prefix=<start of path>
```

```json
{ "files": [ { "path": "reports/q1.pdf", "bytes": 48213, "contentType": "application/pdf", "createdAt": "2026-11-26T15:04:05.000Z" } ] }
```

## Download

```
GET /v1/storage/<bucket>/<path>
```

The answer is the file, with its stored `content-type`, as a download.

## Delete

```
DELETE /v1/storage/<bucket>/<path>
```

```json
{ "ok": true }
```

## Names

| What | Rule |
|---|---|
| Bucket | Lowercase letters, digits and dashes, starting with a letter, up to 63 characters. Not `public` or `signed`. |
| Path | Up to 500 characters, parts separated by `/`. No empty part and no `..`. |

## Buckets and their settings

A bucket is made in the console (**Storage → New bucket**) or by the first upload to a new name. Made by an upload, it is private, takes any kind of file up to the size limit, and belongs to the whole organization.

In the console each bucket can be given:

- **A largest file size and the kinds of file it accepts**, such as `image/*` or `application/pdf`. The kind is what the uploader declares in `content-type`; the contents are not inspected. A refused upload answers `400 not_accepted`.
- **Who reads a file**: everyone in the same organization, or only the account that uploaded it. Your own server, with a secret key, reads all of the organization's files.
- **Who adds and removes files**: any signed-in account, or only your own server. With "only your own server", a signed-in user's upload or delete answers `403 server_only`.
- **Public**: anyone who has a file's address can read it, with no key.

## Public buckets

```
GET https://api.rezincore.com/v1/storage/public/<project ID>/<bucket>/<organization ID>/<path>
```

No key and no token. Use it for images and other assets that anyone may see.

> **Important.** Never put private information in a public bucket. Anyone who learns or guesses a file's address can read it.

## Signed links

A private file can be handed out for a limited time: for a link in a page, an email or a chat.

```
POST /v1/storage/<bucket>/sign
```

```
curl -s $API/v1/storage/documents/sign -H "apikey: $KEY" -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" -d '{"path":"reports/q1.pdf","expiresIn":3600}'
```

```json
{
  "url": "https://api.rezincore.com/v1/storage/signed/abcdefghijklmnopqrst/documents/0d9c8b7a-…/reports/q1.pdf?expires=1795700000&sig=…",
  "expiresAt": "2026-11-26T16:04:05.000Z"
}
```

- `expiresIn` is in seconds, from 10 to 604800 (7 days). Without it, one hour.
- You can only sign a file you could read yourself.
- The link works without a key until it expires, for that one file.
- **It cannot be recalled early** except by deleting the file. Choose the shortest life that does the job.
- Making a link is on the audit record. An expired or altered link answers `403 bad_link`.

## How files are shown

Through a public or signed address, images (PNG, JPEG, GIF, WebP, AVIF), PDFs, plain text and common audio and video (MP3, MP4, WebM) are shown in place. Every other kind is handed over as a download, so a stored web page or script never runs from the API's address.

## From the command line

```
rezin storage ls documents reports/
rezin storage upload documents ./q1.pdf reports/q1.pdf
```

See [The command-line tool](https://rezincore.com/docs/tools/cli.md). The console's **Files** page lists buckets and the newest files and lets members download one.

## Errors

| Status | Code | When |
|---|---|---|
| 400 | `bad_request` | A bucket name or path that cannot be used, or an empty body |
| 400 | `not_accepted` | The bucket's settings refuse this file (too large, or not an accepted kind) |
| 403 | `server_only` | Only your own server may add or remove files in this bucket |
| 403 | `bad_link` | A signed link that has expired or is not valid |
| 404 | `not_found` | No such file |
