API V2: You specified an invalid image for Droplet creation. Why?

April 29, 2018 537 views

I'm setting up an automated droplet creation process in Laravel for an automated deployment setup package I'm making for myself. But for reasons I can't figure out, I keep getting the error: "You specified an invalid image for Droplet creation.", when I try to actually create the droplet. I can't determine if this is a shortcoming of the API, or a flaw in my own logic.

Currently, the process flow looks like this:

  1. Ask the user to select a droplet size. These are retrieved from the API, not hardcoded, and filtered to ones where available is true.
  2. Ask the user to select an image. These are also retrieved from the API (distribution images only), and filtered to ones where the image min_disk_size is greater than or equal to the selected disk size.
  3. Ask the user to select a region. These are also retrieved from the API, and filtered to regions that are in the selected size's array of regions and in the selected image's array of regions.

In other words, by the time a region is chosen, I have what should be, in my mind, a perfectly valid selection of droplet size, image, and region. Some other input occurs, like droplet name and SSH keys, and then I post the information. But I consistently get the error that my chosen image is invalid, every time.

I've tried multiple combinations of regions, images, and sizes, and I've tried posting the image as both the slug and the ID. So far, no change in behaviour.

I've seen this question: https://www.digitalocean.com/community/questions/api-v2-you-specified-an-invalid-image-for-droplet-creation, and it seems like their issue was - annoyingly - that the API just wouldn't work the first few calls, and would need to be called multiple times. This was 3ish years ago now. I certainly hope the issue hasn't remained unresolved this whole time.

Any thoughts on what could be going wrong here? Is there additional 'validation' logic of which image is valid for which region/droplet combination that the API won't give me? I really don't want to hardcode any values, as I should be able to obtain valid selections purely through the API.

For reference, here's an example of what I'm posting to the API:

    'name' => 'Testing',
    'region' => 'nyc1',
    'size' => '512mb',
    'image' => 'ubuntu-14-04-x64',
    'ssh_keys' => [
        0 => 'key_id'
    'backups' => true,
    'tags' => [
        0 => 'Tag 1'
1 Answer

I am not seeing anything wrong with the format of your request (your example would fail since we no longer offer a 512MB droplet size).

When retrieving the images from the API are you then using the image ID or the image slug as shown in your example for the request? Can you share an example of a request that failed with the values provided?

Have another answer? Share your knowledge.