Webhooks and alerts
Signed event webhooks (server, backup, alert, invoice, load balancer and firewall events), signature verification in Node, Python, PHP and Go, and alerts to Slack, Discord and PagerDuty.
Webhooks send an HTTPS request to your endpoint when something happens in your organization. Alerts watch metrics (CPU, memory, disk, traffic, server stopped, backup failed, load balancer target down) and notify e-mail, Slack, Discord, PagerDuty or a webhook.
Endpoints
Owners and members manage endpoints in Monitoring → Webhooks (no API access needed) or with the API
(/webhooks, read-write token):
curl -X POST https://hfcloud.eu/api/cloud/v1/webhooks -H "Authorization: Bearer $HFCLOUD_TOKEN" \
-H "Content-Type: application/json" \
-d '{"url":"https://hooks.example.com/hfcloud","events":["server.ready","backup.failed"]}'
The answer contains the endpoint's secret (whsec_...), shown only this once (and again only when you rotate
it with POST /webhooks/{id}/rotate-secret, which stops the old one at once). Up to 10 endpoints per organization.
URL rules: https only, port 443 or 8443, no user or password in the URL, a public host. The host name is resolved
at every delivery and nothing is sent to private, loopback, link-local or reserved addresses. Redirects are not
followed.
Events
| Event | When |
|---|---|
server.ready |
a server was created or reinstalled and is running (data.reinstalled) |
server.failed |
creating a server failed |
server.deleted |
a server was deleted |
server.power |
a server was started, shut down, powered off or rebooted (data.action: start, shutdown, stop, reboot) |
server.autoscaled |
automatic scaling moved a server to a larger size (data.autoscale: from, to, cpu_average) |
backup.succeeded |
a backup finished |
backup.failed |
a backup failed |
alert.firing |
an alert rule fired |
alert.resolved |
an alert is back to normal |
invoice.issued |
an invoice was issued |
load_balancer.ready |
a load balancer is ready |
load_balancer.failed |
creating a load balancer failed |
firewall.ready |
a firewall is ready |
firewall.failed |
creating a firewall failed |
Subscribe to ["*"] for every event, including ones added later. Send test (POST /webhooks/{id}/test) sends a
webhook.test event.
Request
POST with Content-Type: application/json and these headers:
| Header | Value |
|---|---|
HFCloud-Event |
the event type, e.g. server.ready |
HFCloud-Event-Id |
the event id (same as id in the body) |
HFCloud-Delivery |
the id of this delivery |
HFCloud-Signature |
t=<unix time>,v1=<hex HMAC-SHA256> |
{
"id": "evt_01j9...",
"type": "server.ready",
"created_at": "2026-10-14T08:00:00Z",
"organization_id": "<organization uuid>",
"data": {
"server": {"id": "<uuid>", "name": "web-1", "status": "ready", "power_state": "running", "ipv4": "203.0.113.25", "ipv6": null}
}
}
data per type: server (plus action or backup), load_balancer / firewall (id, name, status),
invoice (number, status, currency, subtotal, vat, total, the period, issued_at, due_at),
alert (id, state, rule, resource, value, unit, detail, started_at, resolved_at).
Verify the signature
The signature is HMAC-SHA256(secret, "<t>.<raw body>") in hex. Compute it over the raw request body (before
parsing JSON), compare in constant time, and reject requests whose t is more than 5 minutes off.
Node.js
const crypto = require('crypto');
function verify(secret, rawBody, header) {
const parts = Object.fromEntries(header.split(',').map((p) => p.trim().split(/=(.*)/s).slice(0, 2)));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > 300) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest('hex');
const given = Buffer.from(parts.v1 || '', 'utf8');
return given.length === expected.length && crypto.timingSafeEqual(given, Buffer.from(expected, 'utf8'));
}
// Express: app.post('/hfcloud', express.raw({ type: 'application/json' }), (req, res) => {
// if (!verify(process.env.WEBHOOK_SECRET, req.body, req.get('HFCloud-Signature'))) return res.sendStatus(400);
// res.sendStatus(204); // then process the event
// });
Python
import hashlib, hmac, time
def verify(secret: str, body: bytes, header: str) -> bool:
parts = dict(p.strip().split("=", 1) for p in header.split(","))
t = int(parts.get("t", "0"))
if not t or abs(time.time() - t) > 300:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))
PHP
function verify(string $secret, string $body, string $header): bool
{
$parts = [];
foreach (explode(',', $header) as $item) {
[$k, $v] = array_pad(explode('=', trim($item), 2), 2, '');
$parts[$k] = $v;
}
$t = (int) ($parts['t'] ?? 0);
if ($t <= 0 || abs(time() - $t) > 300) {
return false;
}
return hash_equals(hash_hmac('sha256', $t.'.'.$body, $secret), $parts['v1'] ?? '');
}
// $ok = verify(getenv('WEBHOOK_SECRET'), file_get_contents('php://input'), $_SERVER['HTTP_HFCLOUD_SIGNATURE'] ?? '');
Go
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"math"
"strconv"
"strings"
"time"
)
func Verify(secret string, body []byte, header string) bool {
parts := map[string]string{}
for _, item := range strings.Split(header, ",") {
if k, v, ok := strings.Cut(strings.TrimSpace(item), "="); ok {
parts[k] = v
}
}
t, err := strconv.ParseInt(parts["t"], 10, 64)
if err != nil || math.Abs(float64(time.Now().Unix()-t)) > 300 {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(strconv.FormatInt(t, 10) + "."))
mac.Write(body)
expected := hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(expected), []byte(parts["v1"]))
}
Delivery and retries
- Answer with a 2xx status within 5 seconds; do the work afterwards (queue it).
- Anything else (another status, a timeout, a refused connection) is retried after 30 s, 2, 5, 15 and 40 minutes: 6 attempts over about an hour.
- The same event can arrive more than once (a retry after a lost answer, a manual resend): de-duplicate by
id. Events are not guaranteed to arrive in order; usecreated_at. - After 5 deliveries in a row have failed for good, the endpoint is switched off and the owners get an e-mail.
Turn it on again in the console or with
PATCH /webhooks/{id}{"enabled": true}. - The last 50 deliveries per endpoint (status, attempts, response code, duration, error) are in the console and in
GET /webhooks/{id}/deliveries; Resend sends the same event (sameid) again.
Alerts and channels
Alert rules (Monitoring) watch a server or load balancer, or all of them: CPU, memory, disk usage, inbound or outbound traffic, an unexpected stop, a failed backup or a load balancer target that is down, with a threshold and a window of 5, 10, 30 or 60 minutes. Up to 50 rules. An alert that repeats within 30 minutes is not sent again.
Each rule notifies e-mail and/or channels (Monitoring → Channels, up to 10):
- Slack: an incoming webhook URL (
https://hooks.slack.com/...). - Discord: a channel webhook URL (
https://discord.com/api/webhooks/...); messages mention nobody. - PagerDuty: an Events API v2 integration key (US or EU region). A firing alert triggers an incident and the
resolved alert resolves it (same
dedup_key). - Webhook: a signed
alert.firing/alert.resolvedrequest, exactly like the webhooks above.
Send test on each channel sends a test message at once and shows the result.