Skip to content

Webhooks

Webhooks

Le Webhooks, faigheann tú fógraí fíor-ama nuair a tharlaíonn imeachtaí i do spás oibre — m.sh. nuair a scanann duine cód QR.

Webhook a chruthú

Terminal window
POST /v1/webhooks
{
"url": "https://example.com/webhooks/qr3",
"events": ["qr.scanned", "qr.created"],
"secret": "my-secret-key-min-16-chars"
}

Freagra

{
"id": "wh_abc123",
"url": "https://example.com/webhooks/qr3",
"events": ["qr.scanned", "qr.created"],
"is_active": true,
"secret": "my-secret-key-min-16-chars",
"secret_hint": "my-s…",
"created_at": "2026-03-15T10:00:00.000Z"
}

Cineálacha Imeachtaí

ImeachtCur síos
*Gach imeacht
qr.createdCód QR cruthaithe
qr.updatedCód QR nuashonraithe (URL, stádas, clibeanna)
qr.deletedCód QR scriosta
qr.scannedCód QR scanta
qr.flaggedCód QR marcáilte mar neamhshábháilte
scan.createdImeacht scanta (ailias do qr.scanned)
workspace.updatedSpás oibre nuashonraithe
webhook.pingPing tástála (tríd an gcríochphointe /ping)

Formáid an Phálasta

Tá an fhormáid seo ag gach pálasta Webhook:

{
"id": "evt_abc123xyz",
"type": "qr.scanned",
"created": "2026-03-15T10:00:00.000Z",
"data": {
"code_id": "qr_abc123",
"short_code": "r7f3Kx",
"scan_id": "scn_xyz",
"country": "AT",
"device_type": "mobile",
"os": "iOS"
}
}

Fíorú Sínithe

qr3.app síníonn gach iarratas Webhook le HMAC-SHA256:

X-QR3-Signature: sha256=a1b2c3d4e5f6...

Fíorú a chur i bhfeidhm

import crypto from "crypto";
function verifySignature(
payload: string,
signature: string,
secret: string
): boolean {
const expected = crypto
.createHmac("sha256", secret)
.update(payload)
.digest("hex");
const received = signature.replace("sha256=", "");
return crypto.timingSafeEqual(
Buffer.from(expected, "hex"),
Buffer.from(received, "hex")
);
}
// In Express:
app.post("/webhooks/qr3", (req, res) => {
const signature = req.headers["x-qr3-signature"] as string;
const valid = verifySignature(
JSON.stringify(req.body),
signature,
process.env.QR3_WEBHOOK_SECRET
);
if (!valid) return res.status(401).json({ error: "Invalid signature" });
const event = req.body;
console.log(event.type, event.data);
res.json({ received: true });
});

Loighic Atrialach

I gcás earráidí (HTTP >= 300 nó teorainn ama), déanann qr3.app iarracht an seachadadh a dhéanamh arís:

IarrachtMoill
1Láithreach
21 nóiméad
35 nóiméad

Tar éis 10 dteip as a chéile, díchonófar an Webhook go huathoibríoch.

Logaí Seachadta

Terminal window
GET /v1/webhooks/:id/deliveries
{
"data": [
{
"id": "whd_abc123",
"event_type": "qr.scanned",
"status": "success",
"status_code": 200,
"response_time_ms": 145,
"attempt": 1,
"created_at": "2026-03-15T10:00:00.000Z"
}
]
}

Ping Tástála

Tástáil Webhook láithreach:

Terminal window
POST /v1/webhooks/:id/ping

Seolann sé seo imeacht webhook.ping chuig do URL críochphointe.