Skip to content

Change a server's alerts

PATCH
/hosts/{id}/alerts
curl --request PATCH \
--url https://app.tunnelhq.com/api/v1/hosts/hst_7/alerts \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <X-API-Key>' \
--header 'X-Project-Id: prj_12' \
--data '{ "resources": [ { "metric": "disk", "above": 85, "for_seconds": 300 } ] }'

Merges a change into the server’s alert settings: only what you send changes, and the answer is the whole settings. resources entries merge by metric; a new one needs above, and { "metric": "cpu", "above": null } removes one.

Setting Default Takes
offline on, after 90 seconds enabled, after_seconds from 90 to 3600
service on, after 60 seconds enabled, after_seconds from 30 to 3600
country off enabled
cert on, 14 days enabled, days: 7, 14, 21 or 30 (agent 1.7.0)
resources none metric (cpu, memory, disk), above from 1 to 100, for_seconds from 60 to 3600 (300 by default), enabled
internet off, hourly enabled, every: once (once in an hour), hourly (3 times in an hour) or daily (3 times in a day). Agent 1.11.0.
watches none Up to 10 rules of your own. See below.

watches is a list of changes, each merged by id:

  • Without id, it adds a watch. metric, when, and value are needed. TunnelHQ gives it the next id, such as w1.
  • With id, it changes that watch: send only what changes.
  • { "id": "w1", "remove": true } removes it.
Field Takes
metric users, traffic (Mbps, in and out together), cpu, memory, or disk
when above, below, or falls_by (users only)
value Users or Mbps from 0 to 1,000,000; a percent from 1 to 100 for cpu, memory, and disk; for falls_by, a percent from 10 to 100
for_seconds 60 to 3600, 600 by default: how long it holds first, or for falls_by the window the fall happens in
until The last day, as YYYY-MM-DD in UTC, from today on, or null for always
channels Up to 20 alert channel IDs as numbers, such as 3 for chn_3, or null for where the server’s other alerts go. A webhook channel can be one of them.
enabled true or false

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.

id
required
string

The server, as hst_7 or 7.

Example
hst_7
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

Any part of the settings. Only what you send changes.

object
offline
object
enabled
boolean
after_seconds
integer
>= 90 <= 3600
service
object
enabled
boolean
after_seconds
integer
>= 30 <= 3600
country
object
enabled
boolean
cert
object
enabled
boolean
days
integer
Allowed values: 7 14 21 30
resources
Array<object>
object
metric
required
string
Allowed values: cpu memory disk
above

null removes this alert.

number | null
>= 1 <= 100
for_seconds
integer
>= 60 <= 3600
enabled
boolean
watches

Changes to the watches, each merged by id. Without id, a new watch.

Array<object>
<= 10 items
object
id

To change or remove that watch.

string
/^w\d{1,4}$/
metric
string
Allowed values: users traffic cpu memory disk
when
string
Allowed values: above below falls_by
value
number
<= 1000000
for_seconds
integer
default: 600 >= 60 <= 3600
until
string | null format: date
channels
Array<integer> | null
<= 20 items
enabled
boolean
remove

With id: removes the watch.

boolean
internet
object
enabled
boolean
every
string
Allowed values: once hourly daily
Examples

Alert when the disk is above 85% for 5 minutes

{
"resources": [
{
"metric": "disk",
"above": 85,
"for_seconds": 300
}
]
}

The whole settings after the change.

Media typeapplication/json
object
alerts
required
object
offline
object
enabled
boolean
after_seconds
integer
service
object
enabled
boolean
after_seconds
integer
country
object
enabled
boolean
cert
object
enabled
boolean
days
integer
Allowed values: 7 14 21 30
resources
Array<object>
object
metric
string
Allowed values: cpu memory disk
above
number
>= 1 <= 100
for_seconds
integer
>= 60 <= 3600
enabled
boolean
watches

The server’s watches still running. One past its until day is left out.

Array<object>

A rule of your own on one reading of the server.

object
id
string
metric
string
Allowed values: users traffic cpu memory disk
when
string
Allowed values: above below falls_by
value
number
for_seconds
integer
>= 60 <= 3600
until

Its last day, in UTC. null is always.

string | null format: date
channels

Alert channel IDs as numbers. null sends it where the server’s other alerts go.

Array<integer> | null
enabled
boolean
internet

Its internet keeps breaking. Needs agent 1.11.0.

object
enabled
boolean
every
string
Allowed values: once hourly daily
Example
{
"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
}
],
"watches": [
{
"id": "w1",
"metric": "users",
"when": "above",
"value": 500,
"for_seconds": 600,
"until": "2026-11-16",
"channels": [
3
],
"enabled": true
}
],
"internet": {
"enabled": false,
"every": "hourly"
}
}
}
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.

A setting it doesn’t take, or a value out of range.

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": 400,
"message": "ram is not an alert setting: use offline, service, country, cert, resources, watches or internet."
}

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 edit 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,
"code": 403,
"message": "Changing a server needs a role that can edit monitors."
}

The project has no server with this ID, or the project doesn’t exist.

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": 404,
"message": "No such server 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.

Media typeapplication/json
One of:
object
error
required
string
Allowed values: Rate limit exceeded Daily limit exceeded Monthly limit exceeded
message
required
string
retry_after

Seconds to wait. Absent for the monthly limit.

integer
Examples
{
"error": "Rate limit exceeded",
"message": "Per-minute limit of 60 requests exceeded",
"retry_after": 60
}
Retry-After
integer

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.

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"
}