pydo.droplets.create()

Description

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.

Create Multiple Droplets

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.

Request Sample

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)

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

Accepted

Click to expand an example response for Single Droplet Create Response.
{
  "value": {
    "droplet": {
      "id": 3164444,
      "name": "example.com",
      "memory": 1024,
      "vcpus": 1,
      "disk": 25,
      "disk_info": [
        {
          "type": "local",
          "size": {
            "amount": 25,
            "unit": "gib"
          }
        }
      ],
      "locked": false,
      "status": "new",
      "kernel": null,
      "created_at": "2020-07-21T18:37:44Z",
      "features": [
        "backups",
        "private_networking",
        "ipv6",
        "monitoring"
      ],
      "backup_ids": [],
      "next_backup_window": null,
      "snapshot_ids": [],
      "image": {
        "id": 63663980,
        "name": "20.04 (LTS) x64",
        "distribution": "Ubuntu",
        "slug": "ubuntu-20-04-x64",
        "public": true,
        "regions": [
          "ams2",
          "ams3",
          "blr1",
          "fra1",
          "lon1",
          "nyc1",
          "nyc2",
          "nyc3",
          "sfo1",
          "sfo2",
          "sfo3",
          "sgp1",
          "tor1"
        ],
        "created_at": "2020-05-15T05:47:50Z",
        "type": "snapshot",
        "min_disk_size": 20,
        "size_gigabytes": 2.36,
        "description": "",
        "tags": [],
        "status": "available",
        "error_message": ""
      },
      "volume_ids": [],
      "size": {
        "slug": "s-1vcpu-1gb",
        "memory": 1024,
        "vcpus": 1,
        "disk": 25,
        "transfer": 1,
        "price_monthly": 5,
        "price_hourly": 0.00743999984115362,
        "regions": [
          "ams2",
          "ams3",
          "blr1",
          "fra1",
          "lon1",
          "nyc1",
          "nyc2",
          "nyc3",
          "sfo1",
          "sfo2",
          "sfo3",
          "sgp1",
          "tor1"
        ],
        "available": true,
        "description": "Basic"
      },
      "size_slug": "s-1vcpu-1gb",
      "networks": {
        "v4": [],
        "v6": []
      },
      "region": {
        "name": "New York 3",
        "slug": "nyc3",
        "features": [
          "private_networking",
          "backups",
          "ipv6",
          "metadata",
          "install_agent",
          "storage",
          "image_transfer"
        ],
        "available": true,
        "sizes": [
          "s-1vcpu-1gb",
          "s-1vcpu-2gb",
          "s-1vcpu-3gb",
          "s-2vcpu-2gb",
          "s-3vcpu-1gb",
          "s-2vcpu-4gb",
          "s-4vcpu-8gb",
          "s-6vcpu-16gb",
          "s-8vcpu-32gb",
          "s-12vcpu-48gb",
          "s-16vcpu-64gb",
          "s-20vcpu-96gb",
          "s-24vcpu-128gb",
          "s-32vcpu-192g"
        ]
      },
      "tags": [
        "web",
        "env:prod"
      ]
    },
    "links": {
      "actions": [
        {
          "id": 7515,
          "rel": "create",
          "href": "https://api.digitalocean.com/v2/actions/7515"
        }
      ]
    }
  }
}
Click to expand an example response for Multiple Droplet Create Response.
{
  "value": {
    "droplets": [
      {
        "id": 3164444,
        "name": "sub-01.example.com",
        "memory": 1024,
        "vcpus": 1,
        "disk": 25,
        "disk_info": [
          {
            "type": "local",
            "size": {
              "amount": 25,
              "unit": "gib"
            }
          }
        ],
        "locked": false,
        "status": "new",
        "kernel": null,
        "created_at": "2020-07-21T18:37:44Z",
        "features": [
          "backups",
          "private_networking",
          "ipv6",
          "monitoring"
        ],
        "backup_ids": [],
        "next_backup_window": null,
        "snapshot_ids": [],
        "image": {
          "id": 63663980,
          "name": "20.04 (LTS) x64",
          "distribution": "Ubuntu",
          "slug": "ubuntu-20-04-x64",
          "public": true,
          "regions": [
            "ams2",
            "ams3",
            "blr1",
            "fra1",
            "lon1",
            "nyc1",
            "nyc2",
            "nyc3",
            "sfo1",
            "sfo2",
            "sfo3",
            "sgp1",
            "tor1"
          ],
          "created_at": "2020-05-15T05:47:50Z",
          "type": "snapshot",
          "min_disk_size": 20,
          "size_gigabytes": 2.36,
          "description": "",
          "tags": [],
          "status": "available",
          "error_message": ""
        },
        "volume_ids": [],
        "size": {
          "slug": "s-1vcpu-1gb",
          "memory": 1024,
          "vcpus": 1,
          "disk": 25,
          "transfer": 1,
          "price_monthly": 5,
          "price_hourly": 0.00743999984115362,
          "regions": [
            "ams2",
            "ams3",
            "blr1",
            "fra1",
            "lon1",
            "nyc1",
            "nyc2",
            "nyc3",
            "sfo1",
            "sfo2",
            "sfo3",
            "sgp1",
            "tor1"
          ],
          "available": true,
          "description": "Basic"
        },
        "size_slug": "s-1vcpu-1gb",
        "networks": {
          "v4": [],
          "v6": []
        },
        "region": {
          "name": "New York 3",
          "slug": "nyc3",
          "features": [
            "private_networking",
            "backups",
            "ipv6",
            "metadata",
            "install_agent",
            "storage",
            "image_transfer"
          ],
          "available": true,
          "sizes": [
            "s-1vcpu-1gb",
            "s-1vcpu-2gb",
            "s-1vcpu-3gb",
            "s-2vcpu-2gb",
            "s-3vcpu-1gb",
            "s-2vcpu-4gb",
            "s-4vcpu-8gb",
            "s-6vcpu-16gb",
            "s-8vcpu-32gb",
            "s-12vcpu-48gb",
            "s-16vcpu-64gb",
            "s-20vcpu-96gb",
            "s-24vcpu-128gb",
            "s-32vcpu-192g"
          ]
        },
        "tags": [
          "web",
          "env:prod"
        ]
      },
      {
        "id": 3164445,
        "name": "sub-02.example.com",
        "memory": 1024,
        "vcpus": 1,
        "disk": 25,
        "disk_info": [
          {
            "type": "local",
            "size": {
              "amount": 25,
              "unit": "gib"
            }
          }
        ],
        "locked": false,
        "status": "new",
        "kernel": null,
        "created_at": "2020-07-21T18:37:44Z",
        "features": [
          "backups",
          "private_networking",
          "ipv6",
          "monitoring"
        ],
        "backup_ids": [],
        "next_backup_window": null,
        "snapshot_ids": [],
        "image": {
          "id": 63663980,
          "name": "20.04 (LTS) x64",
          "distribution": "Ubuntu",
          "slug": "ubuntu-20-04-x64",
          "public": true,
          "regions": [
            "ams2",
            "ams3",
            "blr1",
            "fra1",
            "lon1",
            "nyc1",
            "nyc2",
            "nyc3",
            "sfo1",
            "sfo2",
            "sfo3",
            "sgp1",
            "tor1"
          ],
          "created_at": "2020-05-15T05:47:50Z",
          "type": "snapshot",
          "min_disk_size": 20,
          "size_gigabytes": 2.36,
          "description": "",
          "tags": [],
          "status": "available",
          "error_message": ""
        },
        "volume_ids": [],
        "size": {
          "slug": "s-1vcpu-1gb",
          "memory": 1024,
          "vcpus": 1,
          "disk": 25,
          "transfer": 1,
          "price_monthly": 5,
          "price_hourly": 0.00743999984115362,
          "regions": [
            "ams2",
            "ams3",
            "blr1",
            "fra1",
            "lon1",
            "nyc1",
            "nyc2",
            "nyc3",
            "sfo1",
            "sfo2",
            "sfo3",
            "sgp1",
            "tor1"
          ],
          "available": true,
          "description": "Basic"
        },
        "size_slug": "s-1vcpu-1gb",
        "networks": {
          "v4": [],
          "v6": []
        },
        "region": {
          "name": "New York 3",
          "slug": "nyc3",
          "features": [
            "private_networking",
            "backups",
            "ipv6",
            "metadata",
            "install_agent",
            "storage",
            "image_transfer"
          ],
          "available": true,
          "sizes": [
            "s-1vcpu-1gb",
            "s-1vcpu-2gb",
            "s-1vcpu-3gb",
            "s-2vcpu-2gb",
            "s-3vcpu-1gb",
            "s-2vcpu-4gb",
            "s-4vcpu-8gb",
            "s-6vcpu-16gb",
            "s-8vcpu-32gb",
            "s-12vcpu-48gb",
            "s-16vcpu-64gb",
            "s-20vcpu-96gb",
            "s-24vcpu-128gb",
            "s-32vcpu-192g"
          ]
        },
        "tags": [
          "web",
          "env:prod"
        ]
      }
    ],
    "links": {
      "actions": [
        {
          "id": 7515,
          "rel": "create",
          "href": "https://api.digitalocean.com/v2/actions/7515"
        },
        {
          "id": 7516,
          "rel": "create",
          "href": "https://api.digitalocean.com/v2/actions/7516"
        }
      ]
    }
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}