HfogDocsv1.0.0

Shop API

Show your packages, prices and domain search on your own website without a token, and place orders with an administrator's token.

The shop API lets your own website sell what the panel's shop sells. The lists need no token, so a page can read them straight from the visitor's browser or from your web server. Placing an order needs an administrator's API token and runs the same checks as the panel's own order page.

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

The licence plan must include API and Billing.

Lists without a token

Request What it answers
GET /v1/shop/packages the packages with Show in shop, cheapest first within Web hosting and WordPress hosting, each with its price per period
GET /v1/shop/domain-prices the domain endings on sale with their prices for a year
GET /v1/shop/domain-search?q=mybakery which endings of a name are free, with prices
GET /v1/shop/quote?package_id=1&period=year what an order would cost: subtotal, discount, VAT and total (below)
bash
curl -s https://api.yourdomain.com/v1/shop/packages
json
{
    "ok": true,
    "data": {
        "open": true,
        "currency": "gbp",
        "prices_include_vat": true,
        "periods": ["month", "year"],
        "money_back_days": 14,
        "pay_with": ["card"],
        "sale": null,
        "packages": [
            {
                "id": 1,
                "name": "Basic",
                "group": "hosting",
                "description": "For a first website",
                "popular": true,
                "prices": { "month": 5, "year": 50 },
                "trial_days": 0,
                "free_domain": false,
                "disk_mb": 1000,
                "max_domains": 0,
                "max_databases": 0,
                "max_mailboxes": 0,
                "order_url": "https://cp.yourdomain.com:2087/order?p=1"
            }
        ]
    }
}

The lists show exactly what the shop's own pages show:

  • A package appears only with Show in shop ticked and a price. "open" is false and the list is empty while no way to pay is set up.
  • Domain prices are empty, and the search answers 404, while domain sales are off.
  • Prices are in the billing currency.
Limit What happens
120 requests a minute per address 429
Domain search: 20 an hour per address, and a limit for all visitors together 422 with the reason

The answers may be cached (Cache-Control: public, 5 minutes for the lists, 1 minute for a search or a quote) and any website may read them (Access-Control-Allow-Origin: *).

What an order costs

GET /v1/shop/quote works out an order exactly as the panel's own order page does, so your checkout can show the same summary: package_id (required), period, currency, coupon and, with the VAT rules on, country.

bash
curl -s "https://api.yourdomain.com/v1/shop/quote?package_id=1&period=year&coupon=SPRING&country=GB"
json
{
    "ok": true,
    "data": {
        "package_id": 1,
        "period": "year",
        "coupon": "SPRING",
        "coupon_error": "",
        "totals": {
            "currency": "gbp",
            "price": 50,
            "discount": 10,
            "subtotal": 40,
            "vat_rate": 20,
            "vat": 6.67,
            "vat_included": true,
            "total": 40,
            "renews": 50,
            "trial_days": 0
        }
    }
}
Field of totals What it is
price the plan's price for the period
discount the discount code's part of it
subtotal due today before VAT; 0 during a free trial (trial_days)
vat_rate, vat the VAT percent and amount; 0 with the VAT rules off
vat_included true when your prices include VAT: the VAT is part of the subtotal, not added to it
total due today
renews each renewal, with VAT

A discount code that can't be used is left out of the figures, and coupon_error says why. A code is checked as on the order page, with the same limit of tries per address. A new order answers the same totals for what it charges.

Place an order

POST /v1/shop/orders with an administrator's Read & change token. Resellers don't sell through the shop, so a reseller's token is refused.

bash
curl -s https://api.yourdomain.com/v1/shop/orders \
     -H "Authorization: Bearer hf_xxx" -H "Content-Type: application/json" \
     -H "Idempotency-Key: order-8841" \
     -d '{"package_id": 1, "username": "mybakery", "email": "owner@example.com",
          "domain": "mybakery.com", "terms": true, "period": "year",
          "customer_ip": "203.0.113.24"}'
json
{
    "ok": true,
    "data": {
        "token": "5f0c2e…",
        "status": "pending",
        "package": "Basic",
        "username": "mybakery",
        "email": "owner@example.com",
        "domain": "mybakery.com",
        "period": "year",
        "created_at": "2026-11-10 21:14:03",
        "payment_url": "https://checkout.example/pay/…",
        "expires_in": 3600,
        "totals": { "currency": "gbp", "price": 50, "discount": 0, "subtotal": 50, "vat_rate": 0, "vat": 0,
                    "vat_included": false, "total": 50, "renews": 50, "trial_days": 0 }
    }
}

Send the customer to payment_url. The account is made when the payment arrives, exactly as for an order placed on the panel's own page. GET /v1/shop/orders/{token} tells you how the order stands (pending, then paid).

Back to your website after paying

Send return_url and the customer comes back to it once they have paid, with ?order=<token> added, instead of staying on the panel's order page. List your shop's host names first under Billing › Selling › Your shop websites: a return_url must be an https:// address on one of them, without a user name, password or port, or the order is refused (422, field return_url). A website taken off the list later gets nobody back.

json
{ "package_id": 1, "username": "mybakery", "email": "owner@example.com", "domain": "mybakery.com", "terms": true,
  "return_url": "https://shop.yourdomain.com/order/status/" }
Field What it is
package_id, username, email, domain required: what the order page asks
terms required, true: your customer accepted your terms
period month (default), year or 2year
currency one of the currencies you accept; default the billing currency
method card or paypal; default the first way to pay on offer
coupon a discount code
country, vat_number with the VAT rules on
marketing true when the customer ticked "news and offers"; kept with the time
customer_ip your customer's address; kept with the order and counted by the limit below. Default: the caller's
reg_domain true to register the domain with the order, with the owner's details as c_first, c_last, c_email, c_phone, c_addr1, c_city, c_zip, c_country
addon_<id> "1" for each add-on the checkout offers that the customer ticked (Settings › Add-ons, Offer it at the checkout of new orders); bought for the new account once the order is paid
return_url where the customer goes after paying (above)
customer_token an existing customer signed in with POST /v1/shop/sign-in: the plan joins their login (below)
password, code an existing customer: the password of the email's login, and the code from their authenticator app when it asks for one

Every check of the order page applies:

  • The username must be free. It is held for an hour while the order waits for its payment.
  • An email address that already has a login is taken like any other, so the answer never tells whether an address is a customer's. The paid plan then waits for its owner to confirm with a code sent by email.
  • A discount code is checked against the package, the period and the customer.
  • VAT is worked out from the country and the VAT number.
  • At most 5 orders an hour per customer address: 429.

Tip: send an Idempotency-Key header so a retried request doesn't place the order twice.

Orders from existing customers

A customer who already has a login can add the new plan to it, just as Billing › Add a plan does in the Control Panel: one password, and they switch between their hosting accounts. The order names them in one of two ways:

  • Email and password: send password (and code, below) with the order's email.
  • A customer token: sign them in first with POST /v1/shop/sign-in and send the answer's customer_token with the order. The token works for one order within an hour, and the order's email must be the customer's.
bash
curl -s https://api.yourdomain.com/v1/shop/sign-in \
     -H "Authorization: Bearer hf_xxx" -H "Content-Type: application/json" \
     -d '{"email": "owner@example.com", "password": "…"}'
json
{ "ok": true, "data": { "customer_token": "9c41e0…", "expires_in": 3600 } }
Answer When
422 "Wrong email or password." (field password) the password is wrong, or the address has no login a plan can join: both get exactly the same answer
422, field code the login has two-step sign-in: send the code from the authenticator app (or a backup code) as code
429 too many wrong tries for that login, as on the sign-in page

Your website never learns whether an address has a login unless the customer types its password. Without a password or token the order works as before: the plan waits for the address's owner to confirm it.

Add-ons of an account

What a customer has beside their plan, and buying more (the rules are those of Billing in the Control Panel: the add-on must be on sale for the account's package, within its most per account; each purchase is an invoice, paid at once with account credit or the card on file):

Call What it does
GET /v1/accounts/{username}/addons held: the account's add-ons (qty, next_qty from the next period, status unpaid, active or ending, until, invoice); offer: those it may buy, with their price
POST /v1/accounts/{username}/addons buy one: addon (its id from offer), qty (default 1), coupon. Answers 201
PATCH /v1/accounts/{username}/addons/{id} qty: more at once (billed for the rest of the period), fewer from the next period
DELETE /v1/accounts/{username}/addons/{id} cancel: it ends with its paid period; one not paid yet ends now and its invoice is voided

The customer's own token, or the token of the administrator or reseller who manages the account. A quantity over the most is 422, an add-on not for the account's package 422, another seller's customer 404.