Make a new connect command
/v1/servers/{serverId}/connection/actions/renew Servers of your own that aren't connected yet: makes a new connect command. The old one stops working at once. Refused while the server is running the command, and for servers Rabbitflare created (409 invalid_state).
Scopes
The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).
-
servers:write - Manage servers. Power, reboot, snapshots and restores, log settings, restarting PHP, server security (Imunify360), and connecting your own servers.
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 |
|---|---|
serverId Required | string The server's id. |
Example request
curl -X POST "https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/connection/actions/renew" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" const res = await fetch("https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/connection/actions/renew", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
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.servers.connection.renew({
serverId: "3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d",
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/connection/actions/renew');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
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");
}
print_r(json_decode($body, true)['data']); import os
import requests
response = requests.post(
"https://api.rabbitflare.com/v1/servers/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/connection/actions/renew",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
200 OK Returns the ServerConnection object in data.
The ServerConnection object's fields 5 fields
| Field | Type and description |
|---|---|
command | string or null The one line to run on your server as root to connect it. It carries a one-time key: keep it private. Null once the server is connected. |
ports | array of objects The ports your server's firewall must allow from the internet. |
port | integer The port. |
protocol | string The protocol. Known values: |
purpose | string What it's for. |
Example response
{
"data": {
"command": "curl -fsSL https://app.rabbitflare.com/api/connect/3f6c1a2b-8d4e-4b7a-9c2d-1e5f7a8b9c0d/EXAMPLE-NEW-ONE-TIME-KEY | sudo bash",
"ports": [
{
"port": 80,
"protocol": "TCP",
"purpose": "Web traffic (HTTP), and SSL certificate checks"
},
{
"port": 443,
"protocol": "TCP",
"purpose": "Web traffic (HTTPS)"
},
{
"port": 22022,
"protocol": "TCP",
"purpose": "SSH for the Rabbitflare control panel"
}
]
}
} 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 |
|---|---|
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 invalid_ | The resource's status doesn't allow this now (for example, powering on a server that is running). Check the resource's |
409 busy | Another change is still in progress on this server or site, or something else under way stops this one for now (a site backup running on the server, the server's backups being moved): Wait until it finishes, then try again. A change to the server or site itself is done when its |
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 |