Tailscale list all devices using api

750 Views Asked by At

I am trying to follow the tailscale documentation to list all devices on my network using exposed API here

In the example it says that I need to provide tailnet name

GET /api/v2/tailnet/example.com/devices
curl 'https://api.tailscale.com/api/v2/tailnet/example.com/devices' \
  -u "tskey-yourapikey123:"

when I replace example.com with my tailnet name I got from DNS tab on my admin page I am getting this error response

403 Forbidden
{
    "message": "user tailnet does not match"
}

I am not sure what I am doing wrong and how shall I get my list of devices to see which of them is online/offline?

1

There are 1 best solutions below

0
On BEST ANSWER

The name that's displayed on the DNS settings page is for hostnames (it's of the form something.ts.net), it is not meant for API calls.

The tailnet name for API calls is the identifier for your user (for single-person tailnets) or domain -- it't shown on the General settings page as the "Organization".

Even simpler, you can use - as a shorthand for the requesting user's default tailnet. The documentation covers some of this, but it could be made clearer.