HF Cloud
Docs / API

API

The HF Cloud REST API – tokens and service tokens, IP allow lists, rate limits, errors, idempotency, asynchronous operations and labels.

The API manages everything you manage in the console: servers, SSH keys, security groups, snapshots, backups, disks, images, load balancers, firewalls with VPN, reserved IPs, private networks and webhooks.

  • Base URL: https://hfcloud.eu/api/cloud/v1
  • Format: JSON in and out. Successful answers wrap the result in data.
  • Reference: every call with its fields is in the interactive reference, Swagger UI, and in the OpenAPI 3 description https://hfcloud.eu/api/cloud/v1/openapi.json (for code generators and Postman).

Every call goes through the same checks as the console (roles, quotas, billing) and appears in the organization's Activity log with the token's name.

Turning on API access

API access is approved per organization:

  1. An owner opens API in the console and clicks Request API access, with a short note on what it is for.
  2. Our team approves the request; owners get an e-mail.
  3. Owners create tokens (API → New token).

Tokens

A token looks like hfc_<id>_<secret> and is sent as a bearer token:

curl -H "Authorization: Bearer $HFCLOUD_TOKEN" https://hfcloud.eu/api/cloud/v1/me

When you create a token you choose:

Option Values
Access read only (acts as a viewer) or read and write
Acts as you (personal token) or the organization (service token)
Expires after 30, 90 or 365 days
Allowed addresses optional list of IP addresses or ranges the token may be used from

Creating a token asks for a two-factor code. The token is shown once; only its hash is stored. An organization has at most 20 active tokens. Owners see each token's last use (time and address) and can revoke it. Every new token expires, at most after a year; the API page lists tokens that expire within 30 days, so you can replace them in time. Tokens made earlier without an expiry keep working; replace them when you can.

The activity log records the first use of a token from an address it has not used before. Every owner gets an e-mail when a token adds a VPN device, a WireGuard site or an IPsec tunnel, or adds a webhook or changes its URL (in the console these changes ask for a two-factor code).

Personal tokens

A read-write personal token has the role of the person who made it: a member token cannot delete servers, just like in the console. When the person leaves the organization, their tokens stop working.

Suspended and closed organizations

While an organization is suspended, the API is read-only: every GET works and servers can be switched off (shutdown or stop); other changes answer 403 organization_suspended. A closed organization answers 403 organization_closed, and closing it revokes its tokens.

Service tokens

For CI and automation, use a service token (New token → Acts as → The organization). It belongs to the organization, not to a person, so it keeps working when people leave. Its role is member (read and write, cannot delete servers) or viewer (read only), never owner. A service token uses the organization's SSH keys only. In the activity log it appears as token <name> (service).

IP allow lists

Two lists apply, both optional:

  • per token: set when the token is created;
  • per organization: API → Allowed addresses (owners). It applies to every token of the organization.

A request from any other address is refused with 403 ip_not_allowed.

Rate limits

Limit Value
Per token 120 requests per minute, from any address
Per organization 600 requests per minute (all tokens together)
Per client address 300 requests per minute, counted before the token is checked
Server creation 3 per minute per person (or service token)

Over a limit the API answers 429 with a Retry-After header (seconds). Wait and retry.

Errors

Errors carry an HTTP status and a JSON body. Machine-readable codes are in error, details in message:

{"error": "payment_required", "message": "...", "missing": ["payment_method"], "billing_url": "https://hfcloud.eu/billing"}
Status Meaning
401 token missing, invalid, expired or revoked (unauthenticated)
402 billing is not set up or prepaid credit is too low (payment_required, see missing and billing_url)
403 not allowed: ip_not_allowed, api_not_approved, not_a_member, account_blocked, account_closed, organization_suspended, organization_closed, or the token's role (for example a read-only token writing)
404 not found (also resources of other organizations)
409 busy: the resource is in the middle of something that ends by itself (see below); or request_in_progress: a request with the same Idempotency-Key is still running
422 validation failed: errors lists messages per field
429 rate limit, see Retry-After
503 maintenance (maintenance, with until and Retry-After)

A validation error:

{"message": "The name field is required.", "errors": {"name": ["The name field is required."]}}

Busy (409)

A resource that is busy answers 409 instead of 422: a load balancer or firewall being set up, upgraded or deleted, a server being created, reinstalled or restored, a snapshot, backup or disk change in progress, a reserved IP still being removed from a server, or a short cool-down (a certificate request, a retry, an IP change). Nothing is wrong with the request; send it again later. When a sensible wait is known, the answer has a Retry-After header and retry_after (seconds):

{"error": "busy", "message": "The load balancer is busy.", "retry_after": 30}

Wrong input stays 422. A failed resource (status failed) does not become ready by waiting: those answers stay 422 too.

Idempotency

Creating calls (POST /servers, /ssh-keys, /security-groups, snapshots, backups, disks, images, load balancers, firewalls, VPN sites, reserved IPs, networks) accept an Idempotency-Key header: 8 to 128 characters of A-Z a-z 0-9 . _ : -. Use a new random key per operation and reuse it when you retry:

  • a retry with the same key and the same body within 24 hours gets the first answer again, with the header Idempotent-Replayed: true, instead of creating a second server;
  • the same key with a different body is refused: 422 idempotency_key_reused;
  • a retry while the first request is still running gets 409 request_in_progress;
  • only successful answers are remembered, so a request that failed validation can be retried with the same key.

Keys are per token. VPN devices and IPsec tunnels take no Idempotency-Key: their answers contain secrets that are never stored.

curl -X POST https://hfcloud.eu/api/cloud/v1/servers \
  -H "Authorization: Bearer $HFCLOUD_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"name":"web-1","image":"ubuntu-24.04","size":1,"ssh_key_ids":["<ssh-key-uuid>"]}'

Asynchronous operations

Anything that changes infrastructure is asynchronous. The API answers 202 Accepted with the resource in its new state, and the work continues in the background:

  • POST /servers returns the server with status: "provisioning". Poll GET /servers/{id} until status is ready (or failed, with an error text).
  • Power actions (POST /servers/{id}/actions with start, shutdown, stop or reboot) show the action in pending until it is done.
  • DELETE /servers/{id} (with confirm set to the server's name) returns status: "deleting"; the server is gone when GET answers 404.
  • Load balancers and firewalls go from provisioning to active; snapshots from creating to ok.

Poll every few seconds (the Terraform provider polls every 5 seconds) or subscribe to webhooks such as server.ready.

id=$(curl -s -X POST https://hfcloud.eu/api/cloud/v1/servers -H "Authorization: Bearer $HFCLOUD_TOKEN" \
  -H "Content-Type: application/json" -d @server.json | jq -r .data.id)
until [ "$(curl -s https://hfcloud.eu/api/cloud/v1/servers/$id -H "Authorization: Bearer $HFCLOUD_TOKEN" | jq -r .data.status)" = ready ]; do
  sleep 5
done

Lists and filters

Every item of a list can also be read on its own (GET /servers/{id}/snapshots/{sid}, /backups/{bid}, /disks/{did}, /firewalls/{id}/vpn/devices/{uuid}, /vpn/sites/{uuid}, /ipsec-tunnels/{uuid}, /images/{id}, …), with the same fields; 404 for other organizations' (or another server's) items. VPN devices and IPsec tunnels never return their private key or pre-shared key there. GET /images/{id} also shows an own image while it is being created: poll until status is ready.

List calls return every item in data; there is no pagination. Servers can be filtered:

  • GET /servers?name=web-1: by name (names are stored and returned in lowercase); GET /load-balancers?name=, /firewalls?name=, /security-groups?name= and /ssh-keys?name= take the same exact-name filter;
  • GET /servers?label=env=prod: by label. Repeat the parameter or separate with commas: every condition must match. label=env matches servers that have the label env at all.

Labels

Servers carry labels: an object of at most 20 key: value pairs.

  • key: ^[a-z0-9][a-z0-9._/-]{0,62}$ (lowercase, up to 63 characters, may contain . _ / -);
  • value: up to 63 characters of A-Z a-z 0-9 . _ -, may be empty.

Set them in POST /servers or replace the whole set with PATCH /servers/{id} ({} removes all). Labels are always returned as an object ({} when there are none). Load balancers and firewalls have labels in the console too.

curl -X PATCH https://hfcloud.eu/api/cloud/v1/servers/$id -H "Authorization: Bearer $HFCLOUD_TOKEN" \
  -H "Content-Type: application/json" -d '{"labels":{"env":"prod","team":"web"}}'

Good to know

  • Destructive calls (delete a server, load balancer or firewall, restore a backup, roll back a snapshot, reinstall) need the resource's name as confirm.
  • PATCH /servers/{id} can change size (the server must be shut down), security_groups, private_network (takes effect after a reboot), backups and labels.
  • Every id is a UUID (SSH keys, snapshots, backups, disks, reserved IPs too). Old numeric ids are still accepted in paths and ssh_key_ids but deprecated.
  • SSH keys given as ssh_key_ids must be your own personal keys or the organization's; others are refused with 422.
  • Secrets (VPN device configurations, IPsec pre-shared keys, webhook secrets) are returned once, in the answer that creates them.