REST API v1 · Developers

BotGG Hosting Protocol v1

The protocol between a billing panel and BotGG. The WHMCS, Blesta and Paymenter modules are reference implementations of it; any other billing system or in-house panel can implement it and get every BotGG for Hosting feature. Two directions, one connection secret, every request signed.

Developer docs
On this page

How it works

  • Panel → BotGG: your panel sends events (an order, a suspension, a paid invoice…) to the events URL, creates account links after the customer approved BotGG Sign-in, and calls the handshake during setup.
  • BotGG → panel: BotGG calls your bridge, one HTTPS URL that answers POST { "op", "params" }, to read services, invoices and the catalog, and (when you support it) to sync tickets, press power buttons or create promo codes.
  • Events are hints, never authority: before granting or removing a role BotGG re-reads the customer’s services through the bridge. A forged or out-of-order event can at worst cause a re-read.
  • Data minimization: events carry ids and statuses only, never e-mail, names, addresses, phone numbers, IPs, passwords or card data. The schemas are strict, so unknown fields are refused. Ticket sync bodies are the one exception: the message text and the author’s display name.
  • All ids are strings on the wire. accountId is the panel login identity (WHMCS user, Blesta user, Paymenter user); one Discord user links to one account per connection and vice versa.

The connection key

When a server owner adds a billing connection in the console, BotGG shows a connection key once. Paste it into the module settings and store it encrypted: it holds everything the module needs.

Connection key: four parts separated by dots
hcn_0123456789abcdef.<secret: 43 characters>.hc_<32 hex>.botgg_cs_<43 characters>
└ connection id   └ HMAC secret           └ OAuth client id └ OAuth client secret
  • The connection id goes into X-BotGG-Connection on every request; the HMAC secret signs requests in both directions.
  • The OAuth client (hc_… + secret) is used for “BotGG Sign-in”: authorization code flow with PKCE S256, scope identify, the redirect URI locked to your callback, a 10-minute access token, no refresh token.
  • Rotating the secret in the console keeps the previous one valid for 24 hours, so you can update the module without downtime.

Signing requests

Both directions use the same four headers. The signature is an HMAC-SHA256, in lower-case hex, keyed with the secret string, over the timestamp, nonce, method, request target and raw body joined with dots:

Headers
X-BotGG-Connection: hcn_<16 hex>
X-BotGG-Timestamp:  <unix seconds>
X-BotGG-Nonce:      <16 random bytes, 32 hex characters>
X-BotGG-Signature:  v1=<hex HMAC-SHA256(secret, timestamp + "." + nonce + "." + METHOD + "." + path + "." + body)>
  • path is the request target exactly as sent: path and query string (/index.php?m=botgg&action=bridge). body is the raw body bytes; an empty body signs as an empty string.
  • The receiver compares in constant time, accepts a timestamp within ±300 seconds and refuses a nonce it has seen in the last 10 minutes. Remember nonces only after the signature matched.
  • Signed requests never follow redirects: answer the bridge URL directly with HTTPS.
Test vector (fixtures/signing.json)
secret    = c2lnbmluZy1maXh0dXJlLXNlY3JldC0wMDEtYWJjZGU
timestamp = 1795947300
nonce     = 0123456789abcdef0123456789abcdef
method    = POST
path      = /api/hooks/hosting/Zm9vYmFyYmF6cXV4cXV1eHF1dXhxdXV4
body      = {"id":"evt_service_suspended_0005","type":"service.suspended","occurredAt":"2026-11-29T10:15:00Z","accountId":"12","clientId":"34","data":{"serviceId":"56","productId":"7","groupId":"2","status":"suspended","reason":"Overdue on payment"}}

signed string:
1795947300.0123456789abcdef0123456789abcdef.POST./api/hooks/hosting/Zm9vYmFyYmF6cXV4cXV1eHF1dXhxdXV4.{"id":"evt_service_suspended_0005","type":"service.suspended","occurredAt":"2026-11-29T10:15:00Z","accountId":"12","clientId":"34","data":{"serviceId":"56","productId":"7","groupId":"2","status":"suspended","reason":"Overdue on payment"}}

X-BotGG-Signature: v1=224d6f9dc9ec40276bb848f0241702780622abfbf000cb42814abc44007aad27
PHP
<?php
// BotGG Hosting Protocol v1: sign requests to BotGG and verify requests from BotGG (PHP 7.4+, no extensions beyond hash).
// Signature: X-BotGG-Signature: v1=<hex HMAC-SHA256(secret, timestamp.nonce.METHOD.path.body)>

const BOTGG_TOLERANCE_SECONDS = 300;

/** The signed string. $path = the request target exactly as sent (path + ?query), $body = the raw body ('' if none). */
function botgg_signature_base(string $timestamp, string $nonce, string $method, string $path, string $body = ''): string
{
    return $timestamp . '.' . $nonce . '.' . strtoupper($method) . '.' . $path . '.' . $body;
}

/** v1=<hex> for one request. The key is the connection secret string itself. */
function botgg_sign(string $secret, string $timestamp, string $nonce, string $method, string $path, string $body = ''): string
{
    return 'v1=' . hash_hmac('sha256', botgg_signature_base($timestamp, $nonce, $method, $path, $body), $secret);
}

/** Headers for a request you send to BotGG (events, links, handshake), as "Name: value" lines for curl. */
function botgg_signed_headers(string $connectionId, string $secret, string $method, string $path, string $body = ''): array
{
    $timestamp = (string) time();
    $nonce = bin2hex(random_bytes(16)); // 32 hex characters, new for every request
    return [
        'Content-Type: application/json',
        'X-BotGG-Connection: ' . $connectionId,
        'X-BotGG-Timestamp: ' . $timestamp,
        'X-BotGG-Nonce: ' . $nonce,
        'X-BotGG-Signature: ' . botgg_sign($secret, $timestamp, $nonce, $method, $path, $body),
    ];
}

/**
 * Verify a request BotGG sends to your bridge. $headers = lower-case names, $rawBody = file_get_contents('php://input').
 * $claimNonce($nonce) must return true only the first time a nonce is seen (store nonces for 10 minutes).
 */
function botgg_verify(string $secret, string $method, string $path, array $headers, string $rawBody, ?int $now = null, ?callable $claimNonce = null): bool
{
    $now = $now ?? time();
    $timestamp = (string) ($headers['x-botgg-timestamp'] ?? '');
    $nonce = (string) ($headers['x-botgg-nonce'] ?? '');
    $given = (string) ($headers['x-botgg-signature'] ?? '');
    if (!preg_match('/^\d{9,11}$/', $timestamp) || abs($now - (int) $timestamp) > BOTGG_TOLERANCE_SECONDS) {
        return false;
    }
    if (!preg_match('/^[0-9a-f]{32}$/', $nonce)) {
        return false;
    }
    if (!hash_equals(botgg_sign($secret, $timestamp, $nonce, $method, $path, $rawBody), $given)) {
        return false;
    }
    return $claimNonce ? (bool) $claimNonce($nonce) : true; // only after the signature matched
}
Node.js
// BotGG Hosting Protocol v1 — sign requests to BotGG and verify requests from BotGG (Node.js 18+, no dependencies).
// Signature: X-BotGG-Signature: v1=<hex HMAC-SHA256(secret, timestamp.nonce.METHOD.path.body)>
import crypto from 'node:crypto';

export const TOLERANCE_SECONDS = 300;

/** The signed string. `path` = the request target exactly as sent (path + ?query), `body` = the raw body ('' if none). */
export function signatureBase({ timestamp, nonce, method, path, body = '' }) {
  return `${timestamp}.${nonce}.${method.toUpperCase()}.${path}.${body}`;
}

/** `v1=<hex>` for one request. The key is the connection secret string itself. */
export function sign(secret, parts) {
  return `v1=${crypto.createHmac('sha256', secret).update(signatureBase(parts), 'utf8').digest('hex')}`;
}

/** Headers for a request you send to BotGG (events, links, handshake). */
export function signedHeaders({ connectionId, secret, method, path, body = '' }) {
  const timestamp = String(Math.floor(Date.now() / 1000));
  const nonce = crypto.randomBytes(16).toString('hex'); // 32 hex characters, new for every request
  return {
    'Content-Type': 'application/json',
    'X-BotGG-Connection': connectionId,
    'X-BotGG-Timestamp': timestamp,
    'X-BotGG-Nonce': nonce,
    'X-BotGG-Signature': sign(secret, { timestamp, nonce, method, path, body }),
  };
}

/**
 * Verify a request BotGG sends to your bridge. `headers` = lower-case names, `rawBody` = the exact body string.
 * `claimNonce(nonce)` must return true only the first time a nonce is seen (store nonces for 10 minutes).
 */
export function verify(secret, { method, path, headers, rawBody }, { now = Date.now(), claimNonce = () => true } = {}) {
  const timestamp = String(headers['x-botgg-timestamp'] ?? '');
  const nonce = String(headers['x-botgg-nonce'] ?? '');
  const given = String(headers['x-botgg-signature'] ?? '');
  if (!/^\d{9,11}$/.test(timestamp) || Math.abs(Math.floor(now / 1000) - Number(timestamp)) > TOLERANCE_SECONDS) return false;
  if (!/^[0-9a-f]{32}$/.test(nonce)) return false;
  const expected = sign(secret, { timestamp, nonce, method, path, body: rawBody });
  if (given.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected))) return false;
  return claimNonce(nonce); // only after the signature matched, so forged requests can't burn nonces
}

// Example: send an event to the events URL from the handshake answer.
//   const body = JSON.stringify(event);
//   const path = new URL(eventsUrl).pathname;
//   await fetch(eventsUrl, { method: 'POST', body, headers: signedHeaders({ connectionId, secret, method: 'POST', path, body }) });
Python
# BotGG Hosting Protocol v1: sign requests to BotGG and verify requests from BotGG (Python 3.8+, standard library only).
# Signature: X-BotGG-Signature: v1=<hex HMAC-SHA256(secret, timestamp.nonce.METHOD.path.body)>
import hashlib
import hmac
import re
import secrets
import time

TOLERANCE_SECONDS = 300


def signature_base(timestamp: str, nonce: str, method: str, path: str, body: str = "") -> str:
    """The signed string. path = the request target exactly as sent (path + ?query), body = the raw body ("" if none)."""
    return f"{timestamp}.{nonce}.{method.upper()}.{path}.{body}"


def sign(secret: str, timestamp: str, nonce: str, method: str, path: str, body: str = "") -> str:
    """v1=<hex> for one request. The key is the connection secret string itself."""
    base = signature_base(timestamp, nonce, method, path, body)
    return "v1=" + hmac.new(secret.encode("utf-8"), base.encode("utf-8"), hashlib.sha256).hexdigest()


def signed_headers(connection_id: str, secret: str, method: str, path: str, body: str = "") -> dict:
    """Headers for a request you send to BotGG (events, links, handshake)."""
    timestamp = str(int(time.time()))
    nonce = secrets.token_hex(16)  # 32 hex characters, new for every request
    return {
        "Content-Type": "application/json",
        "X-BotGG-Connection": connection_id,
        "X-BotGG-Timestamp": timestamp,
        "X-BotGG-Nonce": nonce,
        "X-BotGG-Signature": sign(secret, timestamp, nonce, method, path, body),
    }


def verify(secret: str, method: str, path: str, headers: dict, raw_body: str, now=None, claim_nonce=lambda nonce: True) -> bool:
    """Verify a request BotGG sends to your bridge. headers = lower-case names, raw_body = the exact body string.
    claim_nonce(nonce) must return True only the first time a nonce is seen (store nonces for 10 minutes)."""
    now = time.time() if now is None else now
    timestamp = str(headers.get("x-botgg-timestamp", ""))
    nonce = str(headers.get("x-botgg-nonce", ""))
    given = str(headers.get("x-botgg-signature", ""))
    if not re.fullmatch(r"\d{9,11}", timestamp) or abs(int(now) - int(timestamp)) > TOLERANCE_SECONDS:
        return False
    if not re.fullmatch(r"[0-9a-f]{32}", nonce):
        return False
    expected = sign(secret, timestamp, nonce, method, path, raw_body)
    if not hmac.compare_digest(given, expected):
        return False
    return claim_nonce(nonce)  # only after the signature matched, so forged requests can't burn nonces

Sending events

POST <eventsUrl> with a JSON body { id, type, occurredAt, accountId?, clientId?, data }. You get the events URL (it contains a secret token) from the handshake answer. id is your dedupe key: send the same id again on a retry and BotGG stores the event only once. Body ≤ 64 kB, 120 requests per minute per IP and 600 per connection.

Request
POST /api/hooks/hosting/<token> HTTP/1.1
Host: botgg.app
Content-Type: application/json
X-BotGG-Connection: hcn_0123456789abcdef
X-BotGG-Timestamp: 1795947300
X-BotGG-Nonce: 0123456789abcdef0123456789abcdef
X-BotGG-Signature: v1=224d6f9dc9ec40276bb848f0241702780622abfbf000cb42814abc44007aad27

{"id":"evt_service_suspended_0005","type":"service.suspended","occurredAt":"2026-11-29T10:15:00Z","accountId":"12","clientId":"34","data":{"serviceId":"56","productId":"7","groupId":"2","status":"suspended","reason":"Overdue on payment"}}
Event body (service.suspended)
{
  "id": "evt_service_suspended_0005",
  "type": "service.suspended",
  "occurredAt": "2026-11-29T10:15:00Z",
  "accountId": "12",
  "clientId": "34",
  "data": {
    "serviceId": "56",
    "productId": "7",
    "groupId": "2",
    "status": "suspended",
    "reason": "Overdue on payment"
  }
}
Event types (POST to the events URL)
GroupTypesSend it when
orderorder.created, order.accepted, order.fraudAn order is placed, accepted by staff or marked as fraud.
serviceservice.activated, service.suspended, service.unsuspended, service.terminated, service.cancellationRequested, service.changedA service is activated, suspended, unsuspended, terminated, upgraded / changed, or the customer requests cancellation.
invoiceinvoice.created, invoice.paid, invoice.overdueAn invoice is created, paid or becomes overdue.
ticketticket.opened, ticket.customerReplied, ticket.staffReplied, ticket.closed, ticket.reopenedA panel ticket is opened, answered by the customer or by staff, closed or reopened (ticket sync).
statusstatus.issueA network issue or maintenance is opened, updated or resolved.
productproduct.restockedA sold-out product is back in stock.
Answers
StatusBodyMeaning
202{ "status": "queued" }Stored; the bot processes it within seconds.
200{ "status": "duplicate" }This id was already received: treat it as delivered.
200{ "status": "ignored", "reason": … }Accepted but not used (the feature is off or the connection is paused by the plan). Do not retry.
400{ "error": "bad_request" }Invalid JSON or an unknown / extra field.
401{ "error": "bad_signature" }The signature does not match.
404{ "error": "not_found" }Unknown or disconnected events URL.
409{ "error": "replay" }Stale timestamp or reused nonce.
413 / 429{ "error": … }Body too large / rate limited: retry later.

Send events from an outbox with retries (for example 1 min, 5 min, 30 min, 2 h): a failed delivery must not block the panel’s own hook. Events for accounts without a link are still accepted for staff notifications.

  1. A logged-in customer clicks Connect Discord in your client area. Your module redirects to authorizationEndpoint with client_id, redirect_uri, state, code_challenge (S256) and scope=identify.
  2. The customer logs in with Discord on BotGG and approves. BotGG redirects to your callback with code and state.
  3. Your module exchanges the code at tokenEndpoint (server-to-server, with the client secret and code_verifier) and may call userinfoEndpoint → { sub, username, globalName, avatarUrl }.
  4. Your module calls POST /api/hosting/v1/links (signed) with the account id and the access token. BotGG checks that the token was issued to this connection’s client within the last 10 minutes and takes the Discord id from the token: a module can never claim an arbitrary Discord id.
Create a link
POST https://console.botgg.app/api/hosting/v1/links
{ "accountId": "12", "accessToken": "<the access token from /oauth/token>" }

→ 201 { "ok": true, "accountId": "12", "userId": "876543210987654321", "linkedAt": "2026-11-29T10:15:00.000Z" }
  • Unlink from the panel: DELETE /api/hosting/v1/links/<accountId> (signed, empty body). When the customer unlinks on BotGG’s side, BotGG calls your bridge unlink so you drop your cached mapping.
  • Sign in with Discord: the same OAuth round-trip, then log the linked account in with the panel’s own session mechanism. Never create accounts and never match by e-mail; respect the provider’s 2FA setting (signIn.twoFactor: refuse or allow).
  • Provider endpoints accept bodies up to 16 kB and 120 requests per minute per connection.

Handshake

POST /api/hosting/v1/handshake (signed) is the setup test. BotGG answers and calls your bridge ping in the same request, so both directions are proven and the connection is marked verified. The answer hands the module its events URL and the Sign-in settings; call it again after a settings change.

Handshake
POST https://console.botgg.app/api/hosting/v1/handshake
{ "module": "custom", "moduleVersion": "1.0.0", "platformVersion": "2.4", "protocol": 1 }

→ 200 {
  "ok": true,
  "protocol": 1,
  "connectionId": "hcn_0123456789abcdef",
  "eventsUrl": "https://console.botgg.app/api/hooks/hosting/<token>",
  "linksUrl": "https://console.botgg.app/api/hosting/v1/links",
  "oauth": {
    "issuer": "https://console.botgg.app",
    "authorizationEndpoint": "https://console.botgg.app/oauth/authorize",
    "tokenEndpoint": "https://console.botgg.app/oauth/token",
    "userinfoEndpoint": "https://console.botgg.app/oauth/userinfo",
    "redirectUri": "https://billing.example.com/<your callback path>"
  },
  "signIn": { "enabled": false, "twoFactor": "refuse" },
  "bridge": { "ok": true }
}

The bridge

One HTTPS URL that answers signed POST { "op": "<op>", "params": { … } } requests from BotGG with JSON. BotGG waits at most 5 s and reads at most 512 kB; services asks for up to 50 accounts at once. Verify every request (signature, ±300 s, nonce) before doing anything.

services
POST https://billing.example.com/<your bridge path>
X-BotGG-Connection / X-BotGG-Timestamp / X-BotGG-Nonce / X-BotGG-Signature (signed by BotGG)

{"op":"services","params":{"accountIds":["12","99"]}}

→ 200 {
  "accounts": [
    {
      "accountId": "12",
      "linked": true,
      "services": [
        {
          "serviceId": "56",
          "clientId": "34",
          "productId": "7",
          "groupId": "2",
          "product": "Minecraft 4 GB",
          "label": "mc.example.net",
          "status": "active",
          "nextDueDate": "2026-12-29",
          "manageUrl": "https://billing.example.com/clientarea.php?action=productdetails&id=56",
          "panel": {
            "kind": "pterodactyl",
            "powerable": true
          }
        },
        {
          "serviceId": "57",
          "clientId": "34",
          "productId": "11",
          "groupId": "3",
          "product": "VPS S",
          "label": null,
          "status": "suspended",
          "nextDueDate": "2026-11-20",
          "manageUrl": null,
          "panel": null
        }
      ]
    },
    {
      "accountId": "99",
      "linked": false,
      "services": []
    }
  ]
}
Bridge ops (BotGG → your bridge)
OpparamsAnswerImplementAccounts
ping—{ ok, module, moduleVersion, platformVersion, protocol, capabilities }requiredany
catalog—{ groups, products, departments, promos }requiredany
services{ accountIds }{ accounts }requiredlinked accounts only
invoices{ accountId }{ invoices, summary }requiredlinked accounts only
status—{ issues }optional (capability)any
unlink{ accountId }{ ok }requiredlinked accounts only
ticket.open{ accountId, departmentId, subject, message, serviceId, originId, attachments }{ ticketId }optional (capability)linked accounts only
ticket.reply{ accountId, ticketId, message, authorName, staff, originId }{ ticketId }optional (capability)linked accounts only
ticket.close{ accountId, ticketId, originId }{ ticketId }optional (capability)linked accounts only
panel.power{ accountId, serviceId, signal }{ ok }optional (capability)linked accounts only
panel.state{ accountId, serviceId }{ state, cpu, ramMb }optional (capability)linked accounts only
promo.create{ type, value, productIds, maxUses, expiresAt, code }{ code }optional (capability)any
  • Answer only for linked accounts (except the ops marked “any”), only for clients the account owns, and only with fields the provider enabled (hostnames off → label: null). An unknown or unlinked account in services comes back as { accountId, linked: false, services: [] }.
  • Statuses are normalized: services pending | active | suspended | terminated | cancelled | fraud | completed; invoices unpaid | overdue | paymentPending.
  • Write ops (tickets, power, promo codes) re-check the link and ownership on every call, are rate-limited and are logged in the panel’s activity log too.

Errors

Errors are a 4xx (5xx for internal) status with { "error": "<code>", "message"?: "…" }. BotGG treats unauthorized, bad_signature and replay as a broken connection; the rest are normal business answers.

Error codes
errorHTTPMeaning
bad_request400The body or params are invalid.
unauthorized401Missing or unknown credentials (connection id, token).
bad_signature401The signature does not match.
replay409The timestamp is outside ±300 s or the nonce was already used.
not_linked403The account is not linked to a Discord user.
not_owner403The account does not own this service, or a token belongs to another connection.
not_found404Unknown account, service, ticket or path.
not_supported400The op is not implemented (announce only what you support).
disabled403The provider switched this feature off in the module settings.
inactive409The service is not active (for example power buttons on a suspended server).
rate_limited429Too many requests; retry later.
internal500Unexpected error on the answering side.

Bridge health is shown on the connection in the console: after 5 failures in a row the owner sees a warning, after 30 minutes down the staff get a DM, and role sync pauses (it never mass-removes roles while the bridge fails).

Capabilities

Every module must implement ping, catalog, services, invoices, unlink. Everything else is announced in ping.capabilities[]; the console hides what your module doesn’t support, and BotGG never calls an op you didn’t announce.

Capabilities (ping.capabilities[])
CapabilityMeans
statusThe status op: open network issues and maintenance.
ticket.openTicket sync: open a panel ticket from Discord.
ticket.replyTicket sync: post a reply to a panel ticket.
ticket.closeTicket sync: close a panel ticket.
panel.powerStart / Stop / Restart buttons for game servers (Pterodactyl / Pelican).
panel.stateGame server state, CPU and RAM next to the power buttons.
promo.createDiscord-only promo codes created in the panel.
signIn“Sign in with Discord” on the panel login page.
stockcatalog reports stock (restock alerts).
hostnamesServices carry a label (hostname / domain).
events.orderThe module sends order.* events.
events.serviceThe module sends service.* events.
events.invoiceThe module sends invoice.* events.
events.ticketThe module sends ticket.* events.
events.statusThe module sends status.* events.
events.productThe module sends product.* events.

Test your implementation

The protocol test-suite checks every op and every event shape against a running module. It is read-only unless you allow writes.

Protocol test-suite (BotGG monorepo)
npm run hosting:protocol-test -- --url https://billing.example.com/<bridge path> --key <connection key>

  --account <id>   a linked test account (services, invoices, panel.state)
  --service <id>   a service of that account
  --allow-writes   also run ticket.*, promo.create and panel.power (creates real rows)
  --listen <port>  validate the events your module sends to http://127.0.0.1:<port>/events

Install guides for the ready-made modules: WHMCS, Blesta, Paymenter.

Frequently asked questions

Do I need one of the modules?

No. The modules are reference implementations. Any panel that sends signed events, answers the bridge ops and does the OAuth round-trip works the same way; choose “Custom billing system” in the console.

Why does BotGG call the bridge instead of trusting events?

So that a forged, replayed or out-of-order event can never grant or remove anything: roles are always computed from what your panel says right now.

Which clock does the timestamp use?

Unix time in seconds, UTC. Keep the server clock synced (NTP): requests more than 300 seconds off are refused as replays.

Ready to level up your server?

Add BotGG for free, then switch features on in the web console.