# Verify JumpCloud webhooks

JumpCloud doesn't sign webhook requests, so there's no signature to check and no SDK to verify one. With Basic Authentication on the channel, each request carries an `Authorization: Basic` header built from the username and password you set, and your endpoint compares both in constant time. That authenticates the sender, but it doesn't protect the body or stop a replay.

Agent skill: `npx skills add hookdeck/webhook-skills --skill jumpcloud-webhooks` ([details](https://hookdeck.com/webhooks/jumpcloud/skill))

> Independent reference generated from hookdeck/webhook-registry (commit ff7f882, 20 Nov 2026). [JumpCloud's official docs](https://jumpcloud.com/support/create-webhook-channels).

[Overview](https://hookdeck.com/webhooks/jumpcloud) · [Webhook events (119)](https://hookdeck.com/webhooks/jumpcloud/events) · [MCP events](https://hookdeck.com/webhooks/jumpcloud/mcp-events) · [Verify signatures](https://hookdeck.com/webhooks/jumpcloud/verify) · [Production guide](https://hookdeck.com/webhooks/jumpcloud/guide-duplicates-ordering-retries-timeouts) · [Agent skill](https://hookdeck.com/webhooks/jumpcloud/skill)

## The facts

| Fact | Value | Source |
|---|---|---|
| Signature header | `None (unsigned)` | [JumpCloud docs](https://jumpcloud.com/support/create-webhook-channels) |
| What to build | `Compare the Basic username and password with your stored values` | [JumpCloud docs](https://jumpcloud.com/support/create-webhook-channels) |
| Key | `shared secret` | [JumpCloud docs](https://jumpcloud.com/support/create-webhook-channels) |

## JumpCloud webhook secret

JumpCloud issues no secret. You choose a username and password and enter them in the Authentication section of the webhook channel. Keep it in an environment variable, not in source code.

- Set them under Settings > Notification Channels > Webhooks, when you create or edit a channel
- Credentials belong to the channel, and one channel can serve many rules and services, so a change applies to all of them
- Edit the channel to rotate them, then update your stored values
- A header marked Sensitive Value, and a value masked in the URL, can't be viewed after saving

Source: [JumpCloud docs](https://jumpcloud.com/support/create-webhook-channels)

## Code

### Express

From [webhook-skills: skills/jumpcloud-webhooks/examples/express/src/index.js](https://github.com/hookdeck/webhook-skills/blob/556a89753e3e66e85d2a3ce50558e95b96c08571/skills/jumpcloud-webhooks/examples/express/src/index.js)

```javascript
// Generated with: jumpcloud-webhooks skill
// https://github.com/hookdeck/webhook-skills
require('dotenv').config({ quiet: true });
const crypto = require('crypto');
const express = require('express');

const app = express();

/**
 * Constant-time string comparison. Hashing both sides first gives equal-length
 * buffers, so timingSafeEqual never throws and the length isn't leaked.
 */
function safeEqual(a, b) {
  const ha = crypto.createHash('sha256').update(String(a)).digest();
  const hb = crypto.createHash('sha256').update(String(b)).digest();
  return crypto.timingSafeEqual(ha, hb);
}

/**
 * Parse "Authorization: Basic base64(username:password)". The scheme is
 * case-insensitive and the value splits on the FIRST colon (passwords may
 * contain colons). Returns null if the header is missing or malformed.
 */
function parseBasicAuth(header) {
  if (typeof header !== 'string') return null;
  const match = /^basic +([A-Za-z0-9+/]+={0,2})$/i.exec(header.trim());
  if (!match) return null;
  const decoded = Buffer.from(match[1], 'base64').toString('utf8');
  const idx = decoded.indexOf(':');
  if (idx < 0) return null;
  return { username: decoded.slice(0, idx), password: decoded.slice(idx + 1) };
}

/**
 * JumpCloud webhook channels are not signed. With Basic Authentication selected,
 * every request carries the channel's username and password. Compare both in
 * constant time and evaluate both before deciding (no short-circuit).
 */
function verifyJumpCloudRequest(
  headers,
  username = process.env.JUMPCLOUD_WEBHOOK_USERNAME,
  password = process.env.JUMPCLOUD_WEBHOOK_PASSWORD
) {
  if (!username || !password) return false; // never accept when unconfigured
  const creds = parseBasicAuth(headers.authorization);
  if (!creds) return false;
  const userOk = safeEqual(creds.username, username);
  const passOk = safeEqual(creds.password, password);
  return userOk && passOk;
}

// JumpCloud documents the field names, but no category values. The event name is di_event.event_type.
function handleAlert(alert) {
  const { alert_id, alert_title, priority, status, category, di_event } = alert;
  console.log(
    `JumpCloud alert ${alert_id} "${alert_title}" [${priority}/${status}] ` +
      `category=${category} event_type=${di_event?.event_type}`
  );
  // Your code: open or update a ticket keyed on alert_id; route on priority and status
}

// Read the body raw (any content type) and authenticate before parsing it.
app.post('/webhooks/jumpcloud', express.raw({ type: '*/*' }), (req, res) => {
  if (!verifyJumpCloudRequest(req.headers)) {
    return res.status(401).json({ error: 'Invalid or missing Basic credentials' });
  }

  let payload;
  try {
    const raw = Buffer.isBuffer(req.body) ? req.body.toString('utf8') : '';
    payload = JSON.parse(raw);
  } catch {
    return res.status(400).json({ error: 'Invalid JSON body' });
  }

  if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
    return res.status(400).json({ error: 'Expected a JSON object' });
  }

  try {
    handleAlert(payload);
  } catch (err) {
    console.error('Error handling JumpCloud alert:', err);
    return res.status(500).json({ error: 'Handler error' });
  }

  res.status(200).json({ received: true });
});

app.get('/health', (req, res) => {
  res.json({ status: 'ok' });
});

module.exports = app;
module.exports.verifyJumpCloudRequest = verifyJumpCloudRequest;
module.exports.parseBasicAuth = parseBasicAuth;

if (require.main === module) {
  const PORT = process.env.PORT || 3000;
  app.listen(PORT, () => {
    console.log(`Server running on http://localhost:${PORT}`);
    console.log(`Webhook endpoint: POST http://localhost:${PORT}/webhooks/jumpcloud`);
  });
}
```

### Next.js

From [webhook-skills: skills/jumpcloud-webhooks/examples/nextjs/app/webhooks/jumpcloud/route.ts](https://github.com/hookdeck/webhook-skills/blob/556a89753e3e66e85d2a3ce50558e95b96c08571/skills/jumpcloud-webhooks/examples/nextjs/app/webhooks/jumpcloud/route.ts)

```typescript
// Generated with: jumpcloud-webhooks skill
// https://github.com/hookdeck/webhook-skills
import { NextRequest, NextResponse } from 'next/server';
import { verifyJumpCloudRequest } from '../../../lib/verify-jumpcloud';

// JumpCloud documents the field names, but no category values. The event name is di_event.event_type.
interface JumpCloudAlert {
  alert_id?: string;
  alert_title?: string;
  category?: string;
  di_event?: { event_type?: string; [key: string]: unknown };
  event_description?: string;
  priority?: string;
  rule_id?: string;
  status?: string;
  [key: string]: unknown;
}

function handleAlert(alert: JumpCloudAlert): void {
  const { alert_id, alert_title, priority, status, category, di_event } = alert;
  console.log(
    `JumpCloud alert ${alert_id} "${alert_title}" [${priority}/${status}] ` +
      `category=${category} event_type=${di_event?.event_type}`
  );
  // Your code: open or update a ticket keyed on alert_id; route on priority and status
}

export async function POST(request: NextRequest) {
  // Authenticate before reading or parsing the body.
  if (!verifyJumpCloudRequest(request.headers)) {
    return NextResponse.json({ error: 'Invalid or missing Basic credentials' }, { status: 401 });
  }

  let payload: unknown;
  try {
    // Read as text so any content type is accepted.
    payload = JSON.parse(await request.text());
  } catch {
    return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });
  }

  if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
    return NextResponse.json({ error: 'Expected a JSON object' }, { status: 400 });
  }

  try {
    handleAlert(payload as JumpCloudAlert);
  } catch (err) {
    console.error('Error handling JumpCloud alert:', err);
    return NextResponse.json({ error: 'Handler error' }, { status: 500 });
  }

  return NextResponse.json({ received: true });
}
```

### FastAPI

From [webhook-skills: skills/jumpcloud-webhooks/examples/fastapi/main.py](https://github.com/hookdeck/webhook-skills/blob/556a89753e3e66e85d2a3ce50558e95b96c08571/skills/jumpcloud-webhooks/examples/fastapi/main.py)

```python
# Generated with: jumpcloud-webhooks skill
# https://github.com/hookdeck/webhook-skills
import base64
import binascii
import hashlib
import hmac
import json
import os
import re

from dotenv import load_dotenv
from fastapi import Depends, FastAPI, HTTPException, Request

load_dotenv()

app = FastAPI()

_BASIC_RE = re.compile(r"^basic +([A-Za-z0-9+/]+={0,2})$", re.IGNORECASE)


def safe_equal(a: bytes, b: bytes) -> bool:
    """Constant-time comparison (compare_digest on equal-length digests of bytes)."""
    return hmac.compare_digest(hashlib.sha256(a).digest(), hashlib.sha256(b).digest())


def parse_basic_auth(header):
    """Parse 'Authorization: Basic base64(username:password)'.

    The scheme is case-insensitive and the value splits on the FIRST colon.
    Returns (username, password) as bytes, or None if missing or malformed.
    """
    if not header:
        return None
    match = _BASIC_RE.match(header.strip())
    if not match:
        return None
    try:
        decoded = base64.b64decode(match.group(1) + "=" * (-len(match.group(1)) % 4), validate=True)
    except (binascii.Error, ValueError):
        return None
    username, sep, password = decoded.partition(b":")
    if not sep:
        return None
    return username, password


def verify_jumpcloud_request(headers, username=None, password=None) -> bool:
    """JumpCloud webhook channels are not signed. With Basic Authentication selected,
    every request carries the channel's username and password. Compare both in
    constant time and evaluate both before deciding (no short-circuit).
    """
    username = username if username is not None else os.environ.get("JUMPCLOUD_WEBHOOK_USERNAME")
    password = password if password is not None else os.environ.get("JUMPCLOUD_WEBHOOK_PASSWORD")
    if not username or not password:
        return False  # never accept when unconfigured
    creds = parse_basic_auth(headers.get("authorization"))
    if creds is None:
        return False
    user_ok = safe_equal(creds[0], username.encode("utf-8"))
    pass_ok = safe_equal(creds[1], password.encode("utf-8"))
    return user_ok and pass_ok


async def require_jumpcloud_basic_auth(request: Request) -> None:
    """FastAPI dependency: reject the request before the body is parsed."""
    if not verify_jumpcloud_request(request.headers):
        raise HTTPException(status_code=401, detail="Invalid or missing Basic credentials")


def handle_alert(alert: dict) -> None:
    # JumpCloud documents the field names, but no category values. The event name is di_event.event_type.
    di_event = alert.get("di_event")
    event_type = di_event.get("event_type") if isinstance(di_event, dict) else None
    print(
        f"JumpCloud alert {alert.get('alert_id')} \"{alert.get('alert_title')}\" "
        f"[{alert.get('priority')}/{alert.get('status')}] "
        f"category={alert.get('category')} event_type={event_type}"
    )
    # Your code: open or update a ticket keyed on alert_id; route on priority and status


@app.post("/webhooks/jumpcloud", dependencies=[Depends(require_jumpcloud_basic_auth)])
async def jumpcloud_webhook(request: Request):
    # Read the raw body so any content type is accepted.
    raw_body = await request.body()

    try:
        payload = json.loads(raw_body)
    except (json.JSONDecodeError, UnicodeDecodeError):
        raise HTTPException(status_code=400, detail="Invalid JSON body")

    if not isinstance(payload, dict):
        raise HTTPException(status_code=400, detail="Expected a JSON object")

    try:
        handle_alert(payload)
    except Exception as err:  # noqa: BLE001
        print(f"Error handling JumpCloud alert: {err}")
        raise HTTPException(status_code=500, detail="Handler error")

    return {"received": True}


@app.get("/health")
async def health():
    return {"status": "ok"}


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=8000)
```

Or install the JumpCloud webhooks skill: `npx skills add hookdeck/webhook-skills --skill jumpcloud-webhooks`

## Common failures

- **Channel set to another authentication type.** With None, Token Authentication or custom headers selected, no Basic credentials arrive. Choose Basic Authentication on the channel, or check the header you configured.
- **Credentials changed on one side.** Editing the username or password on the channel doesn't change your stored values. Update both together.
- **Password split on the wrong colon.** Decode the base64 and split on the first colon only, because a password can contain one.
- **Credentials missing from the first request.** JumpCloud doesn't say whether it sends Basic credentials up front or only after a `401` challenge. Log the headers from a Test Webhook request to see what arrives.

From [Hookdeck's JumpCloud guide](https://hookdeck.com/webhooks/jumpcloud/guide-duplicates-ordering-retries-timeouts).

---

Not affiliated with JumpCloud. Facts are compiled from public sources and linked inline. [View as JSON](https://hookdeck.com/webhooks/jumpcloud.json) · [Report a correction](https://hookdeck.com/contact)
