Get a one-hour install command
const url = 'https://app.tunnelhq.com/api/v1/hosts/install/token';const options = { method: 'POST', headers: { 'X-Project-Id': 'prj_12', 'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json' }, body: '{"name":"web-1","max_servers":3}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.tunnelhq.com/api/v1/hosts/install/token \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --header 'X-Project-Id: prj_12' \ --data '{ "name": "web-1", "max_servers": 3 }'The same install command, holding a key made for this request instead of the project’s install key. It works
for 1 hour and adds at most max_servers servers, then stops working; servers it added keep reporting. This is
the install command an AI assistant’s connection gets, so a key leaked through a prompt can’t add machines for
good.
A project can have up to 10 such commands open at once (not expired, not used up). It needs a role that can add monitors.
Need an API key? See Getting an API key.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters”The project, as prj_12 or 12. A workspace key can only reach its own workspace’s projects.
Example
prj_12Request Body
Section titled “Request Body”object
Left out, the project’s default decides.
Count no online users on the server. Needs agent 1.14.0.
The command to run again on a server already added. It keeps that server’s --no-users.
The most servers this command may add.
Example
{ "name": "web-1", "max_servers": 3}Responses
Section titled “ Responses ”The command, when it stops working, and how many servers it may add.
object
Examplegenerated
{ "command": "example", "auto_update": true, "no_users": true, "expires_at": "2026-04-15T12:00:00Z", "max_servers": 1}Headers
Section titled “Headers”Requests the workspace’s plan allows per minute.
Requests left in the current minute.
Unix time, in seconds, when the current minute ends.
max_servers or no_users has a value it does not take.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Example
{ "error": true, "code": 400, "message": "max_servers must be a whole number from 1 to 50."}The API key is missing, wrong, expired, switched off, or no longer valid.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": true, "code": 401, "message": "API key is required. Provide X-API-Key header or Authorization: Bearer <key>"}{ "error": true, "code": 401, "message": "Invalid or expired API key"}{ "error": true, "code": 401, "message": "API key has expired"}{ "error": true, "code": 401, "message": "API key owner account is inactive"}{ "error": true, "code": 401, "message": "This API key's workspace access has been removed"}Your role can’t add monitors.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Example
{ "error": true}The project, or the server host_id names, isn’t there or isn’t yours.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Example
{ "error": true}10 install commands made for this project are still open. Use one of them, or wait for one to expire.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Example
{ "error": true}Something failed on TunnelHQ’s side.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Example
{ "error": true, "code": 500, "message": "Internal server error"}