How to restore droplet with R pulmber API running?

I have created a Rstudio droplet with a plumber API under the user ‘rtest’ at location ‘/home/test/api.R’. I have taken a snapshot of this droplet. Now I am trying to restore the droplet using digital ocean API and run the command to start the plumber API. The following steps need to be done to run the API:

  1. Restore the droplet
  2. LogIn as “rtest” with credentials
  3. Change directory to "/home/rtest/
  4. Execute command “Rscript api.R”

How can I accomplish this? Or I need to do something else?

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.


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":"","region":"nyc3","size":"512mb","image": 12345}' \

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:

  1. curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" ""

For more information, you can take a look at the official documentation here:

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 "" \

apt-get -y update
apt-get -y install nginx
export HOSTNAME=$(curl -s
export PUBLIC_IPV4=$(curl -s
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:

Hope that this helps! Regards, Bobby