Cloud Panel

Create a VM

POST/api/v1/vms

Creates a server and starts it, usually in about a minute; poll Get a VM until its status is active. You log in as scamp, with sudo, with the SSH key, the password or both. With assign_public_ips the server gets a public IPv4 and IPv6 once it is up. The first hour is charged at once and then every hour after it. Send an Idempotency-Key header to retry safely: the same key within 24 hours answers with the same server instead of making a second one.

Parameters

NameInDescription
Idempotency-Keyheader, string, optionalAny string of yours, up to 200 characters. The same key within 24 hours answers with the server the first request made instead of making a second one.

Request body

FieldTypeDescription
display_namestring, optionalName of the server, up to 100 characters
vm_class_idintegerrequiredPlan id, from List plans
storage_class_idintegerrequiredDisk id of the root disk, from List disks
vm_template_idinteger, optionalImage id, from List images. Give this, or source_snapshot_id or source_backup_id
source_snapshot_idstring, optionalMake the server from a snapshot of another one
source_backup_idstring, optionalMake the server from a backup
network_uuidstringrequiredPrivate network, from List networks
sg_uuidstring, optionalSecurity group, from List security groups; the default group of the account when left out
ssh_key_idinteger, optionalSSH key of the scamp user, from List SSH keys
disk_gbintegerrequiredRoot disk size, GB. The first 25 GB of a standard disk are free
os_passwordstring, optionalPassword of the scamp user, 8 to 64 characters; generated and returned when left out
assign_public_ipsbooleanGive the server a public IPv4 and IPv6 address. The network has to be on a router
tagsmap of string, optionalYour tags, up to 10: key up to 64 characters, value up to 256
monitoringboolean, optionalThe guest agent and monitoring; on when left out. Disk auto-extend needs them
autoextendVMAutoextendIn, optionalGrow the root disk and its filesystem before it fills up
autoextend.enabledbooleanAuto-extend on
autoextend.at_pctintegerGrow when the root filesystem is this full, percent
autoextend.step_pctintegerGrow by this share of the current disk size: 10, 20, 30 or 50 percent. Rounded to 5 GB, at least 5 GB.
autoextend.max_gbintegerrequiredNever grow the disk past this size, GB
user_datastring, optionalcloud-init user data: #cloud-config or a script starting with #!, up to 64 KB. Runs once at first boot, after the platform's own setup

Example request

curl -X POST "https://platform.serverscamp.com/api/v1/vms" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "web-1",
    "vm_class_id": 49,
    "vm_template_id": 5,
    "storage_class_id": 18,
    "disk_gb": 50,
    "network_uuid": "a3e1f0c2-7d4b-4c6e-8f9a-0b1c2d3e4f50",
    "ssh_key_id": 42,
    "assign_public_ips": true
  }'

Answer

Status 201 with this body.

FieldTypeDescription
vm_uuidstringrequiredServer id
display_namestring, optionalThe name you gave
statusstringrequiredAlways queued: poll Get a VM until status is active
os_userstringrequiredUser to log in as: scamp, with sudo
os_passwordstringrequiredIts password, yours or generated
{
  "vm_uuid": "6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34",
  "display_name": "web-1",
  "status": "queued",
  "os_user": "scamp",
  "os_password": "Rk7vQ2mXp9LwT4sN"
}

Wait until it is ready

The answer comes at once and the server is made in the background, usually in about a minute. Get a VM shows how far it got in its status field.

Check the status

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

curl "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" \
  -H "Authorization: Bearer $API_TOKEN"
statusWhat it means
pendingThe server is being made: the disk, the network and the system
activeReady. SSH answers once the system has booted, a few seconds later
failedSomething went wrong; the error field says what. Delete the server and create it again

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
while true; do
  VM=$(curl -s "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" -H "Authorization: Bearer $API_TOKEN")
  STATUS=$(echo "$VM" | jq -r .status)
  echo "$STATUS"
  [ "$STATUS" = active ] && break
  case "$STATUS" in failed|error) echo "$VM" | jq -r .error; exit 1;; esac
  sleep 5
done
curl -s "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" -H "Authorization: Bearer $API_TOKEN" | jq -r '"ssh scamp@" + .network.public_ip_v4'

The bash version needs jq.

Errors

StatusWhen
400A plan, disk, size or value that is not accepted, or a public address on a network without a router
401No token, or a token that is not valid
402The balance is too low
403The server limit of the account is reached
404No such network or SSH key in your account
409The plan has no free capacity right now
422The body or a parameter is not what the operation takes

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