Reference

The API

What this does: the API lets your own programs and scripts do what you do in the panel: make accounts, add domains, read the status and so on, without clicking. API tokens let a script sign in, and event hooks tell another system when something happens.

When you need it: when you want to connect freePanel to another system, such as a billing system or your own scripts. You don't need it to run your server.

API stands for "application programming interface": a set of addresses on your server that a program can call, sending and receiving data instead of web pages.

The full reference

The complete list of every API address, what each takes and what it answers, is in the admin panel, and always matches the freePanel version your server runs:

This page is an overview to get you started.

How it works

A first call, which needs no sign-in and checks the panel answers:

curl https://server.example.com:7443/api/v1/health
{"status":"ok","realm":"admin","setup_required":false}

API tokens

An API token is a long secret that lets a script call the API as you, without your password. You can limit what it may do, for how long, and from which addresses.

Where: Branding and API > API tokens (for you, the admin). Your customers make their own in Security > API tokens, for their account only.

To make an API token

  1. Open Branding and API > API tokens.
  2. Under Make a token, type a Name that says what it is for, such as billing.
  3. Under What it may do, choose Read only (it can only read) or Full (it can make changes too).
  4. In Valid for (days), type how many days it lasts, from 1 to 365. It is not renewed.
  5. If the script always runs from the same place, list its addresses in Addresses it may be used from, one on each line. Leave it empty for any address.
  6. In Your password, type the password you sign in with, to confirm it is you.
  7. Click Make token.
  8. You see Your new token: billing. This is the only time the token is shown. Click Copy the token, keep it somewhere safe, then click I have copied it. The token starts with fpt_.
The API tokens page with the form to make a token

Each step and button is described in API tokens. For customers' tokens, see API tokens in the hosting panel.

Using a token

Send it in the Authorization header of each request:

curl -H "Authorization: Bearer fpt_YOUR-TOKEN" \
  https://server.example.com:7443/api/v1/accounts

If a token leaks, revoke it at once on the same page. Changing your password also ends every token of yours in the admin panel, so make new ones afterwards and put them in your scripts. Tokens made in the customer panel are not ended.

Event hooks

An event hook tells another system when something is done on your server: for example, when an account is made or removed. freePanel sends a short message to an address you choose, each time.

Where: Branding and API > Event hooks

To add an event hook

  1. Open Branding and API > Event hooks.
  2. Under Make a hook, type a Name, such as crm.
  3. In Address, type the https:// address that should receive the messages, such as https://crm.example.com/hook. It can't be this server or a network of its own.
  4. In Actions, type the events it wants, one on each line: * for everything, a family such as account.*, or one event such as account.create. The names are those of the audit log.
  5. Leave Send as soon as it is made ticked to start at once.
  6. In Your password, type the password you sign in with.
  7. Click Make hook.
  8. You see The signing secret of crm. This is the only time it is shown. Click Copy the secret, give it to the receiving system so it can check each message really came from your server, then click I have copied it. The secret starts with whsec_.
  9. To check it works, click Send a test next to the hook. You see The test was delivered: ....
The Event hooks page with the form to add a hook

Each step and button is described in Event hooks.

What the receiver gets

Each event is one POST request with a JSON body: {id, type, time, result, actor:{name}, target, detail, server}, the same as the audit log entry. It never holds a password or key.

The headers say which event it is (X-FreePanel-Event), give a delivery ID (X-FreePanel-Delivery), and sign it (X-FreePanel-Signature: t=SECONDS,v1=HEX). The receiver checks the signature: HEX is the HMAC-SHA256 of SECONDS, a dot and the body, with the secret as the key. It should refuse a time that is not recent.