Cloud Panel

Create a volume

POST/api/v1/volumes

Creates a volume, usually in a few seconds; one from a backup takes longer, by its size. Poll Get a volume until its state is created, then attach it. The volume is billed by the hour for its size, attached or not.

Request body

FieldTypeDescription
display_namestring, optionalName of the volume
size_gbintegerrequiredSize, GB: up to 5,000 on standard, up to 10,000 on enterprise
storage_class_idintegerrequiredDisk id, from List disks
source_snapshot_idstring, optionalMake the volume from a snapshot of another volume
source_backup_idstring, optionalMake the volume from a backup of another volume

Example request

curl -X POST "https://platform.serverscamp.com/api/v1/volumes" \
  -H "Authorization: Bearer $API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "data",
    "size_gb": 100,
    "storage_class_id": 18
  }'

Answer

Status 201 with this body.

FieldTypeDescription
disk_uuidstringrequiredVolume id
display_namestring, optionalThe name you gave
size_gbintegerrequiredSize, GB
statusstringrequiredqueued: poll Get a volume until it is created
{
  "disk_uuid": "c7a1e3f9-52b8-4d06-9e41-8b3f2a6d0c75",
  "display_name": "data",
  "size_gb": 100,
  "status": "queued"
}

Wait until it is ready

The answer comes at once and the work runs in the background, usually for a few seconds. Get a volume shows how far it got in its state field.

Check the state

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

curl "https://platform.serverscamp.com/api/v1/volumes/$DISK_UUID" \
  -H "Authorization: Bearer $API_TOKEN"
stateWhat it means
creatingThe volume is being made; one from a backup also shows provision_phase and provision_pct
createdReady. With vm_uuid set it is attached to that server, without it the volume is free
attaching, detaching, resizingThe change runs
failedSomething went wrong. Write to support with the volume id

Wait in a loop

Ask every few seconds until the state is no longer one of the busy ones, and stop on failed.

# DISK_UUID: disk_uuid of the volume, from the answer above
BUSY=" pending queued creating provisioning attaching attach_queued detaching detach_queued resizing deleting deprovisioning delete_queued "
while true; do
  VOL=$(curl -s "https://platform.serverscamp.com/api/v1/volumes/$DISK_UUID" -H "Authorization: Bearer $API_TOKEN")
  STATE=$(echo "$VOL" | jq -r .state)
  echo "$STATE"
  case "$STATE" in failed|error) echo "volume $STATE"; exit 1;; esac
  case "$BUSY" in *" $STATE "*) ;; *) [ "$(echo "$VOL" | jq -r '.provision_phase // "ready"')" = ready ] && break;; esac
  sleep 5
done

The bash version needs jq.

Errors

StatusWhen
400A disk or size that is not accepted
401No token, or a token that is not valid
402The balance is too low
403The volume limit of the account is reached
404No such snapshot or backup in your account
422The body or a parameter is not what the operation takes

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