Skip to content

Webhooks and signature verification

QProctor sends a JSON POST to your URL for the events you subscribe to. The body is a flat object: id, event, created_at, org_id plus the event's own fields.

Headers

X-QProctor-EventEvent name (e.g. oturum.bitti)
X-QProctor-DeliveryDelivery id. Same as id in the body. Unchanged across retries; use it to de-duplicate.
X-QProctor-TimestampSend time (Unix seconds)
X-QProctor-Signaturet=<timestamp>,v1=<hex HMAC-SHA256(webhook secret, "<timestamp>." + raw body)>
X-Proctor-SignatureLegacy sha256=<hex HMAC(secret, body)>. Kept for backwards compatibility. It has no timestamp, so don't use it in new integrations.

Verification rules

  1. Compute the signature over the raw body. Do not parse and re-serialise the JSON first.
  2. Reject the request if t is more than 5 minutes old (replay protection).
  3. Compare in constant time (timingSafeEqual / compare_digest).
  4. The webhook secret is per organisation. In the sandbox it is in the console, on live in the panel (API & integrations). Keep it on your server only.
  5. Respond fast (2xx within 10 s) and queue heavy work.
// Node 18+ / Express: ham gövdeyle doğrulayın (JSON ayrıştırmadan ÖNCE)
import crypto from "node:crypto";
import express from "express";

const SECRET = process.env.QP_WEBHOOK_SECRET;   // konsol / panel › API › webhook anahtarı
const app = express();

app.post("/qproctor", express.raw({ type: "application/json" }), (req, res) => {
  const sig = req.get("X-QProctor-Signature") || "";          // t=1794903600,v1=ab12…
  const parts = Object.fromEntries(sig.split(",").map(p => p.split("=", 2)));
  const t = Number(parts.t);
  if (!t || Math.abs(Date.now() / 1000 - t) > 300) return res.sendStatus(400);   // ±5 dk

  const expected = crypto.createHmac("sha256", SECRET)
    .update(`${parts.t}.`).update(req.body).digest("hex");
  const a = Buffer.from(expected), b = Buffer.from(parts.v1 || "");
  if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) return res.sendStatus(401);

  const event = JSON.parse(req.body);
  // Aynı teslimat yeniden gelebilir: event.id (= X-QProctor-Delivery) ile tekrarı ayıklayın
  console.log(event.event, event.session_id);
  res.sendStatus(204);
});
app.listen(3000);

Delivery rules

Testing

POST /api/v1/kancalar/{id}/test sends a sample event marked "test": true to your subscription and returns your receiver's HTTP status. Sample bodies are in the API reference and at GET /api/v1/olaylar/{event}/ornek.