Programmatically remove a host?

Is this possible to do through the API?

I would like to run a script on shutdown for spot instances to hit the API to deactivate, remove and purge the host but I can’t think of a good way to actually get the ID of the host that is going down.

I saw the meetup video and blog post for spotinst where they set the host label to the instance id here http://blog.spotinst.com/2015/11/26/rancher-spotinst-integration/ but don’t know how to use that info.

How would I accomplish this? Is it even possible right now?

It’s been awhile since I posted this but I still haven’t found a good way to handle this. Is there a good way to accomplish what I’m trying to do?