How to create a droplet from a snapshot through API?

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'
{"id":"unprocessable_entity","message":"You specified an invalid image for Droplet creation."}

What am I doing wrong?


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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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!