Although removing hosts from SSH Professional is straightforward using both the CLI and Dashboard, there are cases where it is more efficient to remove them in bulk programmatically through the API.
Here's how to unregister an SSH host using the Smallstep Customer API.
There are two main API requests that you need to perform.
First, you need to retrieve the host object to gather important properties like the host UUID (also known as hostId). To begin with, retrieve a list of all hosts and then parse through the response to identify the hosts that you want to unregister.
Once you have the desired hostId values, you can use them to initiate the unregister call.
It's important to note that the unregister call does not accept arrays of hostIds. Therefore, you will need to iterate through a list of hostIds and make the unregister call for each one until all of your desired hosts have been successfully unregistered.
Don't have an API token? Here's how to get access.