Upload a file to a site
/v1/sites/{siteId}/files/upload Uploads a file to the site: send its bytes as the body, with Content-Type: application/octet-stream and its size in Content-Length (400 length_required without it). The bytes are passed on to the site's server as they arrive, and the file appears whole once they all have: an upload cut short leaves nothing behind (422 incomplete).
Up to the File Manager's upload limit of 100 MB (413 payload_too_large). A file already at path is replaced only with overwrite=true. The folder must exist. Location is the file's download address. An Idempotency-Key is accepted, but an upload's answer isn't kept: a key can be sent again once its upload has finished. Not while a staging operation copies, pushes or puts back the site (409 staging_busy).
Time. The whole upload must arrive within 5 minutes of the request's start: a slower one is cut off (the connection is closed, often with a plain 408 that isn't JSON), and nothing is kept. A 100 MB file needs about 350 KB a second.
Scopes
The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).
-
sites:files - Files and logins. File Manager, WordPress logins, cron jobs, backup downloads and backup storage. Full access to the sites' code and data.
Headers
| Field | Type and description |
|---|---|
Idempotency-Key | string 1 to 255 characters A key of your own for this request, like a UUID: letters, digits and |
Path parameters
| Field | Type and description |
|---|---|
siteId Required | string The site's id. |
Query parameters
| Field | Type and description |
|---|---|
path Required | string Up to 4,096 characters The file's path in the site, name included, like |
overwrite | string
One of: |
Request body
The file itself, as the request's raw body, with Content-Type: application/octet-stream.
Example request
curl -X PUT "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/upload?path=%2Fwp-content%2Fuploads%2F2026%2F11%2Fteam-photo.jpg&overwrite=true" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@upload.bin" import { readFile } from "node:fs/promises";
const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/upload?path=%2Fwp-content%2Fuploads%2F2026%2F11%2Fteam-photo.jpg&overwrite=true", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/octet-stream",
},
body: await readFile("upload.bin"),
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data } = await res.json();
console.log(data); import { readFile } from "node:fs/promises";
import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const data = await rf.sites.files.upload({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
path: "/wp-content/uploads/2026/11/team-photo.jpg",
overwrite: true,
body: await readFile("upload.bin"),
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/upload?path=%2Fwp-content%2Fuploads%2F2026%2F11%2Fteam-photo.jpg&overwrite=true');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 360,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
'Content-Type: application/octet-stream',
],
CURLOPT_POSTFIELDS => file_get_contents('upload.bin'),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
print_r(json_decode($body, true)['data']); import os
import requests
response = requests.put(
"https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/upload",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
"Content-Type": "application/octet-stream",
},
params={
"path": "/wp-content/uploads/2026/11/team-photo.jpg",
"overwrite": "true",
},
data=open("upload.bin", "rb"),
timeout=360,
)
response.raise_for_status()
print(response.json()["data"]) Response
201 Created Returns the FileEntry object in data.
The FileEntry object's fields 8 fields
| Field | Type and description |
|---|---|
name | string Its name: the last part of its path. |
path | string Its path in the site, from the site's folder (always starts with |
type | string
Known values: |
sizeBytes | integer Its size, in bytes. For a folder, the size of the folder's own entry, not of what it holds. |
modifiedAt | string An ISO 8601 time, in UTC When it was last changed. |
mode | string Its permissions, as three octal digits: |
version | string Changes whenever the file changes. Send it as |
linkTargetType | string or null For a link: what it leads to: Known values: |
Example response
{
"data": {
"name": "team-photo.jpg",
"path": "/wp-content/uploads/2026/11/team-photo.jpg",
"type": "file",
"sizeBytes": 284113,
"modifiedAt": "2026-11-18T16:20:45.512Z",
"mode": "644",
"version": "1795025645512000000:284113",
"linkTargetType": null
}
} Errors
The errors this request can answer besides those every request can (a missing token, a missing scope, the rate limits). Each answer is an Error object (see Errors).
| Status and code | When, and what to do |
|---|---|
400 invalid_ | A query parameter is unknown or has a wrong value ( Correct or remove the parameter named in |
400 length_ | An upload was sent without a Content-Length header. Send the file's size in Content-Length. |
400 bad_ | The path isn't one the site's server can use. Use a path in the site that starts with /, without control characters. |
403 trial_ | The site's server is on the free trial: WordPress sign-in, the File Manager and Cron Jobs switch on once it's kept. Keep the server in the control panel: they switch on by themselves. |
403 outside_ | The path leads outside the site's folder (through a link), which files can't reach. Use a path inside the site's folder. |
403 permission_ | The site's server refused access to a file or folder: its permissions don't let the site's own user do this. Check its permissions ( |
404 not_ | The resource doesn't exist, or isn't this account's. Check the id. Ids of other accounts' resources answer the same way. |
409 site_ | The site isn't in a state that allows this (for example, it's still installing). Wait until the site is active, then try again. |
409 server_ | The server isn't in a state that allows this (for example, it's off or still being set up). Start the server, or wait until it's active, then try again. |
409 staging_ | A staging operation is running on this site, or on a site of this server. Wait until it finishes ( |
409 exists | Something with that name is already there. Choose another name, or send |
409 is_ | A folder with that name is already there, so a file can't be written in its place. Choose another name, or delete the folder first. |
409 server_ | The server is being restored, and nothing else can change it or its sites until that's done. Wait until the restore finishes (the server's |
413 payload_ | The body is larger than the operation accepts (1 MB for JSON). Send less data; uploads have their own limit. |
413 too_ | It's too large for this: a file over 2 MB to read as text, an upload over the limit, or an archive that holds more than 60,000 files or 4 GB. Download the file instead of reading it, upload a smaller file, or extract a smaller archive. |
415 unsupported_ | The body isn't sent as application/json (or application/octet-stream for uploads). Send Content-Type: application/json with a JSON body. |
422 io_ | The site's server couldn't complete the file operation (its disk or file system refused). Try again; if it keeps failing (for example, the disk is full), contact support. |
422 incomplete | The upload ended before every byte its Content-Length announced arrived, so nothing was saved. Upload the file again. |
502 server_ | The server didn't answer, or didn't finish the request. Check that the server is running, then try again in a minute. |
502 file_ | The site's server didn't complete the file operation. Try again in a moment. |