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

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
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
ok, figured it out! the issue is with formatting the params. it has to be like 'ssh_keys[]': [123] instead of 'ssh_keys': [123].
following up; it also doesnt appear as if using the SSH key fingerprints matters either. for example replacing the above example’s get_key_ids method with:
def get_key_fingerprints(token):
"""
Using ssh_key fingerprints because array of ids seems broken on Digital
Ocean's side?
"""
request = requests.get('https://api.digitalocean.com/v2/account/keys', headers=headers(token))
return list(map(lambda key: key['fingerprint'], request.json()['ssh_keys']))
doesnt effect things either.
also! if you do 'ssh_keys': [] it isnt rejected, but any string or number value (whether valid ids/fingerprints or not!) give the exact same error message. is this because Digital Ocean doesnt want to reveal whether or not youre using a proper ID for security purposes???
Hey friend,
You’ll want to get the ID for the SSH key by listing the keys first: https://developers.digitalocean.com/documentation/v2/#list-all-keys
From there just plug it in like this:
"ssh_keys":[19402414],
Here’s a curl string I just ran, with the API key removed, which did the job:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer [removed]" -d '{"name":"example.com","region":"nyc3","size":"s-1vcpu-1gb","image":"ubuntu-16-04-x64","ssh_keys":[19402414],"backups":false,"ipv6":true,"user_data":null,"private_networking":null,"volumes": null,"tags":["web"]}' "https://api.digitalocean.com/v2/droplets"
Jarland