API and webhooks

PitwallWP has an API for your own tools (reporting, Zapier, Make, n8n, scripts) and a webhook that sends every alert to your address as it happens. An owner sets both up in Settings, API and webhooks.

Getting started

  1. In Settings, API and webhooks, name a key after what it is for and choose Read only or Read and write.
  2. Copy the key straight away. It starts with pw_; PitwallWP keeps only a fingerprint and cannot show it again.
  3. Send it in the Authorization header of every request, to your dashboard’s address followed by /api/v1.
curl https://YOUR-DASHBOARD/api/v1/sites \
  -H "Authorization: Bearer pw_your_key"

Every answer is JSON. Times are Unix seconds (UTC); days are written YYYY-MM-DD.

Keys and limits

Key What it can do
Read only Every GET request below.
Read and write Also the POST requests: check, update, back up, file check, clear the cache, planned maintenance.
  • At most 120 requests a minute per key.
  • Everything a key does is written in Activity as api: key name.
  • Revoke stops a key at once. A revoked key can then be deleted to keep the list tidy; what it did stays in Activity.

Errors

The status code says what kind of problem it is, and the body explains it in a sentence:

{ "error": "This is a read-only key: make a write key for this." }
Status What happened
401 No key, a wrong key or a revoked one.
403 A read-only key tried to change something.
404 No such route, or no such site.
429 More than 120 requests this minute. Wait for the next one.
400, 502 The site could not do it: an older PitwallWP Connect, or the site did not answer. The error says which.

Sites

GET/api/v1/sitesread key

Every site with its state: versions, updates waiting, vulnerabilities, uptime, the last backup and the health score. health.parts lists the points lost and why, worst first; grade is great (90 and up), good (75), fair (50) or poor.

Example answer

{
  "sites": [
    {
      "id": 12,
      "name": "Atlantic Tours",
      "url": "https://atlantictours.pt/",
      "wp": "6.8.3",
      "php": "8.3.14",
      "plugin_updates": 3,
      "theme_updates": 0,
      "vulnerable": 0,
      "up": true,
      "up_ms": 412,
      "backup_at": 1791513562,
      "checked_at": 1791515769,
      "health": {
        "score": 89,
        "grade": "good",
        "parts": [[6, "Updates waiting"], [5, "PHP fatal errors"]]
      }
    }
  ]
}
GET/api/v1/sites/{id}read key

One site in full: its report from PitwallWP Connect (plugins, themes, users, settings), the last file check, backups and recent activity. It is large, so ask for one site at a time.

Alerts and activity

GET/api/v1/alerts?limit=60read key

The latest alerts, newest first. level is bad (urgent), warn, ok (good news) or info. limit defaults to 60.

Example answer

{
  "alerts": [
    {
      "id": 39,
      "at": 1791517083,
      "level": "warn",
      "kind": "alert",
      "title": "Plugin activated on Atlantic Tours: Fluent Forms",
      "body": "Expected? Nothing to do. If not, look at who did it."
    }
  ]
}
GET/api/v1/eventsread key

Activity, with the same filters as the page:

Parameter Filters by
site A site’s id.
kind update, backup, login and so on; the answer lists every kind.
who team (people) or auto (PitwallWP itself).
q Words in the message.
from, to Days, YYYY-MM-DD, Lisbon time.
limit Up to 500; 200 when left out.
format=csv A CSV file instead of JSON.

more is true when there are older events: narrow with from and to.

Example answer

{
  "events": [
    {
      "id": 1447,
      "site_id": 12,
      "at": 1791557453,
      "who": "[email protected]",
      "kind": "update",
      "message": "Updated WooCommerce 9.3.1 to 9.3.2",
      "site_name": "Atlantic Tours",
      "site_url": "https://atlantictours.pt/"
    }
  ],
  "kinds": ["autopilot", "backup", "login", "update"],
  "more": true
}

Insights and plugins

GET/api/v1/insights?month=YYYY-MMread key

The month across all sites: average health and grades, the work done (updates, backups, reports, checks, downtime), the time saved in minutes, clients at risk with the reasons, the busiest sites and the team. Without month, this month so far.

Example answer, shortened

{
  "month": "2026-09",
  "portfolio": { "sites": 24, "avg": 87, "prevAvg": 83, "grades": { "great": 11, "good": 9, "fair": 3, "poor": 1 } },
  "work": { "updates": 212, "backups": 720, "reports": 24, "downtimeMin": 45 },
  "saved": { "minutes": 4210 },
  "atRisk": [
    { "id": 31, "name": "Rota do Vinho", "reasons": ["down about 2 h this month", "health 45"] }
  ]
}
GET/api/v1/pluginsread key

Every plugin and theme across the sites, each with the sites that have it (version, active, update waiting, vulnerable), and every administrator with their sites.

Actions

These need a write key and act on one site. They are the same actions as the buttons in PitwallWP, with the same checks.

POST/api/v1/sites/{id}/refreshwrite key

Check the site now: its report, uptime and updates.

POST/api/v1/sites/{id}/updatewrite key

Update with the usual safe update: a copy first, the home page checked after, a rollback if it breaks. Send {"all": true} for everything waiting, or pick: {"plugins": ["woocommerce/woocommerce.php"], "themes": ["astra"], "core": true} (plugins by their file, themes by their folder). If someone on the team is updating the site right now, the answer is an error that says who; send "force": true to go ahead anyway.

Example request

curl -X POST https://YOUR-DASHBOARD/api/v1/sites/12/update \
  -H "Authorization: Bearer pw_your_key" \
  -H "Content-Type: application/json" \
  -d '{"all": true}'
POST/api/v1/sites/{id}/backupwrite key

Back up the database now.

POST/api/v1/sites/{id}/scanwrite key

Run the file check now.

POST/api/v1/sites/{id}/cache-clearwrite key

Clear the page cache, on sites with a page cache plugin PitwallWP knows.

POST/api/v1/sites/{id}/maintenancewrite key

Planned maintenance: {"minutes": 60, "note": "Moving to a new server"}, for up to 7 days (10080 minutes). Alerts are muted and the time is left out of the uptime. {"minutes": 0} ends it.

Webhook

In Settings, API and webhooks, set an https address and choose every alert or only urgent ones. PitwallWP sends each alert once, as a POST with JSON, and waits up to 5 seconds for an answer. If your address is down, the alert is still in the bell and on Telegram. Send a test sends one with "event": "test".

POST /your-endpoint HTTP/1.1
Content-Type: application/json
User-Agent: Pitwall-Webhook/1
X-Pitwall-Signature: t=1791517083,v1=5f2c8e…

{
  "event": "alert",
  "dashboard": "Northwind Studio",
  "level": "bad",
  "kind": "alert",
  "title": "Atlantic Tours is down",
  "body": "No answer for 10 minutes.",
  "at": 1791517083
}

Checking the signature

Every request is signed with your webhook secret (whsec_…, on the same page). Take the header X-Pitwall-Signature: t=…,v1=…, compute the HMAC-SHA256 of t, a dot and the raw body, in hex, and compare it with v1. Refuse it when t is more than 5 minutes old. Use the body exactly as it arrived, before reading the JSON.

Node.js

import crypto from 'node:crypto';

// rawBody: the request body exactly as received (a string), before JSON.parse.
function verifyPitwall(rawBody, header, secret) {
  const { t, v1 = '' } = Object.fromEntries(header.split(',').map(p => p.split('=')));
  const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
  return fresh && expected.length === v1.length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
}

PHP

function pitwall_verify(string $raw, string $header, string $secret): bool {
    parse_str(str_replace(',', '&', $header), $p);
    $expected = hash_hmac('sha256', ($p['t'] ?? '') . '.' . $raw, $secret);
    return abs(time() - (int) ($p['t'] ?? 0)) < 300 && hash_equals($expected, $p['v1'] ?? '');
}

$ok = pitwall_verify(file_get_contents('php://input'), $_SERVER['HTTP_X_PITWALL_SIGNATURE'] ?? '', 'whsec_…');

Python

import hmac, hashlib, time

def verify_pitwall(raw: bytes, header: str, secret: str) -> bool:
    p = dict(part.split("=", 1) for part in header.split(","))
    expected = hmac.new(secret.encode(), p["t"].encode() + b"." + raw, hashlib.sha256).hexdigest()
    return abs(time.time() - int(p["t"])) < 300 and hmac.compare_digest(expected, p.get("v1", ""))

Answer with any 2xx status. New secret replaces the secret, and the old one stops working at once.

Help

Stuck on something?

Write to us. The people who build PitwallWP answer you.