Sign up

Start, stop, reboot

POST/api/v1/vps/{vps_uuid}/action

start boots a stopped server. shutdown asks the system to stop and stop powers it off at once. reboot asks the system to restart and reset restarts it at once. In the first minute after a create or a reinstall the system is still setting itself up and may not take a shutdown or a reboot; send it again a little later, or use stop or reset.

Parameters

NameInDescription
vps_uuidpath, stringrequiredVPS id, from Create a VPS or List VPS

Request body

FieldTypeDescription
actionstringrequiredstart | 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"
  }'

Answer

Status 200 with this body.

FieldTypeDescription
vps_uuidstringrequired
actionstringrequiredThe 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
}
statusWhat it means
runningUp, after start, reboot or reset
stoppedOff, after shutdown or stop
errorSomething 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

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 rebooted

A 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

StatusWhen
400Not one of the five actions
401No token, or a token that is not valid
402Starting needs a day of the plan on the balance
409The server is busy with another task
422The body or a parameter is not what the operation takes

Every operation can also answer 401 without a valid token. All errors