Servers: Remove A Server Programmatically

This article is intended to help you leverage Stackify’s API by making a REST service call to programmatically remove Retrace instances from the Servers page of Retrace. To see how to remove servers from the Retrace portal, see the “How Do I Remove a Server” article.

Below are the REST calls to the API for both Windows and Linux machines that can be added to shutdown scripts of your server.

Removing Windows Servers

Plug in your API key found in the Settings page of your account and run the call as a Power Shell script:

Invoke-RestMethod -Method POST -Header @{ "X-Stackify-Key" = "license_key_here" } -uri https://api.stackify.com/API/Device/RemoveServerByName/?name=$env:computername 

Note: The $env:computername variable makes an assumption of what your computer name is. There may be cases where you may need to manually set the computer name: /?name=your_server_name

Removing Linux Servers

curl -X POST -i -H "X-Stackify-Key: license_key_here" -H "Content-Length: 0" https://api.stackify.com/API/Device/RemoveServerByName/?name=hostname

Using hostname makes an assumption of what your computer name is. There may be cases where you may need to manually set the computer name: /?name=your_server_name

After making the REST call, you should see your instances removed from the Servers page in your Retrace account almost immediately.