Guides
Keep banned users out
Ban the browsers behind an account, not only the account, and catch a banned user who comes back under a new email, in a private window or behind a VPN.
The threat
You ban an account for cheating, harassment, chargebacks or spam. Ten minutes later the same person is back: a new email, a new username, a private window so your cookies are gone, a VPN so the address is new. An account ban stops the account. It does not stop the person, because nothing they bring to the new account is something you banned.
What they usually bring is the same browser. knownprint gives your backend a visitor id for it, which stays the same across accounts and comes back in a private window or after cookies are cleared whenever knownprint is sure. A ban that records the banned account's visitor ids, and checks them at signup and sign-in, keeps the person out until they change browser or device. Beyond the visitor id, knownprint gives you leads to review: another visitor this browser may be (high_recall_id), and other visitors and accounts related to this browser.
How a ban works with knownprint
- Send your account id with each visit. Every event that happens while someone is signed in carries your account id as its
linked_id. knownprint then knows which browsers each account used. - Ban the browsers, not only the account. When you ban an account, collect every visitor id that carried its account id, resolve their aliases, and store them in your own ban list. Look at your other accounts seen on those browsers too.
- Check every new account and every sign-in against that ban list: the visitor, its aliases, its lead, and the accounts its browser carried.
- Keep the ban list current as visitor ids change, through the
visitor.merged,visitor.unmerged,visitor.splitandvisitor.suggestedwebhooks.
Where to identify
| Moment | Why |
|---|---|
| Signup | The cheapest point to stop a returning user: no new account exists yet |
| Sign-in | Catches a banned user on an account that existed before the ban, or was made on another browser |
| Joining a match, a room, a server or a group | Where the harm is done in games and communities |
| Posting, messaging, listing, reviewing | Where the harm is done on marketplaces and forums |
| Payment | Catches a user banned for chargebacks before they try again |
In the page, call identify() right before the request and send the request id with it (Add the browser agent, protect a form). After sign-in, attach the account to the event from your backend with PATCH /v1/events/{request_id} and a linked_id, so the account is the one your server authenticated and not one the page claims.
// Once, when the page starts. Resolves null when the script is blocked or fails to load.
const agentReady = window.knownprint
? window.knownprint.load({ pk: 'pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }).catch(() => null)
: Promise.resolve(null);
/** A fresh request id, or null when the agent is blocked, fails or takes longer than 3 seconds. */
function requestId(action) {
const timeout = new Promise((resolve) => setTimeout(() => resolve(null), 3000));
const attempt = agentReady
.then((agent) => (agent === null ? null : agent.identify({ tags: { action } })))
.then((result) => (result === null ? null : result.requestId))
.catch(() => null);
return Promise.race([attempt, timeout]);
}
document.querySelector('#signup').addEventListener('submit', async (e) => {
e.preventDefault();
const form = new FormData(e.target);
// null when blocked or failed: sign up without one; the backend treats it as unknown.
const kp_request_id = await requestId('signup');
if (kp_request_id !== null) form.set('kp_request_id', kp_request_id);
await fetch('/signup', { method: 'POST', body: form });
});Which fields to read
| Field | Where | What it tells you |
|---|---|---|
visitor_id | Event | The browser behind this visit. The value you check against your ban list |
confidence | Event | How sure knownprint is about visitor_id, from 0 to 1. Block automatically only above a level you choose |
high_recall_id | Event | Another visitor this browser may also be, named without being merged, or null. A lead for review |
high_recall_probability | Event | How likely the high_recall_id visitor is this browser, from 0 to 1. Absent when there is no such number |
anonymity_set_size | Event | The lookalike count: how many visitors of your environment look like this browser, at least 1. Above 1, give leads less weight |
signals.incognito, signals.vpn, signals.proxy, signals.tor | Event | The visit came from a private window or through a VPN, proxy or Tor. Context for a reviewer |
signals.tampering, signals.virtual_machine | Event | The browser misreports what it is, or runs in a virtual machine: tools people use to get past a ban |
canonical_id, aliases | Visitor | The surviving visitor id and every id merged into it (Visitors) |
linked_ids | Visitor | The distinct linked ids (your account ids) on the visitor's events, up to 100. It shrinks as old events are deleted |
visitors, linked_ids | Related read | Other visitors and accounts related to a browser or an account, each with its evidence |
The related reads are the core of a ban:
| Route | Answers |
|---|---|
GET /v1/linked/{linked_id}/related | visitors: every browser that carried this account id; linked_ids: your other accounts seen on those browsers |
GET /v1/visitors/{visitor_id}/related | visitors: other visitors related to this browser; linked_ids: the account ids this browser carried |
Each entry carries evidence, a list of { kind, detail, weight }, and each list is ordered strongest first, with at most 50 entries. Evidence of kind linked_id means the two share one of your account ids; the other kinds are described with the visitor related read. Both reads are a moderator's aid: they show who to look at, not who someone is. The pairs of browser and account behind them stay after the events that recorded them are deleted, until the visitor or the linked id is deleted or you replace or clear that linked id on its event with PATCH, so the related reads reach back further than the visitor's linked_ids.
Decision table
These are starting points to tune on your own traffic, not knownprint defaults.
| What you see at signup or sign-in | Suggested action |
|---|---|
The visitor, or one of its aliases, is on your ban list, and confidence is at least 0.9 | Block |
The visitor or an alias is banned, and confidence is below 0.9 | Hold for review, or ask for a verified phone number |
high_recall_id (or an alias of it) is banned | Hold for review; order the queue by high_recall_probability |
The related read of the visitor lists a banned visitor with linked_id evidence | Hold for review: the browsers share an account |
| The related read lists a banned visitor with other evidence only | Flag for a reviewer; do not block on it |
The browser carried a banned account (linked_ids of the visitor related read) | Block or review by your policy: the browser was used by the banned account |
A visitor.suggested webhook names a banned visitor beside another | Review the other visitor's accounts |
| Private window, VPN, tampering or a virtual machine, with any lead above | Raise the priority of the review |
| Private window or VPN, no lead | Allow. On their own these describe many honest users |
Backend example
Node 22 with Express 5 and Postgres. Three parts: recording a ban, checking a visitor, and keeping the list current from webhooks. queueBanReview and flagAccountForReview stand for your own review queue.
import crypto from 'node:crypto';
import express from 'express';
import pg from 'pg';
const API = process.env.KNOWNPRINT_API; // the API address that comes with your account
const SECRET = process.env.KNOWNPRINT_SECRET_KEY; // sk_live_..., scopes events:read and events:write
const WEBHOOK_SECRET = process.env.KNOWNPRINT_WEBHOOK_SECRET; // whsec_...
const db = new pg.Pool();
const app = express();
// create table banned_visitors (visitor_id text primary key, account_id text not null,
// banned_at timestamptz default now());
// create table banned_accounts (account_id text primary key, banned_at timestamptz default now());
/** Calls the knownprint API; null on 404 (not found) and 409 (being deleted), throws on other errors. */
async function kp(path, init = {}) {
const res = await fetch(`${API}${path}`, {
...init,
headers: {
Authorization: `Bearer ${SECRET}`,
Accept: 'application/json',
...(init.body ? { 'Content-Type': 'application/json' } : {}),
},
});
if (res.status === 404 || res.status === 409) return null;
if (!res.ok) throw new Error(`knownprint ${res.status}`);
return res.json();
}
/** Every id that names the visitor now: its surviving id and its aliases. */
async function idsOf(visitorId) {
const v = await kp(`/v1/visitors/${visitorId}`);
return v === null ? [visitorId] : [v.visitor_id, ...v.aliases];
}
/** The ids among `ids` that are on the ban list. */
async function bannedAmong(ids) {
if (ids.length === 0) return new Set();
const r = await db.query('select visitor_id from banned_visitors where visitor_id = any($1)', [
ids,
]);
return new Set(r.rows.map((row) => row.visitor_id));
}
async function banIds(ids, accountId) {
for (const id of ids) {
await db.query(
'insert into banned_visitors (visitor_id, account_id) values ($1, $2) on conflict do nothing',
[id, accountId],
);
}
}
/**
* 1. Ban an account and every browser that carried it. Returns your other accounts seen on
* those browsers, for a reviewer to look at.
*/
export async function banAccount(accountId) {
await db.query('insert into banned_accounts (account_id) values ($1) on conflict do nothing', [
accountId,
]);
const related = await kp(`/v1/linked/${encodeURIComponent(accountId)}/related`);
for (const { visitor_id } of related?.visitors ?? []) {
await banIds(await idsOf(visitor_id), accountId);
}
return (related?.linked_ids ?? []).map((l) => l.linked_id);
}
/** 2. Check the visitor of a verified event: 'block', 'review', 'flag' or 'allow'. */
export async function checkVisitor(event) {
if ((await bannedAmong(await idsOf(event.visitor_id))).size > 0) {
return event.confidence >= 0.9 ? 'block' : 'review';
}
if (
event.high_recall_id !== null &&
(await bannedAmong(await idsOf(event.high_recall_id))).size > 0
) {
return 'review';
}
const related = await kp(`/v1/visitors/${event.visitor_id}/related`);
if (related === null) return 'allow';
// The accounts this browser carried: one of them banned means the banned user's browser.
const accounts = related.linked_ids.map((l) => l.linked_id);
if (accounts.length > 0) {
const r = await db.query('select 1 from banned_accounts where account_id = any($1) limit 1', [
accounts,
]);
if (r.rowCount > 0) return 'review';
}
// Other visitors related to this browser: a banned one is a lead.
const banned = await bannedAmong(related.visitors.map((v) => v.visitor_id));
for (const v of related.visitors) {
if (!banned.has(v.visitor_id)) continue;
return v.evidence.some((e) => e.kind === 'linked_id') ? 'review' : 'flag';
}
return 'allow';
}
/** Standard Webhooks check: see /webhooks/verify. Returns the envelope or null. */
function verifyWebhook(headers, rawBody) {
const id = headers['webhook-id'];
const ts = headers['webhook-timestamp'];
const sigs = headers['webhook-signature'];
if (!id || !sigs || !/^[0-9]{1,16}$/.test(ts ?? '')) return null;
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return null;
const key = Buffer.from(WEBHOOK_SECRET.slice('whsec_'.length), 'base64');
const expected = crypto.createHmac('sha256', key).update(`${id}.${ts}.${rawBody}`).digest();
const ok = String(sigs)
.split(' ')
.some((entry) => {
if (!entry.startsWith('v1,')) return false;
const given = Buffer.from(entry.slice(3), 'base64');
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
return ok ? JSON.parse(rawBody) : null;
}
/** 3. Keep the ban list current. */
app.post('/webhooks/knownprint', express.text({ type: '*/*' }), async (req, res) => {
const envelope = verifyWebhook(req.headers, req.body);
if (envelope === null) return res.status(400).end();
const d = envelope.data;
switch (envelope.type) {
case 'visitor.merged': {
// Two ids are one browser: if either was banned, ban both.
const r = await db.query(
'select account_id from banned_visitors where visitor_id = any($1) limit 1',
[[d.alias_id, d.canonical_id]],
);
if (r.rowCount > 0) await banIds([d.alias_id, d.canonical_id], r.rows[0].account_id);
break;
}
case 'visitor.unmerged':
case 'visitor.split': {
// Part of a visitor is another browser after all: a person decides whether the ban fits.
const other = envelope.type === 'visitor.unmerged' ? d.canonical_id : d.parent_id;
if ((await bannedAmong([d.visitor_id, other])).size > 0) {
await queueBanReview(d.visitor_id, other, envelope.type); // your code
}
break;
}
case 'visitor.suggested': {
// A past visitor may also be another visitor: a lead, like high_recall_id.
if ((await bannedAmong([d.visitor_id, d.suggested_id])).size > 0) {
await queueBanReview(d.visitor_id, d.suggested_id, envelope.type); // your code
}
break;
}
case 'account.related_found': {
// A browser now carries more than one account, or an account more than one browser.
if ((await bannedAmong(await idsOf(d.visitor_id))).size > 0) {
await flagAccountForReview(d.linked_id, 'browser_of_banned_account'); // your code
}
break;
}
}
res.status(204).end();
});Your signup and sign-in handlers verify the event first (one use per request id, fresh, not replayed, from your origin: see Verify a request in your backend), then call checkVisitor(event) and act on the answer. After a successful sign-in, attach the account:
curl -X PATCH "$KNOWNPRINT_API/v1/events/$REQUEST_ID" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"linked_id": "acct_8841"}'Subscribe the webhook endpoint to visitor.merged, visitor.unmerged, visitor.split, visitor.suggested and account.related_found (Webhooks API). banAccount returns your other accounts seen on the banned browsers: queue them for a reviewer rather than banning them outright, since a shared computer puts honest accounts there too. Delivery is at least once, so the same delivery can arrive more than once and out of order: the handler above is safe to run twice (Ordering and duplicates). Verify webhook signatures covers the signature check in full.
Reviewing a held account
A reviewer deciding whether a new account is a banned user needs:
- the event, with
confidence,high_recall_id,high_recall_probabilityandanonymity_set_size; - the banned account the lead points to, and why it was banned;
GET /v1/visitors/{visitor_id}/relatedfor the new browser, whose evidence shows what relates it to the banned one;- the events of the banned visitor,
GET /v1/events?visitor_id={visitor_id}, which also returns the events of every alias merged into it, and of the banned account,GET /v1/events?linked_id={linked_id}(Events API).
Record the outcome on the event with POST /v1/events/{request_id}/feedback and a label of fraud or legit (Feedback). If the reviewer finds it is the banned user, call banAccount on the new account too, so its browsers join the list.
Pitfalls
- Blocking on a lead.
high_recall_id, avisitor.suggestedwebhook and a related visitor are reasons to look, not proof. Block automatically only when the visitor itself, or one of its aliases, is banned andconfidenceis high. - Banning a shared computer. A family PC, a school lab or an internet café puts many people on one browser or one device. A visitor id ban there blocks everyone who uses it. Give a reviewed path back in, and treat a ban on a browser seen with many unrelated accounts (
linked_idsof the visitor) with care. - Checking only the id on the event. After a merge, the banned browser may be stored under an alias. Resolve with
GET /v1/visitors/{visitor_id}, checkaliases, and keep the list current withvisitor.merged. After an unmerge or a split, your list may hold an id that is now another browser: review it rather than keep blocking it. - Banning only the visitor of the last visit. A banned user has usually used several browsers.
GET /v1/linked/{linked_id}/relatedlists the ones that carried the account, at most 50; ban them all. For an account past 50 browsers, also pageGET /v1/events?linked_id={linked_id}and collect the visitor ids of its events (within the event retention period). - Letting the page name the account. A
linkedIdpassed toidentify()comes from the browser. Set the account from your backend withPATCH /v1/events/{request_id}once the user is authenticated. - Expecting a ban to be permanent. A determined user can switch to another device. knownprint raises the cost of coming back; it cannot make it impossible. Pair the ban with what your own data shows (payment instruments, phone numbers, behaviour).
- Telling the user what tripped the ban. "Your browser is banned" tells them to change browser. Use a generic message.
- Keeping only knownprint's copy. Events are deleted after your account's event retention period (How long events are kept), and with them the event history behind a visitor. Your ban list is your record; keep the visitor ids in it.
- Forgetting what deletion does. If a banned user asks you to delete their data,
DELETE /v1/visitors/{visitor_id}deletes the visitor with its aliases and events, andDELETE /v1/linked/{linked_id}clears the account id from knownprint and deletes the visitors it leaves with no other account (Delete a linked id). A deleted visitor id never answers again and a later visit from that browser gets a new visitor id, so the ids on your ban list stop matching. Your ban list is yours to handle under your own policy (Privacy).
Related pages
- Visitors and Visitors API: the visitor read, aliases and the visitor related read.
- Accounts and linked ids and Linked ids API: attaching account ids and the related reads.
- Account sharing and multi-accounting: one browser with many accounts, one account on many browsers.
- Stop fake signups: the other checks worth running at signup.