Quick start
Make a token, make your first call, then create a WordPress site from your own code.
3 min read Updated
This guide takes you from your first token to a WordPress site made from your own code, in a few minutes. Every step comes in cURL, JavaScript, PHP and Python, and with the SDK: pick your language on any sample, and the others follow.
Before you start
- Your own Rabbitflare account. API tokens belong to the account's owner, so team members can't make them.
- Two-factor authentication turned on: making a token asks for a code from your authenticator app. The API opens once the account's email address is confirmed and its first payment is made.
- A server to put the site on. Step 2 lists yours; you can also create one through the API.
-
To run the samples:
curl, Node.js 18 or later (save the JavaScript as an.mjsfile), PHP with its curl extension, or Python 3 withrequests(pip install requests).
1. Make a token
-
Open the API page
In the control panel, open API in the sidebar and choose Generate new token.
-
Say what it may do
Name it, like Quick start. Under Access, choose Custom and tick View servers, View sites and Create sites: enough to list your servers and to create a site. Read only is enough if you only want to look around. Leave it on all servers, and its expiry at 90 days.
-
Confirm it's you
Enter the 6-digit code from your authenticator app, and choose Generate token.
-
Copy the token
Keep the token in an environment variable, not in your code. Every sample in these docs reads it from RABBITFLARE_TOKEN:
export RABBITFLARE_TOKEN="rfp_ExampleTokenNotRealExampleTokenNotReal00Ex4mpl" That token is a made-up example: paste yours. In a CI job or on a server, put it in the job's secrets or the server's environment instead (see the security checklist).
2. Make your first call
List your servers with GET /v1/servers:
curl "https://api.rabbitflare.com/v1/servers" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" const res = await fetch("https://api.rabbitflare.com/v1/servers", {
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data, pagination } = await res.json();
console.log(data, pagination.nextCursor); import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
for await (const item of rf.servers.list()) {
console.log(item);
} <?php
$ch = curl_init('https://api.rabbitflare.com/v1/servers');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
$answer = json_decode($body, true);
print_r($answer['data']);
echo $answer['pagination']['nextCursor'] ?? 'Last page', PHP_EOL; import os
import requests
response = requests.get(
"https://api.rabbitflare.com/v1/servers",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
timeout=120,
)
response.raise_for_status()
answer = response.json()
print(answer["data"], answer["pagination"]["nextCursor"]) Every answer is JSON. This one holds your servers, like this:
{
"data": [
{
"id": "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
"name": "Production",
"status": "active",
"stage": "complete",
"pendingAction": null,
"cloud": "digitalocean",
"region": "fra1",
"planId": "business",
"priceMonthlyCents": 5200,
"currency": "usd",
"ipv4": "203.0.113.10",
"ipv6": "2001:db8::10",
"phpVersion": "8.3",
"backupsEnabled": true,
"automaticBackupsBy": null,
"billing": {
"method": "card",
"status": "active",
"currentPeriodEnd": "2026-12-18T08:46:49.000Z"
},
"pendingPlanId": null,
"scheduledDeletionAt": null,
"trial": false,
"specs": null,
"siteCount": 2,
"dataTransfer": null,
"phpSecurity": {
"state": "current",
"reason": null,
"build": "8.3.6-0ubuntu0.24.04.13",
"packages": 14,
"fixes": [],
"restart": [],
"auto": true,
"listsAt": "2026-11-18T06:12:04.000Z",
"securityAt": "2026-11-17T21:30:00.000Z",
"checkedAt": "2026-11-18T07:00:31.000Z",
"error": null
},
"security": {
"status": "on",
"available": true
},
"lastError": null,
"readyAt": "2026-11-18T08:51:12.000Z",
"createdAt": "2026-11-18T08:46:49.000Z",
"updatedAt": "2026-11-18T09:02:31.000Z"
}
],
"pagination": {
"limit": 25,
"hasMore": false,
"nextCursor": null
}
} data- Your servers, newest first, each a Server object.
id- The server's id. Calls about the server use it, like
GET /v1/servers/{serverId}, and the next step needs it. statusactivewhen it's running;provisioningwhile it's being set up.cloud,region,planId- Where it runs and its plan, by their ids in the catalogue.
pagination-
Lists come a page at a time, 25 items unless you ask for more.
hasMoreisfalse, so this page holds every server (see Pagination).
3. Create a WordPress site
Now make something: a WordPress site on one of your servers, with POST /v1/sites. Put the server's id in
serverId, and choose the site's name, its title and its WordPress administrator:
curl -X POST "https://api.rabbitflare.com/v1/sites" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"serverId": "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
"name": "Shop",
"siteTitle": "Example Shop",
"adminUsername": "editor",
"adminEmail": "[email protected]"
}' const res = await fetch("https://api.rabbitflare.com/v1/sites", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"serverId": "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
"name": "Shop",
"siteTitle": "Example Shop",
"adminUsername": "editor",
"adminEmail": "[email protected]"
}),
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data } = await res.json();
console.log(data); import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const data = await rf.sites.create({
serverId: "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
name: "Shop",
siteTitle: "Example Shop",
adminUsername: "editor",
adminEmail: "[email protected]",
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'serverId' => '3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d',
'name' => 'Shop',
'siteTitle' => 'Example Shop',
'adminUsername' => 'editor',
'adminEmail' => '[email protected]',
]),
]);
$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.post(
"https://api.rabbitflare.com/v1/sites",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
json={
"serverId": "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
"name": "Shop",
"siteTitle": "Example Shop",
"adminUsername": "editor",
"adminEmail": "[email protected]",
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"])
The answer comes straight away: 201 Created, with the new site and its status queued, while your server
installs it. On a running server the install starts at once and usually takes 1 to 2 minutes (installing, with stage wordpress, then ssl); on a server that's still being set up it starts as soon as the server is ready.
Wait until it's live
Read the site every 10 seconds until its status is active:
curl "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" // Read the site every 10 seconds until it's live, for up to 10 minutes.
async function waitForSite(siteId) {
const deadline = Date.now() + 10 * 60_000;
while (Date.now() < deadline) {
const res = await fetch(`https://api.rabbitflare.com/v1/sites/${siteId}`, {
headers: { Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}` },
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data: site } = await res.json();
if (site.status === "active") return site;
if (site.status === "failed") throw new Error(`The install failed: ${site.lastError}`);
await new Promise((resolve) => setTimeout(resolve, 10_000));
}
throw new Error("The site isn't live after 10 minutes");
}
const site = await waitForSite("8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d");
console.log(`${site.url} is live`); // Read the site every 10 seconds until it's live, for up to 10 minutes.
import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const siteId = "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d";
// It throws a RabbitflareWaitError if the install failed (its lastError says why), or the time ran out.
// Each read is given the wait's signal and the time left, so the wait's limit holds for it too.
const site = await rf.waitFor((options) => rf.sites.get({ siteId }, options), {
until: (s) => s.status === "active",
intervalMs: 10_000,
timeoutMs: 10 * 60_000,
});
console.log(`${site.url} is live`); <?php
// Read the site every 10 seconds until it's live, for up to 10 minutes.
function waitForSite(string $siteId): array
{
$deadline = time() + 10 * 60;
while (time() < $deadline) {
$ch = curl_init('https://api.rabbitflare.com/v1/sites/' . $siteId);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN')],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
$site = json_decode($body, true)['data'];
if ($site['status'] === 'active') {
return $site;
}
if ($site['status'] === 'failed') {
throw new RuntimeException('The install failed: ' . $site['lastError']);
}
sleep(10);
}
throw new RuntimeException("The site isn't live after 10 minutes");
}
$site = waitForSite('8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d');
echo $site['url'], ' is live', PHP_EOL; import os
import time
import requests
def wait_for_site(site_id):
"""Read the site every 10 seconds until it's live, for up to 10 minutes."""
deadline = time.monotonic() + 10 * 60
while time.monotonic() < deadline:
response = requests.get(
f"https://api.rabbitflare.com/v1/sites/{site_id}",
headers={"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"]},
timeout=120,
)
response.raise_for_status()
site = response.json()["data"]
if site["status"] == "active":
return site
if site["status"] == "failed":
raise RuntimeError("The install failed: " + str(site["lastError"]))
time.sleep(10)
raise TimeoutError("The site isn't live after 10 minutes")
site = wait_for_site("8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d")
print(site["url"], "is live")
Then open its url. It answers on its built-in address (builtInDomain) until you connect your own domain.
If the install fails, status is failed and lastError says why: try it again once that's fixed.
What's next
- Authentication: what a token carries, and how to replace one without stopping your apps.
- Scopes: give each token only what it needs.
- Errors: what a failed request answers, and which errors are worth retrying.
- Long-running operations: follow servers and sites while they're set up.
- Webhooks: have Rabbitflare tell your own URL when something happens, instead of asking.
Still have a question?
Our team answers support tickets about the API, and other developers answer in the community.