Start, stop, reboot
Start boots a stopped server, shutdown turns the system off cleanly and stop cuts the power. Reboot restarts the system cleanly, reset works like the reset button. For about a minute after a create or a reinstall the system is still setting up and may ignore shutdown and reboot, so try again later or use stop or reset.
Parameters
| Name | In | Description |
|---|---|---|
| vps_uuid | path, stringrequired | VPS id, from Create a VPS or List VPS |
Request body
| Field | Type | Description |
|---|---|---|
| action | stringrequired | start | stop | shutdown | reboot | reset (hard reboot) |
Example request
curl -X POST "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/action" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"action": "reboot"
}'import os, requests
token = os.environ["API_TOKEN"]
vps_uuid = "12d46f8c-d66e-4163-99aa-1245d5b06e5b"
r = requests.post(
f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}/action",
headers={"Authorization": f"Bearer {token}"},
json={
"action": "reboot"
},
)
r.raise_for_status()
print(r.json())const vpsUuid = '12d46f8c-d66e-4163-99aa-1245d5b06e5b';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}/action`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"action": "reboot"
}),
});
console.log(r.status, await r.json());curl -X POST "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/action" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"action": "start"
}'import os, requests
token = os.environ["API_TOKEN"]
vps_uuid = "12d46f8c-d66e-4163-99aa-1245d5b06e5b"
r = requests.post(
f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}/action",
headers={"Authorization": f"Bearer {token}"},
json={
"action": "start"
},
)
r.raise_for_status()
print(r.json())const vpsUuid = '12d46f8c-d66e-4163-99aa-1245d5b06e5b';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}/action`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"action": "start"
}),
});
console.log(r.status, await r.json());curl -X POST "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/action" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"action": "shutdown"
}'import os, requests
token = os.environ["API_TOKEN"]
vps_uuid = "12d46f8c-d66e-4163-99aa-1245d5b06e5b"
r = requests.post(
f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}/action",
headers={"Authorization": f"Bearer {token}"},
json={
"action": "shutdown"
},
)
r.raise_for_status()
print(r.json())const vpsUuid = '12d46f8c-d66e-4163-99aa-1245d5b06e5b';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}/action`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"action": "shutdown"
}),
});
console.log(r.status, await r.json());curl -X POST "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/action" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"action": "stop"
}'import os, requests
token = os.environ["API_TOKEN"]
vps_uuid = "12d46f8c-d66e-4163-99aa-1245d5b06e5b"
r = requests.post(
f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}/action",
headers={"Authorization": f"Bearer {token}"},
json={
"action": "stop"
},
)
r.raise_for_status()
print(r.json())const vpsUuid = '12d46f8c-d66e-4163-99aa-1245d5b06e5b';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}/action`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"action": "stop"
}),
});
console.log(r.status, await r.json());curl -X POST "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/action" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"action": "reset"
}'import os, requests
token = os.environ["API_TOKEN"]
vps_uuid = "12d46f8c-d66e-4163-99aa-1245d5b06e5b"
r = requests.post(
f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}/action",
headers={"Authorization": f"Bearer {token}"},
json={
"action": "reset"
},
)
r.raise_for_status()
print(r.json())const vpsUuid = '12d46f8c-d66e-4163-99aa-1245d5b06e5b';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}/action`, {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"action": "reset"
}),
});
console.log(r.status, await r.json());Answer
Status 200 with this body.
| Field | Type | Description |
|---|---|---|
| vps_uuid | stringrequired | |
| action | stringrequired | The action sent to the server |
{
"vps_uuid": "12d46f8c-d66e-4163-99aa-1245d5b06e5b",
"action": "reboot"
}Wait until it is ready
The answer comes at once and the action runs in the background. Get a VPS shows the server's status: running after start, stopped after shutdown or stop. A reboot keeps the status running, so watch uptime for it instead, below.
Check the status
Ask Get a VPS with the server's id:
curl "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID" \
-H "Authorization: Bearer $API_TOKEN"The answer carries the whole server; the field to watch is status:
{
"vps_uuid": "12d46f8c-d66e-4163-99aa-1245d5b06e5b",
"name": "web-1",
"uptime": 41,
"status": "running",
"ipv4": "185.236.9.61",
"error": null
}| status | What it means |
|---|---|
running | Up, after start, reboot or reset |
stopped | Off, after shutdown or stop |
error | Something went wrong; the error field says what |
Wait in a loop
Ask every few seconds until the status is the one you wait for, and stop on error.
# VPS_UUID: vps_uuid of the server, from the answer above
WANT=running # stopped after shutdown or stop
while true; do
VPS=$(curl -s "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID" -H "Authorization: Bearer $API_TOKEN")
STATUS=$(echo "$VPS" | jq -r .status)
echo "$STATUS"
[ "$STATUS" = "$WANT" ] && break
[ "$STATUS" = error ] && { echo "$VPS" | jq -r .error; exit 1; }
sleep 5
done# vps_uuid: vps_uuid of the server, from the answer above
import os, time, requests
headers = {"Authorization": f"Bearer {os.environ['API_TOKEN']}"}
want = "running" # "stopped" after shutdown or stop
while True:
vps = requests.get(f"https://platform.serverscamp.com/api/v1/vps/{vps_uuid}", headers=headers).json()
print(vps["status"])
if vps["status"] == want:
break
if vps["status"] == "error":
raise SystemExit(vps["error"])
time.sleep(5)// vpsUuid: vps_uuid of the server, from the answer above
const headers = { Authorization: `Bearer ${process.env.API_TOKEN}` };
const want = 'running'; // 'stopped' after shutdown or stop
let vps;
for (;;) {
vps = await (await fetch(`https://platform.serverscamp.com/api/v1/vps/${vpsUuid}`, { headers })).json();
console.log(vps.status);
if (vps.status === want) break;
if (vps.status === 'error') throw new Error(vps.error);
await new Promise((ok) => setTimeout(ok, 5000));
}The bash version needs jq.
After a reboot
The status is running before and after, so read uptime, the seconds since the server started, before you send the action, and wait until it is lower.
BEFORE=$(curl -s "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID" -H "Authorization: Bearer $API_TOKEN" | jq .uptime)
curl -s -X POST "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID/action" \
-H "Authorization: Bearer $API_TOKEN" -H "Content-Type: application/json" \
-d '{"action": "reboot"}'
until [ "$(curl -s "https://platform.serverscamp.com/api/v1/vps/$VPS_UUID" -H "Authorization: Bearer $API_TOKEN" | jq '.uptime // 0')" -lt "$BEFORE" ]; do sleep 5; done
echo rebootedA reset is a hardware reset of the running server: it takes effect at once, and the system is usually back within half a minute. Neither the status nor uptime changes, so check your own service, an SSH login or a port, to know it is up.
Errors
| Status | When |
|---|---|
400 | Not one of the five actions |
401 | No token, or a token that is not valid |
402 | Starting needs a day of the plan on the balance |
409 | The server is busy with another task |
422 | The body or a parameter is not what the operation takes |
Every operation can also answer 401 without a valid token. All errors