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.
accountIdis 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.
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-Connectionon 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, scopeidentify, 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:
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)>pathis the request target exactly as sent: path and query string (/index.php?m=botgg&action=bridge).bodyis 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.
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
// 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
}// 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 }) });# 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 noncesSending 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.
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"}}{
"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"
}
}| Group | Types | Send it when |
|---|---|---|
order | order.created, order.accepted, order.fraud | An order is placed, accepted by staff or marked as fraud. |
service | service.activated, service.suspended, service.unsuspended, service.terminated, service.cancellationRequested, service.changed | A service is activated, suspended, unsuspended, terminated, upgraded / changed, or the customer requests cancellation. |
invoice | invoice.created, invoice.paid, invoice.overdue | An invoice is created, paid or becomes overdue. |
ticket | ticket.opened, ticket.customerReplied, ticket.staffReplied, ticket.closed, ticket.reopened | A panel ticket is opened, answered by the customer or by staff, closed or reopened (ticket sync). |
status | status.issue | A network issue or maintenance is opened, updated or resolved. |
product | product.restocked | A sold-out product is back in stock. |
| Status | Body | Meaning |
|---|---|---|
| 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.
Account links and BotGG Sign-in
- A logged-in customer clicks Connect Discord in your client area. Your module redirects to
authorizationEndpointwithclient_id,redirect_uri,state,code_challenge(S256) andscope=identify. - The customer logs in with Discord on BotGG and approves. BotGG redirects to your callback with
codeandstate. - Your module exchanges the code at
tokenEndpoint(server-to-server, with the client secret andcode_verifier) and may calluserinfoEndpoint→{ sub, username, globalName, avatarUrl }. - 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.
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 bridgeunlinkso 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:refuseorallow). - 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.
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.
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": []
}
]
}| Op | params | Answer | Implement | Accounts |
|---|---|---|---|---|
ping | — | { ok, module, moduleVersion, platformVersion, protocol, capabilities } | required | any |
catalog | — | { groups, products, departments, promos } | required | any |
services | { accountIds } | { accounts } | required | linked accounts only |
invoices | { accountId } | { invoices, summary } | required | linked accounts only |
status | — | { issues } | optional (capability) | any |
unlink | { accountId } | { ok } | required | linked 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 inservicescomes back as{ accountId, linked: false, services: [] }. - Statuses are normalized: services
pending | active | suspended | terminated | cancelled | fraud | completed; invoicesunpaid | 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 | HTTP | Meaning |
|---|---|---|
bad_request | 400 | The body or params are invalid. |
unauthorized | 401 | Missing or unknown credentials (connection id, token). |
bad_signature | 401 | The signature does not match. |
replay | 409 | The timestamp is outside ±300 s or the nonce was already used. |
not_linked | 403 | The account is not linked to a Discord user. |
not_owner | 403 | The account does not own this service, or a token belongs to another connection. |
not_found | 404 | Unknown account, service, ticket or path. |
not_supported | 400 | The op is not implemented (announce only what you support). |
disabled | 403 | The provider switched this feature off in the module settings. |
inactive | 409 | The service is not active (for example power buttons on a suspended server). |
rate_limited | 429 | Too many requests; retry later. |
internal | 500 | Unexpected 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.
| Capability | Means |
|---|---|
status | The status op: open network issues and maintenance. |
ticket.open | Ticket sync: open a panel ticket from Discord. |
ticket.reply | Ticket sync: post a reply to a panel ticket. |
ticket.close | Ticket sync: close a panel ticket. |
panel.power | Start / Stop / Restart buttons for game servers (Pterodactyl / Pelican). |
panel.state | Game server state, CPU and RAM next to the power buttons. |
promo.create | Discord-only promo codes created in the panel. |
signIn | “Sign in with Discord” on the panel login page. |
stock | catalog reports stock (restock alerts). |
hostnames | Services carry a label (hostname / domain). |
events.order | The module sends order.* events. |
events.service | The module sends service.* events. |
events.invoice | The module sends invoice.* events. |
events.ticket | The module sends ticket.* events. |
events.status | The module sends status.* events. |
events.product | The 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.
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>/eventsInstall guides for the ready-made modules: WHMCS, Blesta, Paymenter.