Delete a volume
DELETE/api/v1/volumes/{disk_uuid}
Deletes the volume and its data. Detach it first. Billing stops at once; Get a volume answers 404 once it is gone.
Parameters
| Name | In | Description |
|---|---|---|
| disk_uuid | path, stringrequired | Volume id, from Create a volume or List volumes |
Example request
curl -X DELETE "https://platform.serverscamp.com/api/v1/volumes/$DISK_UUID" \
-H "Authorization: Bearer $API_TOKEN"import os, requests
token = os.environ["API_TOKEN"]
disk_uuid = "c7a1e3f9-52b8-4d06-9e41-8b3f2a6d0c75"
r = requests.delete(
f"https://platform.serverscamp.com/api/v1/volumes/{disk_uuid}",
headers={"Authorization": f"Bearer {token}"},
)
r.raise_for_status()
print(r.json())const diskUuid = 'c7a1e3f9-52b8-4d06-9e41-8b3f2a6d0c75';
const r = await fetch(`https://platform.serverscamp.com/api/v1/volumes/${diskUuid}`, {
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": "Volume deletion started"
}Wait until it is ready
The answer comes at once. Get a volume answers 404 once the volume is gone.
Check the state
Ask Get a volume with the volume's id. After the delete it answers 404.
curl "https://platform.serverscamp.com/api/v1/volumes/$DISK_UUID" \
-H "Authorization: Bearer $API_TOKEN"Wait in a loop
Ask every few seconds until the answer is 404.
# DISK_UUID: disk_uuid of the volume, from the answer above
until [ "$(curl -s -o /dev/null -w '%{http_code}' \
"https://platform.serverscamp.com/api/v1/volumes/$DISK_UUID" -H "Authorization: Bearer $API_TOKEN")" = 404 ]; do
sleep 5
done
echo deleted# disk_uuid: disk_uuid of the volume, 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/volumes/{disk_uuid}", headers=headers).status_code != 404:
time.sleep(5)
print("deleted")// diskUuid: disk_uuid of the volume, from the answer above
const headers = { Authorization: `Bearer ${process.env.API_TOKEN}` };
while ((await fetch(`https://platform.serverscamp.com/api/v1/volumes/${diskUuid}`, { headers })).status !== 404) {
await new Promise((ok) => setTimeout(ok, 5000));
}
console.log('deleted');Errors
| Status | When |
|---|---|
400 | The volume is attached; detach it first |
401 | No token, or a token that is not valid |
404 | No such volume in your account |
409 | The volume is busy |
422 | The body or a parameter is not what the operation takes |
Every operation can also answer 401 without a valid token. All errors