Link a tunnel or check to a server
const url = 'https://dev.tunnelhq.com/api/v1/hosts/hst_7/link';const options = { method: 'POST', headers: { 'X-Project-Id': 'prj_12', 'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json' }, body: '{"monitor_id":"srv_81"}'};
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://dev.tunnelhq.com/api/v1/hosts/hst_7/link \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --header 'X-Project-Id: prj_12' \ --data '{ "monitor_id": "srv_81" }'Links a tunnel or check to the server by hand, for when TunnelHQ can’t tell from the address, such as behind a load balancer or a CDN. Unlink undoes it.
It needs a role that can edit monitors (Owner, Admin and Manager have it by default).
Need an API key? See Getting an API key.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”The server, as hst_7 or 7.
Example
hst_7Header 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 Bodyrequired
Section titled “Request Bodyrequired”object
The tunnel or check, as srv_81 or 81.
Example
{ "monitor_id": "srv_81"}Responses
Section titled “ Responses ”The server, with its linked tunnels and checks after the change.
object
The name a person gave it, else its hostname.
Online: a report in the last 60 seconds. Stale: 60 to 90 seconds. Offline: more than 90 seconds, or never.
The agent version TunnelHQ hands out now.
A newer release than this server’s agent is out.
The agent has the updater, so TunnelHQ can update it. False for one installed before updates came, or with --no-updates.
TunnelHQ updates this agent by itself, a day after each release.
The version on its way
How the last update went, as the agent reported it.
object
The country of the server’s own address, as the agent reports it (agent 1.4.0 and later).
0 to 100, where 0 is best: 0 means no sign of trouble for users, 100 that users are suffering now.
0 to 100: how little room is left for more users (100: none).
0 to 100: how busy the server is overall.
Users per VPN protocol.
The VPN services it watches.
Web servers, databases and the like, with their state (agent 1.6.0 and later).
Its linked tunnels and checks that you can see.
object
How it was linked: by hand, by address, or by hostname.
Every disk the agent reports.
object
The biggest programs by memory, up to 8.
object
Users per country, biggest first, on a VPN server. Countries under 11 users are counted under “Other”.
object
object
object
object
object
object
object
object
Its open incidents.
object
The service, metric (cpu, memory, disk) or country code, when the kind has one.
When its message went. Servers failing together share one message.
object
What the message was built from, such as a certificate’s expiry and names.
object
The command that removes the agent from the machine.
The certificate the server’s OpenConnect service serves, read by the agent every hour (agent 1.8.0). Null when it serves none. There is no revocation check.
object
Its common name.
Server certificate first, then the ones above it.
object
True when the file on disk was renewed and OpenConnect still serves the old one.
When TunnelHQ first saw this certificate.
Each check passes (true), fails (false) or is not known (null).
object
Example
{ "id": "hst_7", "status": "online", "monitors": [ { "id": "srv_81", "family": "tunnel", "via": "manual" } ], "alerts": { "offline": { "enabled": true, "after_seconds": 90 }, "service": { "enabled": true, "after_seconds": 60 }, "country": { "enabled": false }, "cert": { "enabled": true, "days": 14 }, "resources": [ { "metric": "disk", "above": 85, "for_seconds": 300, "enabled": true } ] }, "incidents": [ { "id": "hin_3", "kind": "offline", "state": "open" } ], "certificate": { "key": "RSA 2048", "tls_version": "TLS 1.3", "trust_problem": "self-signed", "checks": [ { "key": "validity" } ] }}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.
The body names no tunnel or check.
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": "Send monitor_id: the tunnel or check, such as srv_81."}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 edit 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, "code": 403, "message": "Changing a server needs a role that can edit monitors."}No such server, or no such tunnel or check that you can see in this project.
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": 404, "message": "No such server in this project."}{ "error": true, "code": 404, "message": "No such tunnel or check in this project."}A usage limit was reached, or this IP address made too many requests with a wrong key.
Usage limits are per workspace and plan: per minute (Retry-After: 60), per day
(Retry-After: 3600), and per month (no Retry-After). They use their own body shape.
An IP address may send 10 wrong keys a minute; one more is allowed every 6 seconds. While
that allowance is used up, every request from the address is refused, even one with a
valid key.
object
Seconds to wait. Absent for the monthly limit.
object
The HTTP status, repeated.
What went wrong.
More detail, on some errors.
Seconds to wait, on the 429 for wrong keys.
Examples
{ "error": "Rate limit exceeded", "message": "Per-minute limit of 60 requests exceeded", "retry_after": 60}{ "error": "Daily limit exceeded", "message": "Daily limit of 25000 requests exceeded", "retry_after": 3600}{ "error": "Monthly limit exceeded", "message": "Monthly limit of 250000 requests exceeded"}{ "error": true, "code": 429, "message": "Too many failed API key attempts from this address. Wait a few seconds and try again.", "retry_after": 6}Headers
Section titled “Headers”Seconds to wait. 60 for the per-minute limit, 3600 for the daily limit, 6 after wrong keys. Absent for the monthly limit.
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"}