# Programmatically remove a host?

**URL:** <https://forums.suse.com/t/programmatically-remove-a-host/2821>\
**Category:** Rancher 1.x\
**Created:** [May 17, 2016, 6:11am UTC](https://forums.suse.com/t/programmatically-remove-a-host/2821 "2016-05-17T06:11:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmreicha](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/jmreicha/32/444_2.png) [@jmreicha](https://forums.suse.com/u/jmreicha)\
**Post date:** [May 17, 2016, 6:11am UTC](https://forums.suse.com/t/programmatically-remove-a-host/2821/1 "2016-05-17T06:11:23Z")

</div>

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/](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?

---

<div class="post-metadata">

**Author:** ![jmreicha](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/jmreicha/32/444_2.png) [@jmreicha](https://forums.suse.com/u/jmreicha)\
**Post date:** [June 2, 2016, 10:01pm UTC](https://forums.suse.com/t/programmatically-remove-a-host/2821/2 "2016-06-02T22:01:55Z")

</div>

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?
