I want to know if there is an endpoint that I could use to remove a device by its hostname.
For example, I have a terraform script with Cloudinit which adds a VPS to Tailscale and works perfectly fine. However, I want to destroy the VM simultaneously without going to Tailscale's admin console to remove it.
Is an API for that?
The API for deleting a node from the tailnet is documented here: https://github.com/tailscale/tailscale/blob/main/api.md#delete-device
It seems like you are describing the behavior of an ephemeral node, so here is some information about how to leverage that feature in case it is helpful to you or others:
Ephemeral Auth Keys
If the auth key you're using to add the node is configured as Ephemeral, the node will eventually disappear after a period of inactivity or it will disappear immediately if you use
tailscale logout
.Ephemeral
tailscaled
state(If you're using version >=1.22)
Another option is to use
--state=mem:
as a flag fortailscaled
(note, this is not atailscale
CLI flag, it is a flag for the daemon itself). Using memory state will mark the machine as ephemeral as well.From the help output: