To create a new Droplet, send a POST request to /v2/droplets
setting the
required attributes.
A Droplet will be created using the provided information. The response body
will contain a JSON object with a key called droplet
. The value will be an
object containing the standard attributes for your new Droplet. The response
code, 202 Accepted, does not indicate the success or failure of the operation,
just that the request has been accepted for processing. The actions
returned
as part of the response’s links
object can be used to check the status
of the Droplet create event.
Creating multiple Droplets is very similar to creating a single Droplet.
Instead of sending name
as a string, send names
as an array of strings. A
Droplet will be created for each name you send using the associated
information. Up to ten Droplets may be created this way at a time.
Rather than returning a single Droplet, the response body will contain a JSON
array with a key called droplets
. This will be set to an array of JSON
objects, each of which will contain the standard Droplet attributes. The
response code, 202 Accepted, does not indicate the success or failure of any
operation, just that the request has been accepted for processing. The array
of actions
returned as part of the response’s links
object can be used to
check the status of each individual Droplet create event.
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"name": "example.com",
"region": "nyc3",
"size": "s-1vcpu-1gb",
"image": "ubuntu-20-04-x64",
"ssh_keys": [
289794,
"3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45"
],
"backups": True,
"ipv6": True,
"monitoring": True,
"tags": [
"env:prod",
"web"
],
"user_data": "#cloud-config\nruncmd:\n - touch /test.txt\n",
"vpc_uuid": "760e09ef-dc84-11e8-981e-3cfdfeaae000"
}
resp = client.droplets.create(body=req)
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.