---
title: REST API overview
project: OpenFiles
version: 1.0
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/openfiles/1-0/reference/rest-api/
updated: 2026-11-19T07:45:44.888Z
---

# REST API overview

> The endpoints your apps call, how to send the token and what comes back.

Your apps talk to OpenFiles over HTTP. The address of every endpoint starts with your OpenFiles address, for example `https://files.example.com`.

## Endpoints

| Method and path | What it does |
|---|---|
| `POST /upload/{db}/` | [Upload files](../upload/) as `multipart/form-data`. |
| `POST /files/{db}/` | The same as `/upload/{db}/`. |
| `POST /base64/{db}/` | [Upload one file as Base64](../upload-base64/) in JSON. |
| `GET /files/{db}/{id}-{checksum}.{ext}` | [Open or download a file](../file-links/). Public, no token. |

`{db}` is the storage name, for example `photos`. The storage must exist; create it in [Storages](../../guides/storages/).

## Send the token

Every upload needs an [API token](../../guides/api-tokens/). Send it in one of two ways:

- as the `token` query argument:

```bash
curl -F file=@sunset.png "https://files.example.com/upload/photos/?token=YOUR_TOKEN"
```

- or in the `x-token` header:

```bash
curl -H "x-token: YOUR_TOKEN" -F file=@sunset.png "https://files.example.com/upload/photos/"
```

The header keeps the token out of server logs and browser history, so prefer it when your app can set headers.

## What comes back

A successful upload answers `200` with JSON that describes the file:

```json
{"id":"JapO3b1e961f","name":"sunset.png","size":2795,"type":"image/png","width":640,"height":480,"ext":"png","url":"/files/photos/JapO3b1e961f-pn.png"}
```

| Field | Meaning |
|---|---|
| `id` | The file ID in the storage. |
| `name` | The file name. |
| `size` | Size in bytes. |
| `type` | The content type. |
| `width`, `height` | Image size in pixels; `0` for other files. |
| `ext` | The file extension. |
| `url` | The [link](../file-links/) to the file. Relative, unless you add `hostname=1`. |

Save `id` and `url` in your app. Errors come back as a JSON array with an `error` text. See [Errors and limits](../errors/).

## Cross-origin requests

The upload endpoints allow cross-origin requests, so a web page on another domain can upload directly. See [Upload from a web page](../../recipes/upload-from-browser/).
