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-Event | Event name (e.g. oturum.bitti) |
|---|---|
X-QProctor-Delivery | Delivery id. Same as id in the body. Unchanged across retries; use it to de-duplicate. |
X-QProctor-Timestamp | Send time (Unix seconds) |
X-QProctor-Signature | t=<timestamp>,v1=<hex HMAC-SHA256(webhook secret, "<timestamp>." + raw body)> |
X-Proctor-Signature | Legacy sha256=<hex HMAC(secret, body)>. Kept for backwards compatibility. It has no timestamp, so don't use it in new integrations. |
Verification rules
- Compute the signature over the raw body. Do not parse and re-serialise the JSON first.
- Reject the request if
tis more than 5 minutes old (replay protection). - Compare in constant time (
timingSafeEqual/compare_digest). - 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.
- 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);# Flask: ham gövdeyle doğrulayın (request.get_data), JSON ayrıştırmadan ÖNCE
import hashlib, hmac, os, time
from flask import Flask, abort, request
SECRET = os.environ["QP_WEBHOOK_SECRET"].encode() # konsol / panel › API › webhook anahtarı
app = Flask(__name__)
@app.post("/qproctor")
def qproctor():
parts = dict(p.split("=", 1) for p in request.headers.get("X-QProctor-Signature", "").split(",") if "=" in p)
t = parts.get("t", "")
if not t.isdigit() or abs(time.time() - int(t)) > 300: # ±5 dk
abort(400)
body = request.get_data()
expected = hmac.new(SECRET, t.encode() + b"." + body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, parts.get("v1", "")):
abort(401)
event = request.get_json()
# Aynı teslimat yeniden gelebilir: event["id"] (= X-QProctor-Delivery) ile tekrarı ayıklayın
print(event["event"], event.get("session_id"))
return "", 204# İmzayı elle hesaplamak (hata ayıklama) / compute a signature by hand (debugging)
T=$(date +%s)
BODY='{"id":"test","event":"oturum.bitti"}'
printf '%s.%s' "$T" "$BODY" | openssl dgst -sha256 -hmac "$QP_WEBHOOK_SECRET" -hex
# → v1 değeri; başlık: X-QProctor-Signature: t=$T,v1=<değer>
Delivery rules
- A non-2xx response is retried after 5 s and 30 s (3 attempts in total). 4xx responses (except 429) are not retried.
- Responding
410 Gonedeletes the subscription (Zapier REST Hooks rule). - After 20 consecutive failures the subscription is disabled. You can re-enable it in the panel.
- Redirects are not followed. The URL must be HTTPS on port 443 or 8443 and publicly reachable. Private IP ranges, localhost, metadata addresses such as
169.254.169.254, and names that resolve to internal networks are rejected both when you subscribe and when we deliver. - If an exam has
result_webhookin its settings, the session summary is posted there when a session ends, with the same signature headers.
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.