Skip to content

Outgoing webhooks ​

This page explains the webhooks MoorCP Shared sends to your systems: the available events, payload format, how to verify signatures, the retry schedule, and redelivery. With webhooks, billing or monitoring does not need to poll GET /v1/jobs/{id} to learn that an account is active, a suspend worked, or a backup failed.

Who can manage webhooks ​

CreatorEvents receivedURL rules
Admin (admin staff or admin API key)All eventshttp or https, without user:password
Billing keyOnly events for accounts with the same billingOwner (jobs and account alerts). Events without an account, such as server alerts, are not sent.Must be https to a public address. Localhost, private IPs, link-local (169.254.169.254), and *.internal are refused. The destination IP is checked again on every connection, redirects and proxies are not followed, and delivery errors do not reveal the address or port that was tried.

Webhooks owned by a billing key can only be viewed, changed, deleted, tested, and redelivered by the same owner. Staff other than admins cannot manage webhooks.

Events ​

Events come from two sources.

Finished jobs ​

Each job below fires <kind>.succeeded or <kind>.failed when it finishes for good:

GroupJob kinds
Accountsaccount.provision, account.suspend, account.unsuspend, account.terminate, account.change_package, account.purge, account.move
Websites and SSLwebsite.provision, website.delete, ssl.issue, ssl.install
Backupbackup.run, backup.restore, backup.check, backup.restore_test, backup.external (client external backup rule), backup.archive_restore (restore from a portable archive in the account home)
Databasesdb.export, db.import
Appsapp.install, app.wp_update, app.wp_restore, app.wp_clone
Migrationmigration.cpanel_import, migration.wave_account, migration.wave_sync, migration.wave_cutover
Serversserver.switch_webserver
Files and Gitfiles.archive, files.extract, git.deploy

Examples: account.provision.succeeded, backup.run.failed.

A job that staff cancel, stop, or kill (POST /v1/jobs/{id}/cancel) also fires <kind>.failed, with status set to cancelled. A job that was left running by a panel restart is closed after 3 minutes without a heartbeat and fires <kind>.failed with the error code cp.job_abandoned. Check status and errorCode in the payload if you need to tell these cases apart.

INFO

A job that is queued again after a temporary failure does not fire an event yet. The event is only sent when the job succeeds or fails for good.

Alerts ​

EventWhen
alert.openedA new alert appears
alert.escalatedAn alert goes from warning to critical
alert.resolvedThe alert condition is gone

The full catalog is always available at GET /v1/webhooks/events.

Subscription patterns ​

The events field accepts:

PatternExampleMatches
Exact typeaccount.provision.succeededOne type
Prefixaccount.*All account events
Suffix*.failedAll failures
Everything*All events

Patterns that match no type are refused.

Creating a webhook ​

From the GUI ​

  1. Open Settings › Integrations & webhooks.
  2. Click New webhook.
  3. Enter a name and URL, and pick event groups. Other types can be typed in Other event types, separated by commas.
  4. Save. Copy the signing secret that appears, then click I've saved it. The secret is shown only once.

From the API ​

bash
curl -sS -X POST https://panel.example.com:8443/v1/webhooks \
  -H "X-API-Key: API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "billing", "url": "https://billing.example.com/moorcp/hook", "events": ["account.*", "*.failed"]}'

The response contains a secret starting with whsec_. Store it on the receiver, because it cannot be shown again.

Request format ​

Every event is sent as a JSON POST:

json
{
  "id": "EVENT_ID",
  "type": "account.provision.succeeded",
  "occurredAt": "2026-11-01T10:00:00Z",
  "data": {
    "jobId": "JOB_ID",
    "kind": "account.provision",
    "status": "succeeded",
    "serverId": "SERVER_ID",
    "account": {
      "id": "ACCOUNT_ID",
      "username": "jane",
      "serverId": "SERVER_ID",
      "status": "active",
      "billingClientId": "1001",
      "billingServiceId": "svc-10042"
    },
    "requestedBy": "billing-api:mybilling",
    "attempt": 1,
    "finishedAt": "2026-11-01T10:00:00Z"
  }
}
  • Failed job events add errorCode and errorMessage.
  • The job result is not sent, because it can contain sensitive data. Get it with GET /v1/jobs/{jobId}.
  • Alert events contain alertId, kind, severity, message, objectType, objectId, firstAt, and resolvedAt. The account field is set when the alert's object is an account.
  • Text in the payload (for example message, errorMessage) is in Indonesian.

Headers ​

HeaderContent
X-MoorCP-EventEvent type
X-MoorCP-Event-IdEvent ID. The same for every attempt and redelivery.
X-MoorCP-DeliveryDelivery ID. Different for every redelivery.
X-MoorCP-TimestampUnix seconds when the request was signed
X-MoorCP-Signaturesha256= + hex(HMAC-SHA256(secret, timestamp + "." + body))

Verifying the signature ​

The receiver should:

  1. recompute the signature from the raw body (before JSON parsing), and compare it in constant time;
  2. reject timestamps older than 5 minutes, to prevent replay;
  3. filter duplicates by X-MoorCP-Event-Id;
  4. answer 2xx as fast as possible, then process the event in the background.

WARNING

Do not compute the signature from JSON that was parsed and encoded again. Field order or whitespace can change, and the signature will not match.

PHP ​

php
<?php
$secret = getenv('MOORCP_WEBHOOK_SECRET');
$body   = file_get_contents('php://input');
$ts     = $_SERVER['HTTP_X_MOORCP_TIMESTAMP'] ?? '';
$sig    = $_SERVER['HTTP_X_MOORCP_SIGNATURE'] ?? '';

$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
if (!hash_equals($expected, $sig) || abs(time() - (int)$ts) > 300) {
    http_response_code(401);
    exit;
}

$event = json_decode($body, true);
// Store $event['id'] to filter duplicates, then process.
http_response_code(204);

Node.js (Express) ​

js
import crypto from 'node:crypto'
import express from 'express'

const app = express()
const secret = process.env.MOORCP_WEBHOOK_SECRET

app.post('/moorcp/hook', express.raw({ type: 'application/json' }), (req, res) => {
  const ts = req.get('X-MoorCP-Timestamp') ?? ''
  const sig = req.get('X-MoorCP-Signature') ?? ''
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(ts + '.' + req.body)
    .digest('hex')

  const ok = sig.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected))
  if (!ok || Math.abs(Date.now() / 1000 - Number(ts)) > 300) {
    return res.sendStatus(401)
  }

  const event = JSON.parse(req.body)
  // Filter duplicates with event.id, then process in the background.
  res.sendStatus(204)
})

Python (Flask) ​

python
import hashlib, hmac, os, time
from flask import Flask, request, abort

app = Flask(__name__)
SECRET = os.environ["MOORCP_WEBHOOK_SECRET"].encode()

@app.post("/moorcp/hook")
def hook():
    ts = request.headers.get("X-MoorCP-Timestamp", "")
    sig = request.headers.get("X-MoorCP-Signature", "")
    body = request.get_data()
    expected = "sha256=" + hmac.new(SECRET, ts.encode() + b"." + body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(expected, sig) or abs(time.time() - int(ts or 0)) > 300:
        abort(401)
    event = request.get_json()
    # Filter duplicates with event["id"], then process.
    return "", 204

Delivery and retries ​

Events go into an outbox in the panel database, one row per webhook. A control plane restart does not lose events.

  • New events are sent right away. The worker also processes the queue every 5 seconds.

  • Request timeout is 10 seconds. Redirects are not followed.

  • A 2xx response means success. Other responses or network errors are retried after:

    AttemptDelay since previous attempt
    230 seconds
    32 minutes
    410 minutes
    530 minutes
    61 hour
    73 hours
    86 hours

    8 attempts in total over about 10 hours. After that the delivery fails for good.

  • The latest status (lastStatus, lastError, lastAt) shows in the webhook list.

  • Disabling a webhook stops new events. Deliveries still pending fail with "webhook dimatikan" (webhook disabled).

  • Delivery history is kept for 30 days.

TIP

Because an event can arrive more than once (retry or redelivery), make the receiver idempotent: store the X-MoorCP-Event-Id values you processed and ignore them if they come again.

Test, redeliver, and secret rotation ​

ActionGUIAPI
Send a webhook.test eventSend testPOST /v1/webhooks/{id}/test
View delivery historyDeliveriesGET /v1/webhooks/{id}/deliveries
RedeliverRedeliver in the historyPOST /v1/webhooks/{id}/deliveries/{delivery}/redeliver
Rotate secretRotate secretPOST /v1/webhooks/{id}/rotate-secret
Disable or enableDisable / EnablePUT /v1/webhooks/{id} with enabled
DeleteDeleteDELETE /v1/webhooks/{id}
  • The history shows the response code, error, payload, and number of attempts.
  • Redelivery creates a new delivery with the same X-MoorCP-Event-Id, so the receiver can recognize duplicates.
  • Rotating the secret invalidates the old secret immediately. Update the secret on the receiver right after rotating.

WARNING

After rotation, every request still signed with the old secret fails verification. Prepare the receiver to accept the new secret before you press Rotate secret.

Creating, changing, deleting, rotating secrets, and redelivering are recorded in the audit log. The secret never goes into the audit log.

Webhook API ​

MethodPathPurpose
GET/v1/webhooksList (without secrets)
GET/v1/webhooks/eventsEvent catalog
POST/v1/webhooksCreate; the response contains secret
GET, PUT, DELETE/v1/webhooks/{id}View, change (name, url, events, enabled), delete
POST/v1/webhooks/{id}/rotate-secretNew secret
POST/v1/webhooks/{id}/testQueue a webhook.test event
GET/v1/webhooks/{id}/deliveriesDelivery history
POST/v1/webhooks/{id}/deliveries/{delivery}/redeliverRedeliver

See also ​

MoorCP Shared, a shared hosting panel for server fleets.