Quickstart
Get a risk decision back for a real event in about five minutes.
1. Install the browser SDK
npm install @sentriq/browser2. Get a public key
In the Sentriq dashboard, create an API key for your environment. Copy the public key (pub_test_... in test mode, pub_live_... in live mode). Public keys are safe to embed in browser code — they can only do one thing: POST /v1/events.
3. Initialize the SDK
import { Sentriq } from '@sentriq/browser';
const sentriq = await Sentriq.init({
publicKey: 'pub_test_xxx',
});Never pass a secret key here — Sentriq.init rejects anything that doesn't look like a public key.
4. Report an event
Call track() with a named event and, optionally, your own opaque reference for the end user (never a password or email):
const result = await sentriq.track('login', {
account: { id: 'usr_123' },
});identify() is a thin convenience wrapper around track('page_view') for the cases where you just want a baseline read on the current device/session:
const result = await sentriq.identify();5. Act on the decision
Every response carries a risk object. Your application — not Sentriq — decides what each decision means in practice:
console.log(result.risk.score); // 0-100
console.log(result.risk.level); // 'low' | 'medium' | 'high' | 'critical'
console.log(result.risk.decision); // 'allow' | 'monitor' | 'challenge' | 'block'
switch (result.risk.decision) {
case 'allow':
// proceed normally
break;
case 'monitor':
// proceed, but flag for review in your own tooling
break;
case 'challenge':
// require an extra verification step of your own choosing
// (Sentriq does not provide a CAPTCHA/challenge UI)
break;
case 'block':
// stop the flow
break;
}challenge and block are signals for your own application logic to act on.Handling failures
A security SDK sitting in your login path must never hang or crash the flow silently. Decide explicitly whether to fail open or fail closed:
let risk;
try {
const result = await sentriq.track('login', { account: { id: userId } });
risk = result.risk;
} catch (err) {
// Fail open: Sentriq was unreachable/slow — don't block the login over
// an availability problem with a third-party service.
risk = null;
}
if (risk?.decision === 'block') {
// handle the fail-closed case where Sentriq *did* respond and said block
}Next steps
- Browser SDK reference for the full API, error types, and what's collected.
- REST API to pull device and event detail from your own backend with a secret key.