API & integrations

The web interface and the API are the same thing: the interface calls exactly the API that is exposed to integrations, with no privileged shortcut. Anything you can do on screen is available over HTTP.

API tokens

Tokens are for unattended integrations (billing systems, scripts). Only admins can create them.

  1. In the admin interface open Panel → API tokens.
  2. Give the token a name and an expiry (mandatory, at most one year).
  3. Copy the token. It is shown once; the panel stores only a hash. If you lose it, revoke it and create another.

Use it as a bearer token against the admin port (the API is not exposed on a separate port):

curl -sS -H "Authorization: Bearer <token>" https://panel.example.com:2087/api/conexion

Requests without that header get 404. The browser cookie is never accepted on /api/.

Revoke a token at any time in the same screen; it stops working immediately. Resetting the creating admin's password or second factor also revokes their tokens. Tokens that are not used expire like any other; an expired token that was real is not counted as an attack.

What a token can and cannot do

A token never receives, sees or sets anyone's password or second factor. Operations that create or move credentials, or that open a session on something (terminal, mailbox, database, impersonation), answer 403 with "this operation cannot be done with an API token: sign in to the panel". Everything else an admin can do is allowed, including creating and suspending clients.

Creating a login for a customer is done as follows:

  • A token can create the sign-in only for an account that was itself created by a token, only with role client, and only if the account has no sign-in yet.
  • The login is created without a password. The customer receives an email with a one-time link (valid one hour) to choose their password and enroll their second factor. The link is not consumed by link-scanners that merely open it; it is spent by submitting the new password.
  • A password reset from an integration sends a new link to the recovery email stored on the account. Changing that email requires a person with their own password.

Reference and OpenAPI file

The full list of routes a token can reach, with their parameters and request fields, is in the REST API reference. The same data is an OpenAPI 3.1 file that the panel serves to admins at GET /api/openapi.json (same authentication as the rest of the API) and that ships as docs/openapi.json in the release. Both are generated from the routes the panel registers, so they do not drift from the code.

Examples

Field names are those of the API (Spanish identifiers):

H="Authorization: Bearer <token>"
B=https://panel.example.com:2087/api

# create a client, then a site
curl -sS -H "$H" -H 'Content-Type: application/json' -d '{"cliente":"acme"}' $B/clientes
curl -sS -H "$H" -H 'Content-Type: application/json' \
  -d '{"cliente":"acme","domain":"example.com","aliases":["www.example.com"]}' $B/sitios

# assign a plan
curl -sS -H "$H" -H 'Content-Type: application/json' -d '{"plan":"basic"}' $B/clientes/acme/plan

# suspend / reactivate (these SET a state; repeating them is safe)
curl -sS -H "$H" -X POST $B/clientes/acme/suspender
curl -sS -H "$H" -X POST $B/clientes/acme/activar

# consumption against the plan
curl -sS -H "$H" $B/clientes/acme/uso

Listings are paginated by cursor (GET /clientes?desde=<last>&limite=200; the limit has a hard cap of 200).

Error codes follow the same meaning as in the interface: 402 paid feature, 403 not allowed or a token-restricted operation, 409 conflict or a prerequisite is missing (for example "this account lives on node X"), 429 wait before repeating, 507 out of disk quota or inodes. See the FAQ.

WHMCS

A WHMCS server module is provided in the integraciones/whmcs directory of the release. Pure PHP, no Composer; needs the curl extension.

  1. Copy modules/servers/controlpanel/ into WHMCS modules/servers/.
  2. Create an API token as above (name it "WHMCS").
  3. In WHMCS: Setup → Products/Services → Servers → Add New Server, type controlpanel. Hostname panel.example.com:2087 (no https://; the module always uses HTTPS), Password = the token (WHMCS stores it encrypted). Leave Username and Access Hash empty. Test Connection must succeed.
  4. On the product, Module Settings → Plan: the exact name of a plan that exists in the panel (empty = no plan).

The customer's email must be filled in WHMCS before the account is created: it is where the activation link goes.

WHMCS actionWhat the panel does
CreateCreates the client and the site, assigns the plan, emails the customer a link to activate their login
Suspend / UnsuspendSets suspended / active (idempotent)
TerminateDeletes the client; "already gone" counts as success, a network error does not
Change packageAssigns the new plan
Change passwordEmails the customer a reset link (the password typed in WHMCS is ignored)
Client areaShows plan and current usage, read-only

TLS is always verified. While the panel's certificate is self-signed, install it in the trust store of the server that runs WHMCS; there is no option to skip verification. The module has not yet been exercised against a production WHMCS; test it on a staging WHMCS first.

FOSSBilling

A server manager for FOSSBilling is provided in integraciones/fossbilling of the release. Pure PHP; needs the curl extension.

  1. Copy library/Server/Manager/Controlpanel.php and the library/Server/Manager/Controlpanel/ folder into FOSSBilling's library/Server/Manager/.
  2. Create an API token for an admin user (name it "FOSSBilling").
  3. In FOSSBilling: System → Hosting servers → New server, manager Controlpanel. Hostname panel.example.com (no https://), Port 2087, Password = the token. Leave the username empty. Test the connection.
  4. On each hosting plan, the plan name must be the exact name of a plan in the panel.

The customer's email is required: the activation link goes there. Create, suspend, unsuspend, cancel and change package work as in WHMCS. Change password does not set the typed password: it emails the customer a link to choose one. "Log in to the panel" opens the customer sign-in page (port 2083): an API token never opens a browser session.

Blesta

A Blesta module is provided in integraciones/blesta of the release. Pure PHP; needs the curl extension.

  1. Copy components/modules/controlpanel/ into Blesta's components/modules/.
  2. Create an API token for an admin user (name it "Blesta").
  3. In Blesta: Settings → Modules → Available → TNS Panel → Install → Add server: name, hostname (no https://), port 2087 and the token (Blesta stores it encrypted).
  4. On the package, the Plan field is the exact name of a plan in the panel (empty = no plan).

Create, suspend, unsuspend, cancel and change package work as in WHMCS. The service's Account tab emails the customer a link to choose their password (none is set) and shows the link to the panel (port 2083, no automatic sign-in). The customer's email must be filled in Blesta.

For both, TLS is always verified and there is no option to skip it. Neither has been tried against a real billing system, only against a fake server; test them on staging first.

Cloudflare

You can mirror your DNS zones to Cloudflare as a secondary. The panel's own DNS is always the source of truth; Cloudflare is only a copy, and changes made at Cloudflare are overwritten by the next sync.

  • Admin-only, one Cloudflare account per node (DNS → Cloudflare). The account belongs to the hosting operator who runs the node, not to each end customer. A customer who wants their own Cloudflare account just changes the name servers at their registrar and removes the zone from the node.
  • Create a Cloudflare API token limited to the zones and permissions needed, paste it once; it is stored encrypted and never shown or logged. The panel cannot verify a token's scope, so give it the narrowest scope you can.
  • You choose zone by zone which to mirror. There is no "mirror everything" switch.
  • Only zones that already resolve to this server can be mirrored; this is checked against a recursive resolver (not the panel's own DNS), and re-checked daily. A zone that stops pointing here is dropped from the mirror and its records are removed from Cloudflare.
  • A zone that already exists in your Cloudflare account is rejected, not adopted: the sync would delete any record not present in the panel.
  • The panel warns about the account's zone quota before it fills, reading the limit from the account itself.
  • Sync now queues the zone; the queue processes about one zone per minute.
  • A Cloudflare failure never affects your own DNS.

Support tickets and webhook

Customers open support tickets inside the panel (Support in their menu). A ticket goes to the customer's reseller, or to the admin when the customer is the admin's own. The admin sees every ticket. Nobody sees tickets outside their own hierarchy. States: abierto, respondido, espera_cliente, cerrado.

With an admin API token you can handle tickets from an outside system (a chat or WhatsApp bot, for instance):

  • GET /tickets (filters estado, desde, limite) and GET /tickets/{id}: list and read the thread.
  • POST /tickets/{id}/mensajes with mensaje (and optionally estado): reply.
  • POST /tickets/{id}/estado with estado: change the status. POST /tickets/{id}/tomar: take the ticket.
  • GET /tickets/{id}/adjuntos/{adj}: an attachment, base64-encoded in datos.

A token cannot open tickets (only a customer can) and cannot configure the webhook.

Webhook. The admin, and each reseller for their own customers, can set one https URL (Support → Customer tickets → Ticket webhook). The panel generates a signing key (whsec_…) and shows it once. On ticket.nuevo, ticket.respuesta and ticket.estado it sends a JSON POST and never makes the user wait: delivery is queued and failed deliveries are retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours. The URL must resolve to a public address (port 443, no redirects).

Headers: X-TNS-Event, X-TNS-Event-Id (the same id on every retry), X-TNS-Delivery-Attempt, X-TNS-Timestamp and X-TNS-Signature: sha256=<hex>, where the signature is HMAC-SHA256 of timestamp + "." + body with your key. Verify it, reject timestamps more than 5 minutes old and ignore event ids you already processed.