To create a new volume, send a POST request to /v2/volumes
. Optionally, a filesystem_type
attribute may be provided in order to automatically format the volume’s filesystem. Pre-formatted volumes are automatically mounted when attached to Ubuntu, Debian, Fedora, Fedora Atomic, and CentOS Droplets created on or after April 26, 2018. Attaching pre-formatted volumes to Droplets without support for auto-mounting is not recommended.
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"size_gigabytes": 10,
"name": "ext4-example",
"description": "Block store for examples",
"region": "nyc1",
"filesystem_type": "ext4",
"filesystem_label": "ext4_volume_01"
}
resp = client.volumes.create(body=req)
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.