Skip to content

Get a one-hour install command

POST
/hosts/install/token
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.

X-Project-Id
required
string

The project, as prj_12 or 12. A workspace key can only reach its own workspace’s projects.

Example
prj_12
Media typeapplication/json
object
name
string
<= 150 characters
group
string
<= 100 characters
auto_update

Left out, the project’s default decides.

boolean
no_users

Count no online users on the server. Needs agent 1.14.0.

boolean
host_id

The command to run again on a server already added. It keeps that server’s --no-users.

string
max_servers

The most servers this command may add.

integer
default: 50 >= 1 <= 50
Example
{
"name": "web-1",
"max_servers": 3
}

The command, when it stops working, and how many servers it may add.

Media typeapplication/json
object
command
required
string
auto_update
required
boolean
no_users
required
boolean
expires_at
required
string format: date-time
max_servers
required
integer
Examplegenerated
{
"command": "example",
"auto_update": true,
"no_users": true,
"expires_at": "2026-04-15T12:00:00Z",
"max_servers": 1
}
X-RateLimit-Limit
integer

Requests the workspace’s plan allows per minute.

X-RateLimit-Remaining
integer

Requests left in the current minute.

X-RateLimit-Reset
integer

Unix time, in seconds, when the current minute ends.

max_servers or no_users has a value it does not take.

Media typeapplication/json
object
error
required
boolean
code
required

The HTTP status, repeated.

integer
message
required

What went wrong.

string
details

More detail, on some errors.

retry_after

Seconds to wait, on the 429 for wrong keys.

integer
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.

Media typeapplication/json
object
error
required
boolean
code
required

The HTTP status, repeated.

integer
message
required

What went wrong.

string
details

More detail, on some errors.

retry_after

Seconds to wait, on the 429 for wrong keys.

integer
Examples
{
"error": true,
"code": 401,
"message": "API key is required. Provide X-API-Key header or Authorization: Bearer <key>"
}

Your role can’t add monitors.

Media typeapplication/json
object
error
required
boolean
code
required

The HTTP status, repeated.

integer
message
required

What went wrong.

string
details

More detail, on some errors.

retry_after

Seconds to wait, on the 429 for wrong keys.

integer
Example
{
"error": true
}

The project, or the server host_id names, isn’t there or isn’t yours.

Media typeapplication/json
object
error
required
boolean
code
required

The HTTP status, repeated.

integer
message
required

What went wrong.

string
details

More detail, on some errors.

retry_after

Seconds to wait, on the 429 for wrong keys.

integer
Example
{
"error": true
}

10 install commands made for this project are still open. Use one of them, or wait for one to expire.

Media typeapplication/json
object
error
required
boolean
code
required

The HTTP status, repeated.

integer
message
required

What went wrong.

string
details

More detail, on some errors.

retry_after

Seconds to wait, on the 429 for wrong keys.

integer
Example
{
"error": true
}

Something failed on TunnelHQ’s side.

Media typeapplication/json
object
error
required
boolean
code
required

The HTTP status, repeated.

integer
message
required

What went wrong.

string
details

More detail, on some errors.

retry_after

Seconds to wait, on the 429 for wrong keys.

integer
Example
{
"error": true,
"code": 500,
"message": "Internal server error"
}