Delete a VM
DELETE/api/v1/vms/{vm_uuid}
Deletes the server and its root disk. Its public and floating addresses go back, attached volumes are detached and kept, and backups and snapshots are kept unless you ask to delete them too. Billing for the server stops at once; Get a VM shows status deleting and then answers 404.
Parameters
| Name | In | Description |
|---|---|---|
| vm_uuid | path, stringrequired | Server id, from Create a VM or List VMs |
| delete_backups | query, boolean | Delete the server's backups too; kept when left out |
| delete_snapshots | query, boolean | Delete the server's snapshots too; kept when left out |
| delete_volumes | query, boolean | Delete the volumes attached to it too; they are detached and kept when left out |
Example request
curl -X DELETE "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" \
-H "Authorization: Bearer $API_TOKEN"import os, requests
token = os.environ["API_TOKEN"]
vm_uuid = "6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34"
r = requests.delete(
f"https://platform.serverscamp.com/api/v1/vms/{vm_uuid}",
headers={"Authorization": f"Bearer {token}"},
)
r.raise_for_status()
print(r.json())const vmUuid = '6f1c2a9e-4b3d-4e8a-9c71-2d5e8f0a1b34';
const r = await fetch(`https://platform.serverscamp.com/api/v1/vms/${vmUuid}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
});
console.log(r.status, await r.json());Answer
Status 200 with this body.
| Field | Type | Description |
|---|---|---|
| success | booleanrequired | |
| message | stringrequired |
{
"success": true,
"message": "VM deletion queued"
}Wait until it is ready
The answer comes at once. Get a VM shows status deleting while the server and its disk are removed, and then answers 404.
Check the status
Ask Get a VM with the server's id. After the delete it answers 404.
curl "https://platform.serverscamp.com/api/v1/vms/$VM_UUID" \
-H "Authorization: Bearer $API_TOKEN"Wait in a loop
Ask every few seconds until the answer is 404.
# VM_UUID: vm_uuid of the server, from the answer above
until [ "$(curl -s -o /dev/null -w '%{http_code}' \
"https://platform.serverscamp.com/api/v1/vms/$VM_UUID" -H "Authorization: Bearer $API_TOKEN")" = 404 ]; do
sleep 5
done
echo deleted# vm_uuid: vm_uuid of the server, from the answer above
import os, time, requests
headers = {"Authorization": f"Bearer {os.environ['API_TOKEN']}"}
while requests.get(f"https://platform.serverscamp.com/api/v1/vms/{vm_uuid}", headers=headers).status_code != 404:
time.sleep(5)
print("deleted")// vmUuid: vm_uuid of the server, from the answer above
const headers = { Authorization: `Bearer ${process.env.API_TOKEN}` };
while ((await fetch(`https://platform.serverscamp.com/api/v1/vms/${vmUuid}`, { headers })).status !== 404) {
await new Promise((ok) => setTimeout(ok, 5000));
}
console.log('deleted');Errors
| Status | When |
|---|---|
401 | No token, or a token that is not valid |
404 | No such server in your account |
409 | The server is busy with another operation |
422 | The body or a parameter is not what the operation takes |
Every operation can also answer 401 without a valid token. All errors