Droplet create - user data not executed

Posted April 30, 2020 583 views

I’m trying to create a droplet and adding a code (in this case a hardcoded ‘saraza’) to a file for later purposes. This code will change from droplet to droplet so I needed parametrized. But when I execute this, no file is created in my droplet. I’ve seen another questions that said that this is the way to do this.

curl -v -X POST “” \
-d’{“name”:“My-Droplet”,“region”:“nyc3”,“size”:“s-1vcpu-1gb”,“image”:“ubuntu-18-04-x64”, “sshkeys”: [“’$SSHPUBLICKEYDOFORMAT’”], “userdata”: “`#cloud-config

  • echo saraza > ~/file.txt`”}’ \ -H “Authorization: Bearer $DOAPITOKEN” \ -H “Content-Type: application/json”)

Thanks for the help

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.

Submit an Answer
1 answer

Hello, @dseidler

I will recommend you to check our official docs for the User Data:

As shown in the example in the article you can simply create a bash script that will execute the command you want after the droplet creation.

curl -X POST "" \

echo saraza > ~/file.txt
      -H "Authorization: Bearer $TOKEN" \
      -H "Content-Type: application/json"

You can try with the example above and see if it works for you.

Note: You can also check the output logs and see what happened when the startup script tried to run the user-data

The log is located here:


Let me know how it goes.