API
/dashboard/settings/api
The API lets applications and scripts upload files to your website. It is served at /api/1/upload (see the API V1 documentation).
Requests are authorized with the X-API-Key header or the key parameter. The key is either:
- a user API key, which acts as that user, or
- the Public API key, which acts as a guest (not logged in).
When both Enable API user and Enable API guest are disabled, the API isn't available and /api responds with 404.
TIP
These settings can be locked by environment variables. If CHEVERETO_ENABLE_API_USER or CHEVERETO_ENABLE_API_GUEST is set to 0, the matching option is always disabled, whatever is set here. Setting CHEVERETO_ENABLE_GUESTS to 0 also disables the guest API. See Toggles.
Enable API user
Toggles API access for registered users, who authenticate with their own API key.
| Value | Effect |
|---|---|
| Enabled | Users can create an API key at /settings/api and use it with the API |
| Disabled | The /settings/api page is hidden and user API keys are rejected with 403 |
Default: Enabled.
Each user gets one API key, created the first time they open /settings/api. A request made with a user key counts as that user: their upload permissions apply, and the files are added to their account. Requests from an account that isn't active are rejected.
WARNING
In personal website mode, only the personal profile user and admins can upload through the API.
Enable API guest
Toggles API access for guests, who authenticate with the Public API key.
| Value | Effect |
|---|---|
| Enabled | Requests made with the Public API key upload as a guest |
| Disabled | The Public API key is rejected |
Default: Disabled. We recommend keeping this disabled unless you need it, because anyone who has the Public API key can upload to your website.
Guest API uploads follow the same rules as guest uploads on the website. They are refused (403) if any of these is true:
- Guest uploads is disabled.
- Website privacy mode is set to private.
- The website is in maintenance.
The Maximum upload file size (guests) limit applies. Uploads from a URL through the API are allowed for admins only, for both users and guests.
Public API key
The key that guests use to call the API. It only works while Enable API guest is enabled.
| Type | Accepted |
|---|---|
| String | Any non-empty string |
A random 64-character key is generated when Chevereto is installed. You can replace it with any value, which immediately makes the old key stop working. Use a long, random value, as the key is not checked for strength.
This key is meant to be embedded in public clients, such as a browser extension or a desktop uploader, so treat it as public rather than secret. If it gets abused, change it here or disable Enable API guest.
DANGER
If the key is empty while Enable API guest is enabled, API requests fail with an error asking you to set the key.
Example
The settings page shows a ready-to-use command with your website URL and Public API key:
curl --fail-with-body -X POST \
-H "X-API-Key: <public_api_key>" \
-H "Content-Type: multipart/form-data" \
-F "source=@image.jpeg" \
https://your-website.com/api/1/upload