pydo.volume_actions.post_by_id()
Generated on 11 Jul 2025
from pydo
version
v0.13.0
Description
To initiate an action on a block storage volume by Id, send a POST request to
~/v2/volumes/$VOLUME_ID/actions
. The body should contain the appropriate
attributes for the respective action.
Attach a Block Storage Volume to a Droplet
Attribute | Details |
---|---|
type | This must be attach |
droplet_id | Set to the Droplet’s ID |
region | Set to the slug representing the region where the volume is located |
Each volume may only be attached to a single Droplet. However, up to fifteen volumes may be attached to a Droplet at a time. Pre-formatted volumes will be automatically mounted to Ubuntu, Debian, Fedora, Fedora Atomic, and CentOS Droplets created on or after April 26, 2018 when attached. On older Droplets, additional configuration is required.
Remove a Block Storage Volume from a Droplet
Attribute | Details |
---|---|
type | This must be detach |
droplet_id | Set to the Droplet’s ID |
region | Set to the slug representing the region where the volume is located |
Resize a Volume
Attribute | Details |
---|---|
type | This must be resize |
size_gigabytes | The new size of the block storage volume in GiB (1024^3) |
region | Set to the slug representing the region where the volume is located |
Volumes may only be resized upwards. The maximum size for a volume is 16TiB.
Parameters
Name | Type | Required | Description | Default Value |
---|---|---|---|---|
volume_id |
string | True | The ID of the block storage volume. | |
per_page |
integer | False | Number of items returned per page | 20 |
page |
integer | False | Which ‘page’ of paginated results to return. | 1 |
body |
JSON or IO[bytes] | True |
Request Sample
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"type": "attach",
"droplet_id": 11612190,
"region": "nyc1",
"tags": [
"aninterestingtag"
]
}
resp = client.volume_actions.post_by_id(volume_id="7724db7c", body=req)
More Information
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.