We have a use case where we need to keep the droplet running for a time period i.e. 8 am to 5 pm. The droplet should be stopped out of these working hours.

Currently we are doing manually. Is there any way to automate this?

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
2 answers

Hi @speedo1947,

I’ll suggest giving the DigitalOcean API a look:


You can use the following CURL Post request:

curl -X POST -H "Content-Type: application/json" \
             -H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" \
             -d '{"type":"power_off"}'  \ 

Just remember to replace b7d03a6947b217efb6f3ec3bd3504582 with your own API token and 3164450 with your Droplet’s ID.

Ofcourse, when you want to start the droplet, replace power_off with power_on.

  • Hi @speedo1947,

    Excuse me for the second reply.

    Now, once you have the above action, you just need to setup a cronjob to be executed once a day to power the droplet off and on in the specified timeframe.

    The cronjob needs to be used on a machine that’s constantly online otherwise it might miss the set times.

Hi there,

In addition to what has already been mentioned, here are a few examples of how to use the DigitalOcean API with different types of programming languages:


The example is with a reboot, but you can change this to power_off and power_on accordingly.