Skip to content Skip to sidebar Skip to footer

How To Add And Remove Heroku Dynos Through Platform Api

I want to add and remove Heroku Dynos through platform API Just like we do ps:scale web=0 in Heroku toolbelt CLI. I have already tried POST /apps/{app_id_or_name}/dynos/{dyno_id_o

Solution 1:

As per the dyno stop ps:stop behavior outlined in this question:

Running ps:stop on dynos that are part of a scaled process will automatically be restarted. In Private Spaces, ps:stop will terminate and replace the dedicated instance running the dyno(s). To permanently stop dynos, scale down the process."

To scale down the dynos to 0 through the Platform API, you'll need to use formation API.

Formation List:

GET /apps/{app_id_or_name}/formation

$ curl -n https://api.heroku.com/apps/$APP_ID_OR_NAME/formation \
  -H "Accept: application/vnd.heroku+json; version=3"

Formation Update:

PATCH /apps/{app_id_or_name}/formation/{formation_id_or_type}

$ curl -n -X PATCH https://api.heroku.com/apps/$APP_ID_OR_NAME/formation/$FORMATION_ID_OR_TYPE \
  -d '{
  "quantity": 1,
  "size": "standard-1X"
}' \
  -H "Content-Type: application/json" \
  -H "Accept: application/vnd.heroku+json; version=3"

Sending quantity = 0 as a parameter will scale the dyno process to zero.

Post a Comment for "How To Add And Remove Heroku Dynos Through Platform Api"