Question

How to create a droplet from a snapshot through API?

Posted February 27, 2015 3k views

Everything is in the title....

I have a snapshot named dev-box, when I try to do the following, I get an error:

curl -s -X POST -d '{
>   "name": "dev",
>   "region": "ams2",
>   "size": "8gb",
>   "image": "dev-box",
>   "ssh_keys": [],
>   "backups": false,
>   "ipv6": false,
>   "user_data": null,
>   "private_networking": null
> }' -H 'Content-Type: application/json' -H 'Authorization: Bearer token' https://api.digitalocean.com/v2/droplets
{"id":"unprocessable_entity","message":"You specified an invalid image for Droplet creation."}

What am I doing wrong?

Thanks

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.

×
2 answers

The image variable when creating a droplet expects an image id, not an image name. You will need to first hit the images endpoint in order to get the ID for the image you wish to use.

Thanks for your help. Will add needed call to retrieve image id then!

regards,

Submit an Answer