Create / Destroy servers using Vultr API

Vultr is an excellent VPS provider. It is giving a tough competition to Digital Ocean.

Vultr provides a nice set of APIs to provision the VPS.


These are REST API's and you can use any programming language to use the API.
Get the API key at https://my.vultr.com/settings/#settingsapi

Make sure you white list the IPs for API access.

Below are few scripts created in PHP which shows how easy it is to interact with vultr APIs

a) Create a server from snapshot and add a tag to it.



Replace the API_KEY with your key and mention the snapshot id. (This is visible when you open the snapshot details from portal).
For normal OS, find the relevant OSID.

To get all available OS ID's visit https://api.vultr.com/v1/os/list

b) Destroy all servers having specific tag.

We first get all available servers in our account.
Then loop into each server, check if the tag matches with the one we want and delete that server instance.



Replace tagname and API_KEY

About This Blog

There is something for everyone. !! A tech blog on various topics. Let it be devops, programming etc; we have it all covered here in layman terms :)

Total Pageviews

Back to TOP