Webhooks

SecOps can POST a signed JSON event to your HTTPS endpoint when something needs your attention.

Events

EventWhendata fields
case.openedA review or deny opened a case (enforce mode only)case_id, trigger, assessment_id, score, reasons
account.at_riskA correct password followed a run of failuresassessment_id, score, case_id, reasons
merchant.holdA merchant's value-out was frozenhold_id, merchant_id, placed_at, reasons, case_id
merchant.releasedAn analyst released that holdhold_id, merchant_id, released_at
checkout.under_attackA wave of declined cards turned on checkout attack modedeclines, attempts, window_seconds

reasons in webhook data is a list of reason codes, for example ["IP_MANY_USERNAMES"].

Set up your endpoint

In Settings › Account protection › Risk API keys and webhook, enter your URL and click Save webhook.

  • The URL must use https:// and resolve to a public address.
  • The signing secret (whsec_...) is shown once, when you save. Saving again replaces the endpoint and makes a new secret.
  • Disable stops all deliveries.

What a delivery looks like

Example delivery
POST /secops HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
User-Agent: SecOps-Webhooks/1.0
SecOps-Event-Id: evt_5f0c2b9a7d1e4f3a8b6c0d2e
SecOps-Event-Type: case.opened
SecOps-Signature: t=1795000000,v1=6f1c0c4e3b...

{"created":1795000000,"data":{"assessment_id":"ra_01a2347758a00e1dbda70118d8cf","case_id":"case_01a2347758a120a0bbf4ec2464c0","reasons":["DEVICE_MANY_ACCOUNTS","IP_MANY_USERNAMES"],"score":98,"trigger":"decision_deny"},"id":"evt_5f0c2b9a7d1e4f3a8b6c0d2e","type":"case.opened"}

The body always has id, type, created (Unix seconds) and data.

Verify the signature

Every delivery carries:

Signature header
SecOps-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>" with your signing secret>

To check it:

  1. Read the raw request body, before any JSON parsing. Re-serialising the JSON changes the bytes and breaks the signature.
  2. Split the header on , and = to get t and v1.
  3. Reject the delivery if t is more than 5 minutes from your clock. This stops replays.
  4. Compute HMAC-SHA256 with your whsec_... secret over t, a dot, then the raw body, as lowercase hex.
  5. Compare it with v1 in constant time. Answer 400 on any mismatch.
Python
import hashlib
import hmac
import time


def verify_secops_signature(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> bool:
    try:
        fields = dict(part.split("=", 1) for part in header.split(","))
        timestamp = int(fields["t"])
    except (ValueError, KeyError):
        return False
    if abs(time.time() - timestamp) > tolerance:
        return False
    expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, fields.get("v1", ""))


# Flask
from flask import Flask, abort, request

app = Flask(__name__)


@app.post("/secops")
def secops_webhook():
    if not verify_secops_signature(WEBHOOK_SECRET, request.headers.get("SecOps-Signature", ""), request.get_data()):
        abort(400)
    event = request.get_json()
    ...  # handle event["type"], ignore an event["id"] you have already seen
    return "", 204
Node.js (Express)
const crypto = require("crypto");
const express = require("express");

function verifySecOpsSignature(secret, header, rawBody, toleranceSeconds = 300) {
  const fields = Object.fromEntries((header || "").split(",").map((part) => {
    const i = part.indexOf("=");
    return [part.slice(0, i), part.slice(i + 1)];
  }));
  const t = Number(fields.t);
  if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
  const expected = crypto.createHmac("sha256", secret).update(`${t}.`).update(rawBody).digest("hex");
  const given = String(fields.v1 || "");
  return given.length === expected.length && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(given));
}

const app = express();
// express.raw keeps the exact bytes that were signed.
app.post("/secops", express.raw({ type: "application/json" }), (req, res) => {
  if (!verifySecOpsSignature(process.env.SECOPS_WEBHOOK_SECRET, req.get("SecOps-Signature"), req.body)) {
    return res.sendStatus(400);
  }
  const event = JSON.parse(req.body);
  // handle event.type, ignore an event.id you have already seen
  res.sendStatus(204);
});
PHP
<?php
function verify_secops_signature(string $secret, string $header, string $rawBody, int $tolerance = 300): bool {
    $fields = [];
    foreach (explode(',', $header) as $part) {
        [$key, $value] = array_pad(explode('=', $part, 2), 2, '');
        $fields[$key] = $value;
    }
    if (!isset($fields['t']) || !ctype_digit($fields['t']) || abs(time() - (int) $fields['t']) > $tolerance) {
        return false;
    }
    $expected = hash_hmac('sha256', $fields['t'] . '.' . $rawBody, $secret);
    return hash_equals($expected, $fields['v1'] ?? '');
}

$raw = file_get_contents('php://input');
if (!verify_secops_signature(getenv('SECOPS_WEBHOOK_SECRET'), $_SERVER['HTTP_SECOPS_SIGNATURE'] ?? '', $raw)) {
    http_response_code(400);
    exit;
}
$event = json_decode($raw, true);

Retries and duplicates

  • Answer any 2xx within 10 seconds to acknowledge a delivery. The response body is ignored.
  • Anything else (another status, a timeout, a TLS error) is retried after 30 seconds, 2 minutes, 10 minutes, 1 hour and 6 hours. After the last retry it is not sent again.
  • Redirects are not followed. TLS certificates are verified.
  • An event can arrive more than once. Use id (also in SecOps-Event-Id) to ignore repeats, and don't rely on the order of deliveries.

Delivery safety

Before every attempt SecOps checks your URL again and connects to the exact public IP address it checked, so a DNS change can't point deliveries at a private network. Each account's events are queued separately, and no account can send events for another.

Security alert webhooks

Separate from the events above, the dashboard can send security alerts (attacks blocked, incidents, certificate problems) to your own URL. Set it in Settings › Notifications › Notification channels:

  • Generic webhook URL gets the alert as JSON: event (always security_alert), severity, title, details, tenant_id, timestamp (Unix seconds) and text (one line for chat tools).
  • Webhook signing secret is optional. Once it is set, every alert carries a SecOps-Signature header in the same t=...,v1=... form as above, signed with the secret you chose. The verify code in Verify the signature works for it unchanged.
  • Slack webhook URL and Microsoft Teams workflow URL get a formatted message instead. For Teams, create a workflow from the "Post to a channel when a webhook request is received" template and paste its URL.
  • Send test sends one test alert to the saved URL and tells you the answer your server gave.

Alerts are sent once, with no retries. As with the events above, the URL must be public, redirects are not followed and each account only ever reaches its own URLs.

Example security alert
{"details":{"path":"/login","source_ip":"203.0.113.9"},"event":"security_alert","severity":"high","tenant_id":"5c7c11b501992ab7","text":"[HIGH] SQL injection blocked: {\"path\": \"/login\", \"source_ip\": \"203.0.113.9\"}","timestamp":1795000000,"title":"SQL injection blocked"}