Cloud Panel

Start, stop, reboot

POST/api/v1/vms/{vm_uuid}/power

start boots a stopped server, shutdown turns the system off cleanly and destroy cuts the power. reboot restarts the system cleanly, reset works like the reset button. A stopped server is still billed for its plan.

Parameters

NameInDescription
vm_uuidpath, stringrequiredServer id, from Create a VM or List VMs

Request body

FieldTypeDescription
actionstringrequiredstart, shutdown (clean), destroy (power off), reboot (clean) or reset (hard)

Example request

curl -X POST "https://platform.serverscamp.com/api/v1/vms/$VM_UUID/power" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "reboot"
  }'

Answer

Status 200 with this body.

FieldTypeDescription
vm_uuidstringrequired
actionstringrequiredThe action sent to the server
statusstringrequiredpower_control_queued: watch state in Get a VM
{
  "vm_uuid": "6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34",
  "action": "reboot",
  "status": "power_control_queued"
}

Wait until it is ready

The answer comes at once and the action runs in the background. Get a VM shows the power state in state, and pending_op while the action still runs.

Check the status

Ask Get a VM with the server's id; the field to watch is state:

curl "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" \
  -H "Authorization: Bearer $API_TOKEN"
stateWhat it means
runningUp, after start, reboot or reset
stoppedOff, after shutdown or destroy

Wait in a loop

Ask every few seconds until it gets there, and stop on an error.

# VM_UUID: vm_uuid of the server, from the answer above
WANT=running   # stopped after shutdown or destroy
while true; do
  VM=$(curl -s "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" -H "Authorization: Bearer $API_TOKEN")
  STATE=$(echo "$VM" | jq -r .state)
  echo "$STATE"
  [ "$STATE" = "$WANT" ] && [ "$(echo "$VM" | jq .pending_op)" = null ] && break
  sleep 5
done

The bash version needs jq.

A reboot and a reset end where they started, running, so the loop ends at once for them. Check your own service, an SSH login or a port, to know the system is back.

Errors

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

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