Automatically add new or restored droplet to digital ocean dns

If I own and configured, I would like for all new droplets to be added on as second level domain. For example, if a new droplet called dev, could it not be automatically added as

I can see this questions: but it is three years old. Has anything been developed since then?

Regards, Analytium

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.

To follow on what @MichaelOjeda said, once you have an API Token, the curl request to add a domain via the API is:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer APITOKEN" -d '{"name":"","ip_address":""}' ""

For NEW droplets, you can automate this by pasting a user-data cloud-config script in the User Data field on the Droplet Create page:

  - export DROPLET_NAME=$(curl -s
  - export DROPLET_IP=$(curl -s
  - 'curl -X POST -H ''Content-Type: application/json'' -d ''{"name":"''"$DROPLET_NAME"''", "ip_address":"''"$DROPLET_IP"''"}'' -H "Authorization: Bearer API_TOKEN"'

replace and API_TOKEN

The #cloud-config line specifies that you are using cloud-init language (which interprets this as YAML), runcmd: specifies that the following lines should be run in shell when server first starts.

The two export lines set the droplet’s IP address and name as environment variables, and the final line makes the HTTP request to create a new domain via the API.

(All the extra quotation marks are due to making YAML and JSON play nice together)

This is possible, but you would need to do it through the API. There isn’t (and probably will never be) a option to do this in the portal. Here’s the link to the documentation: