Hello,
You could use the following request to generate your new Droplet:
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer $TOKEN' -d \
'{"name":"example.com","region":"nyc3","size":"512mb","image": 12345}' \
"https://api.digitalocean.com/v2/droplets"
You need to change the details so that they match your requirements, and also you need to change the image ID with your snapshot ID as well.
In case that you need to get your image ID, you can do it with this request:
- curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" "https://api.digitalocean.com/v2/images?page=1&per_page=1&private=true"
For more information, you can take a look at the official documentation here:
https://www.digitalocean.com/community/questions/how-to-create-a-droplet-using-snapshot-with-digitalocean-api
In case that you wanted to run some specific commands, you could also pass user data to your API request like this:
curl -X POST "https://api.digitalocean.com/v2/droplets" \
-d'{"name":"metadata.example.com","region":"nyc3","size":"s-1vcpu-1gb","vpc_uuid":"c33931f2-a26a-4e61-b85c-4e95a2ec431b","image":"ubuntu-20-04-x64","user_data":
"#!/bin/bash
apt-get -y update
apt-get -y install nginx
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
echo Droplet: $HOSTNAME, IP Address: $PUBLIC_IPV4 > /usr/share/nginx/html/index.html",
"ssh_keys":[ < SSH KEY IDs > ]}' \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"
For more information on user data you can take a look at the following documentation:
https://www.digitalocean.com/docs/droplets/how-to/provide-user-data/
Hope that this helps!
Regards,
Bobby