</span></code></pre></div><p>Copy the output of the command and save it for later. Please note that you can not retrieve an API key again. If the API key is lost, expire the old one, and create a new one.</p><p>To list the API keys currently associated with the server:</p><divclass="language-shell highlight"><pre><span></span><code><spanid=__span-1-1><aid=__codelineno-1-1name=__codelineno-1-1href=#__codelineno-1-1></a>headscale<spanclass=w></span>apikeys<spanclass=w></span>list
</span></code></pre></div><p>and to expire an API key:</p><divclass="language-shell highlight"><pre><span></span><code><spanid=__span-2-1><aid=__codelineno-2-1name=__codelineno-2-1href=#__codelineno-2-1></a>headscale<spanclass=w></span>apikeys<spanclass=w></span>expire<spanclass=w></span>--prefix<spanclass=w></span><PREFIX>
</span></code></pre></div><h2id=rest-api>REST API<aclass=headerlinkhref=#rest-apititle="Permanent link">¶</a></h2><ul><li>API endpoint: <code>/api/v1</code>, e.g. <code>https://headscale.example.com/api/v1</code></li><li>Documentation: <code>/swagger</code>, e.g. <code>https://headscale.example.com/swagger</code></li><li>Authenticate using HTTP Bearer authentication by sending the <ahref=#api>API key</a> with the HTTP <code>Authorization: Bearer <API_KEY></code> header.</li></ul><p>Start by <ahref=#api>creating an API key</a> and test it with the examples below. Read the API documentation provided by your Headscale server at <code>/swagger</code> for details.</p><divclass="tabbed-set tabbed-alternate"data-tabs=1:3><inputchecked=checkedid=__tabbed_1_1name=__tabbed_1type=radio><inputid=__tabbed_1_2name=__tabbed_1type=radio><inputid=__tabbed_1_3name=__tabbed_1type=radio><divclass=tabbed-labels><labelfor=__tabbed_1_1>Get details for all users</label><labelfor=__tabbed_1_2>Get details for user 'bob'</label><labelfor=__tabbed_1_3>Register a node</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass="language-console highlight"><pre><span></span><code><spanid=__span-3-1><aid=__codelineno-3-1name=__codelineno-3-1href=#__codelineno-3-1></a><spanclass=go>curl -H "Authorization: Bearer <API_KEY>" \</span>
</span></code></pre></div></div></div></div><h2id=grpc>gRPC<aclass=headerlinkhref=#grpctitle="Permanent link">¶</a></h2><p>The gRPC interface can be used to control a Headscale instance from a remote machine with the <code>headscale</code> binary.</p><h3id=prerequisite>Prerequisite<aclass=headerlinkhref=#prerequisitetitle="Permanent link">¶</a></h3><ul><li>A workstation to run <code>headscale</code> (any supported platform, e.g. Linux).</li><li>A Headscale server with gRPC enabled.</li><li>Connections to the gRPC port (default: <code>50443</code>) are allowed.</li><li>Remote access requires an encrypted connection via TLS.</li><li>An <ahref=#api>API key</a> to authenticate with the Headscale server.</li></ul><h3id=setup-remote-control>Setup remote control<aclass=headerlinkhref=#setup-remote-controltitle="Permanent link">¶</a></h3><ol><li><p>Download the <ahref=https://github.com/juanfont/headscale/releases><code>headscale</code> binary from GitHub's release page</a>. Make sure to use the same version as on the server.</p></li><li><p>Put the binary somewhere in your <code>PATH</code>, e.g. <code>/usr/local/bin/headscale</code></p></li><li><p>Make <code>headscale</code> executable: <code>chmod +x /usr/local/bin/headscale</code></p></li><li><p><ahref=#api>Create an API key</a> on the Headscale server.</p></li><li><p>Provide the connection parameters for the remote Headscale server either via a minimal YAML configuration file or via environment variables:</p><divclass="tabbed-set tabbed-alternate"data-tabs=2:2><inputchecked=checkedid=__tabbed_2_1name=__tabbed_2type=radio><inputid=__tabbed_2_2name=__tabbed_2type=radio><divclass=tabbed-labels><labelfor=__tabbed_2_1>Minimal YAML configuration file</label><labelfor=__tabbed_2_2>Environment variables</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass="language-yaml highlight"><spanclass=filename>config.yaml</span><pre><span></span><code><spanid=__span-6-1><aid=__codelineno-6-1name=__codelineno-6-1href=#__codelineno-6-1></a><spanclass=nt>cli</span><spanclass=p>:</span>
</span></code></pre></div></div></div></div><p>This instructs the <code>headscale</code> binary to connect to a remote instance at <code><HEADSCALE_ADDRESS>:<PORT></code>, instead of connecting to the local instance.</p></li><li><p>Test the connection by listing all nodes:</p><divclass="language-shell highlight"><pre><span></span><code><spanid=__span-8-1><aid=__codelineno-8-1name=__codelineno-8-1href=#__codelineno-8-1></a>headscale<spanclass=w></span>nodes<spanclass=w></span>list