Billing & Account

API Keys & Webhooks

Generate API keys to automate GHP Cloud and receive webhook events.

4 min read

API Keys & Webhooks

GHP Cloud provides a REST API for reading your sites, backups and domains and for running a few actions (clearing a site's cache, taking a backup). Use API keys for authentication and webhooks to receive real-time events in your own systems.

Generating an API key

1. Click your account name → API & Webhooks

2. Click Generate API Key

3. Give the key a descriptive name (e.g., "CI/CD Pipeline", "Internal Automation")

4. Choose the scopes the key may use: sites:read, sites:write, backups:read, dns:read, dns:write

5. Click Generate

The API key is displayed once — copy it immediately and store it in your secret manager (Vault, AWS Secrets Manager, GitHub Secrets, etc.). It cannot be retrieved again after you close the dialog.

Making API requests

All API requests use the base URL https://api.ghpcloud.com/api/v1/. Include your API key in the Authorization header:

bash
curl -H "Authorization: Bearer ghp_your_api_key_here" \
     https://api.ghpcloud.com/api/v1/sites

API endpoints

GET    /api/v1/status                    API status (no key needed)
GET    /api/v1/sites                     List your sites            (sites:read)
GET    /api/v1/sites/:id                 Get one site's details     (sites:read)
POST   /api/v1/sites/:id/cache/purge     Clear a site's cache       (sites:write)
GET    /api/v1/backups                   List backups               (backups:read)
POST   /api/v1/backups                   Take a backup of a site    (backups:read)
GET    /api/v1/domains                   List domains               (dns:read)

Errors come back as JSON with an error message and the matching HTTP status (401 for a missing or wrong key, 403 for a missing scope, 404 for a site that is not yours).

Setting up webhooks

Webhooks send HTTP POST requests to your endpoint when events occur in GHP Cloud. Click API & Webhooks → Add Webhook:

  • URL — your HTTPS endpoint (must return HTTP 200)
  • Secret — a secret string used to sign webhook payloads (verify it in your handler)
  • Events — choose which events to receive

Available webhook events:

site.created        site.deleted        deploy.success
deploy.failed       backup.completed    backup.failed
ssl.issued          ssl.renewed         site.down
site.up

Each request is a JSON body with event, timestamp and the event's details (for example siteId and domain).

Verifying webhook signatures

GHP Cloud signs every webhook payload with HMAC-SHA256 using your webhook secret, in the X-GHP-Signature header as sha256=<hex>. Verify it against the raw request body (re-serialising parsed JSON can change the bytes):

javascript
const crypto = require('crypto')
// rawBody: the exact bytes received, e.g. express.raw({ type: 'application/json' })
const sig = req.headers['x-ghp-signature'] || ''
const expected = 'sha256=' + crypto.createHmac('sha256', WEBHOOK_SECRET).update(rawBody).digest('hex')
const ok = sig.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected))
if (!ok) return res.status(401).end()

Was this article helpful?

Need help? →