Question

How do I create a Droplet using a Snapshot using v2 API?

Hi, I’ve created a shapshot for one of my droplets and can see it being retrieved using the a private Image: URL: https://api.digitalocean.com/v2/images?private=true Response:

{
    "images": [
        {
            "id": 34127022,
            "name": "sc-sh-foundation",
            "distribution": "CentOS",
            "slug": null,
            "public": false,
            "regions": [
                "sfo2"
            ],
            "created_at": "2018-05-07T09:42:19Z",
            "min_disk_size": 80,
            "type": "snapshot",
            "size_gigabytes": 10.78
        }
    ],
    "links": {},
    "meta": {
        "total": 1
    }
}

But when I try to create a droplet with the image id I get an error. URL: https://api.digitalocean.com/v2/droplets Request:

{
  "name": "sc-sh-isccs",
  "region": "sfo2",
  "size": 109,
  "image": 34127022,
  "ssh_keys": [20594886],
  "backups": false,
  "ipv6": false,
  "user_data": null,
  "private_networking": null,
  "volumes": null,
  "tags":["sterling","isccs"]
}

Response:

{
    "id": "unprocessable_entity",
    "message": "You specified an invalid image for Droplet creation."
}

Can you please guide on what the issue could be?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Thank you, I was able to identify the issue. I was sending the size as an integer id instead of a slug value. I was able to correct the request and create the droplet using the following request:

{
  "name": "sc-sh-isccs-001",
  "region": "sfo2",
  "size": "s-2vcpu-4gb",
  "image": 34127022,
  "ssh_keys": [20594886],
  "backups": false,
  "ipv6": false,
  "user_data": null,
  "private_networking": null,
  "volumes": null,
  "tags":[
	"sterling",
	"isccs"
	]
}
Ryan Quinn
DigitalOcean Employee
DigitalOcean Employee badge
May 7, 2018

I don’t immediately see anything wrong with the snippets you provided. One thing to note is that a snapshot can only be used in the datacenter where it was created unless you first make it available in a new region. The error you’re seeing is the message that would be returned if you selected a region/datacenter where the image has not been propagated.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.