HfogDocsv1.0.0

Hfog Cloud API

Manage VPSs, plans, customers and orders on an Hfog Cloud server from a script, with an API token of a staff login or of a customer.

An Hfog Cloud server has a token API for its staff and for its customers. A token acts as the login that made it: a staff token reaches what that staff login reaches, a customer's token only that customer's own VPSs, orders and invoices.

Where: https://api.yourdomain.com/v1/cloud/…

The licence plan must include API and Hfog Cloud.

Make a token

Where: Hfog Cloud › your name at the top right › Password & security › API tokens

  1. Type a Name, choose Read only or Read & change, and optionally fill in Allowed IPs and Expires.
  2. Type your password (or a code from your authenticator app), then click Create token.
  3. Copy the token with Copy token. It is shown once.
Login Its tokens
Staff, full everything below
Staff, support read everything; change VPSs and customers, not hosts or plans
Staff, view-only read only; the card offers only Read only
Customer their own VPSs, orders and invoices
bash
curl -s https://api.yourdomain.com/v1/cloud/vps -H "Authorization: Bearer hf_xxx"

For staff and customers

Request What it does
GET /v1/cloud/vps the VPSs: every one for staff (?host= narrows), a customer's own
GET /v1/cloud/vps/{id} one VPS with its tools; a customer's also with its billing and last tasks
POST /v1/cloud/vps/{id}/start start it
POST /v1/cloud/vps/{id}/stop shut it down; {"force": true} switches it off
POST /v1/cloud/vps/{id}/restart restart it
POST /v1/cloud/vps/{id}/rebuild install it afresh: image_id, confirm (the VPS's host name), optional password, ssh_key. Answers root's new password once
GET /v1/cloud/invoices, GET /v1/cloud/invoices/{id} invoices: every customer's for staff, a customer's own

The rules are the screens' own: a task still running answers "Wait for the running task to finish.", a customer can't start a suspended VPS, and a rebuild needs the host name typed as on the screen.

For customers

Request What it does
GET /v1/cloud/order what can be ordered: plans, images, locations, extras and each choice's total as the payment page will ask it
POST /v1/cloud/orders order a VPS: plan_id, image_id, optional location, hostname, ssh_key, backups, extra_ipv4, method, marketing. Answers the order's token and the payment page's url
GET /v1/cloud/orders/{token} how the order stands, and its VPS once it is made

The totals come from the server (totals is keyed <plan id>:<backups 0 or 1>:<extra IPv4 0 or 1>), with VAT as your billing settings say. The VPS is made when the payment arrives.

For staff

Request What it does
POST /v1/cloud/vps create a VPS: customer_id, plan_id, image_id, optional host_id, location, hostname, password, ssh_key, licence
POST /v1/cloud/vps/{id}/suspend, /unsuspend stop a VPS and keep it from being started, or let it run again
DELETE /v1/cloud/vps/{id} delete a VPS with its disk
GET /v1/cloud/hosts the KVM hosts with their size and room
POST /v1/cloud/hosts add a host: name, location, provider. Answers the join command, which works once
DELETE /v1/cloud/hosts/{id} remove a host that runs no VPS
GET /v1/cloud/plans the VPS plans, hidden ones too
POST /v1/cloud/plans, PUT /v1/cloud/plans/{id} add a plan, or save one (send the whole plan)
DELETE /v1/cloud/plans/{id} delete a plan; its VPSs keep their size
GET /v1/cloud/customers the customers with their VPSs and what they pay a month
POST /v1/cloud/customers add a customer: email. They get an email to choose their password
POST /v1/cloud/customers/{id}/suspend, /unsuspend stop a customer signing in, or let them again
GET /v1/cloud/billing what the paid VPSs bring in a month, how many they are, the currency, the money-back window

Note: an Hfog Cloud server answers only these endpoints and GET /v1/me. The hosting endpoints of Hfog Panel are "not found" there.

Answers, errors, paging, the request limit and Idempotency-Key work as in the API overview.