knownprintDocs

Get started

Concepts

The ideas behind every knownprint integration, from environments and keys to request ids, visitor ids, confidence, signals, profiles and consent.

This page explains the words the rest of the documentation uses, and what each means for the code you write. Field names are given as they appear in the event your backend reads.

Environments

An environment is a separate space with its own keys, its own visitors and its own events. Every account has two:

EnvironmentKeys start withUse it for
Livepk_live_, sk_live_your production site
Testpk_test_, sk_test_development, staging and automated tests

Nothing crosses between them. A visitor recognised in the test environment is unknown to the live one, and a secret key reads only its own environment's events: a request id from the other environment answers 404 not_found, as if it did not exist. Each environment also has its own proxy secret and its own webhooks.

Every event names its environment in environment_id, an id such as env_b5l7rluhuy37x7qxlnu5qtjlsl.

Use the test environment while you build, then switch the page's public key, the backend's secret key and the proxy secret to the live values together. The go-live checklist lists every step.

Keys and secrets

An environment has four kinds of credential. Only one of them belongs in a web page.

CredentialLooks likeLives inWhat it does
Public keypk_live_ and 32 charactersyour pageTells the browser agent which environment it reports to.
Secret keysk_live_ and 32 charactersyour backendReads events and visitors, and calls every other API route.
Proxy secret32 charactersyour proxy configurationProves that a request to /kp/ came through your own proxy.
Webhook secretwhsec_ and 32 charactersyour webhook endpointLets your endpoint verify that a delivery came from knownprint.

A key's or secret's value is shown once, when it is created. Listings show only a key's prefix (its first 16 characters, such as sk_live_abcdefgh), never its value; a proxy secret is listed by its id alone. You create and revoke keys with the keys API, which needs the keys:manage scope.

Public key

The public key is meant to be seen: it sits in your page's source. It cannot read anything. Three settings limit where it works:

  • Allowed origins. The page's origin must be one of the key's allowed origins, compared exactly as the browser writes it (scheme, host and port, such as https://www.example.com). A page on any other origin is refused with 403 origin_not_allowed. A key with no allowed origins admits no page. https://example.com and https://www.example.com are two origins; list both if both serve the script.
  • Allowed IP ranges. Optional, as single addresses or ranges such as 198.51.100.0/24. When set, only visitors from those ranges are admitted (403 ip_not_allowed), which suits an internal tool or a staging site.
  • Daily cap. Optional. A ceiling on how many identifications the key accepts in a day, counted by the UTC day. Past it, identifications with the key answer 429 rate_limited until the next midnight UTC.

Secret key

The secret key authenticates your backend: send it as Authorization: Bearer sk_live_... on every API call. Never put it in a page, a mobile app, a log line or a repository. Each secret key carries scopes, and a route refuses a key without its scope (403 forbidden_scope):

ScopeAllows
events:readReading and searching events, reading visitors and related accounts.
events:writeSetting the linked id and tags of an event, sending feedback.
visitors:deleteDeleting a visitor's or an account's data.
webhooks:manageRegistering, listing, changing, testing and removing webhooks, and reading and replaying their deliveries.
keys:manageCreating, listing and revoking keys and proxy secrets.
usage:readReading usage, once the usage route ships (coming).

The secret key that comes with your account carries every scope. For a service that only reads events, create a key with events:read alone. Every key is rate limited on its own; see Limits.

Proxy secret

Your proxy adds the proxy secret to every request it forwards under /kp/. It tells knownprint that the request came through your own server, and that the visitor's address your proxy reports can be trusted. It goes in your nginx or Caddy configuration, readable only by the server, and never in a page or a repository. The proxy shows where it goes.

Webhook secret

Each webhook you register has its own secret, returned once when you create the webhook. knownprint signs every delivery with it, and your endpoint checks the signature before it trusts the body. Verify a webhook has the code.

Request id

A request id names one identification, such as evt_q3vx7k2mz4rb6nw5tc2ehj7ypd: evt_ and 26 characters. It is the only thing the page receives. The browser agent's identify() resolves it together with expiresAt, the time 10 seconds after knownprint received the identification:

JavaScript
const { requestId, expiresAt } = await agent.identify();

The page posts the request id to your backend with the form, and your backend exchanges it for the event with its secret key. The request id is also the event's id: you use it to read the event, to attach your account id or tags to it, and to send feedback about it.

Use each request id once

knownprint lets your backend read an event by its request id as often as you need, for as long as the event is kept. Your backend must still accept a given request id for an action only once. Before it acts on a request id, it checks that:

  1. it has not accepted this request id before (record it on first use, in a store your backend processes share);
  2. the event is fresh: received_at is no more than 10 seconds ago;
  3. integrity.replayed is false and integrity.origin is your page's origin;
  4. network.ip is the address your own proxy saw for the request that carries the id.

Without these checks, a request id taken from one clean visit could be posted again and again with forged form data. Your backend shows each check in code. The Node SDK will do them in one call; it is coming with the SDK release.

A form that arrives without a request id means the agent did not run: an ad blocker, a script error, a network failure, or someone posting to your backend directly. Treat that as unknown, not as a pass.

Visitor id

A visitor id names one browser on one device, such as v_f6i63ol6cpthl5uajnmobnbm5k: v_ and 26 characters. knownprint gives the same visitor id each time the browser comes back, whenever it is sure enough, including when the browser has lost its cookie, opens a private window or arrives from another network. When it is not sure, it starts a new visitor id instead of guessing.

knownprint never renumbers a visitor id it gave you. It keeps it until the visitor's data is deleted or 400 days pass without a visit. What can change is which visitor answers for an id, in four ways, each announced by a webhook:

WebhookWhat happened
visitor.mergedTwo visitor ids were found to be one browser. The older id survives and the other becomes its alias.
visitor.unmergedA merge was undone. The alias is its own visitor again, and the events it made since the merge name it again.
visitor.splitPart of a visitor was found to be another device, and moved to a new visitor id together with its events.
visitor.suggestedknownprint names an earlier visitor this one may be, with a probability. No id changes.

So store the visitor id beside your own records, and resolve it when you act on it: GET /v1/visitors/{visitor_id} answers the visitor that holds the id now, with its canonical_id and aliases. After a merge, events keep the visitor id they were answered with, and that id resolves to the surviving visitor; a search by either id finds the events of both. After a split or an undone merge, the events that moved name the new or restored visitor id. Visitors covers merges in full.

Confidence

confidence is how sure knownprint is that the visitor id names this browser, as a number from 0 to 1. Use it to decide how much weight a visitor id's history carries in your rules. A ban, a trial limit or a promo limit that follows a visitor id is safest when you act on confident answers and send the rest to a softer check.

Lookalikes

anonymity_set_size is how many browsers look like this one, at least 1. A small number means the browser stands out. A large number means it is a common setup, such as a popular phone model on a current system, where many honest visitors look alike. Read it beside confidence before you treat two visits as the same person.

Likely earlier visitor

When knownprint does not link a visit to an earlier visitor but one is likely, high_recall_id names that earlier visitor id and high_recall_probability says how likely it is, from 0 to 1. When there is no such lead, high_recall_id is null and high_recall_probability is left out; it can also be left out beside a high_recall_id when no probability was given. The visit still gets its own visitor_id.

Treat high_recall_id as a lead for your review, not as an identity: it is useful for a fraud analyst looking at a suspicious signup ("this may be the account we banned last week"), not for an automatic block.

Device clusters

device_cluster_id (c_ and 26 characters) is meant to group what is probably a second browser on the same device, with cluster_confidence (low or medium).

Linked id

The linked id is your own id for the account behind a visit: a user id, a customer number, an order id. It is a string of 1 to 128 characters, stored on the event as linked_id. With it, knownprint keeps which accounts each browser has used and which browsers each account has used.

You can set it in two places:

  • From your backend, after you know the account: PATCH /v1/events/{request_id} with { "linked_id": "acct_1042" } (scope events:write). This is the value to trust, since the page cannot change it. null clears it.
  • From the page, when the account is known before the identification: agent.identify({ linkedId: 'acct_1042' }), or linkedId in load(). A value given to identify replaces the one given to load.

Then search events by account (GET /v1/events?linked_id=...), list the visitors and accounts related to an account or a visitor, and subscribe to account.linked and account.related_found to hear when an account turns up on a new browser or a browser with another account. Accounts covers all of it.

Use an opaque internal id rather than an email address or a name: the linked id needs to tell accounts apart, not to say who someone is.

Tags

Tags are your own labels on an event: a map of names to strings, numbers or booleans, stored as tags (null when there are none). Use them to record context your rules or your analysts need later, such as the form, the plan or the campaign.

JavaScript
await agent.identify({ tags: { form: 'checkout', plan: 'pro', cart_items: 3 } });
Set fromHowLimits
The pagetags in load() or identify(); a value given to identify replaces the one given to load wholeunder 4,096 bytes in all, serialised as JSON
Your backendPATCH /v1/events/{request_id} with tags (null clears them)under 4,096 bytes serialised, and also at most 64 tags, names of 1 to 64 characters and string values of up to 256 characters

Do not put personal data in tags.

Events

An event is the record of one identification, named by its request id. Your backend reads it with GET /v1/events/{request_id}, and it holds everything knownprint said about that visit:

GroupFields
Ids and timesrequest_id, environment_id, created_at, received_at
Identificationvisitor_id, match_type, confidence, anonymity_set_size, high_recall_id, high_recall_probability, device_cluster_id, cluster_confidence, evidence, protection_flags
Browser and networkbrowser, network
Signalssignals, with signals.suspect_score
Requestintegrity, consent, profile, url_path
Yourslinked_id, tags
Script and billingagent_version, build_id, timings, late, late_complete, billable

Events describes every field. Events are also:

  • searchable with GET /v1/events, newest first, by visitor_id, linked_id, address or range (ip), time (start, end), bot, vpn and min_suspect_score (Search events);
  • delivered to your endpoint as they happen, with the event.identified webhook (Webhooks);
  • labelled fraud or legit by your team with feedback.

Events are kept for your environment's retention period. Privacy lists what is kept and for how long, and how deletion works.

Signals and the suspect score

signals is a map from a signal's name to what it found on this visit:

JSON
{
  "proxy": {
    "value": false,
    "confidence": 0.95,
    "reasons": [],
    "detail": { "type": null, "listed": false, "provider": null }
  },
  "tor": {
    "value": false,
    "confidence": 0.98,
    "reasons": []
  }
}
MemberMeaning
valueThe finding: true or false for most signals, a word such as bad or not_detected for bot, a number for the suspect score.
confidenceHow sure the signal is of its value, from 0 to 1.
reasonsShort codes saying what the finding rests on.
detailExtra fields particular to the signal, such as the kind of network or the service.
cappedPresent and true when the signal's confidence is lowered for this kind of install; see Signals.

A signal that could not be read on a visit is null. Treat null as "not known", never as "no".

The signals cover bots and automation (bot), private windows (incognito), VPNs and relays (vpn), proxies (proxy), Tor (tor), hosting networks (datacenter), listed addresses (ip_blocklist), tampering and spoofing (tampering), virtual machines (virtual_machine), developer tools (developer_tools), privacy settings (privacy_settings), high activity (high_activity) and the country and network operator (ip_geolocation). Replayed requests are marked in integrity.replayed. Signals describes each one and what to do about it.

The suspect score, signals.suspect_score, adds the signals that fired on a visit into one number from 0 to 100, and detail.parts says what each one added. The visit's network counts once, by its heaviest finding. It is a sum, not a probability: it gives your code one threshold to act on, and the parts tell your analysts why. Suspect score has the parts and how to pick a threshold.

Profiles

The profile sets how much the browser agent collects. You choose it in the page, and the event records it in profile:

JavaScript
// Resolves null when the script is blocked or fails to load.
const agentReady = window.knownprint
  ? window.knownprint.load({ pk: PUBLIC_KEY, profile: 'security' }).catch(() => null)
  : Promise.resolve(null);
ProfileWhat it gives
full (default)The most complete collection, and the best recognition of browsers that come back.
securityA smaller collection: it leaves out part of what full collects. Returning browsers can be recognised less often than with full.

The event has the same fields with either profile. One page uses one profile: the first load() fixes it, and a later load() with another profile rejects with invalid_options. Start with full unless your privacy review asks for the smallest collection.

The consent mode tells the browser agent what the visitor has agreed to. Set it in load() and change it with agent.consent():

JavaScript
// Resolves null when the script is blocked or fails to load.
const agentReady = window.knownprint
  ? window.knownprint
      .load({ pk: PUBLIC_KEY, consent: { mode: 'blocked' } }) // wait for the visitor's choice
      .catch(() => null)
  : Promise.resolve(null);

// Later, from your consent banner, when the visitor agrees:
acceptButton.addEventListener('click', async () => {
  const agent = await agentReady;
  if (agent !== null) await agent.consent(true).catch(() => {});
});
ModeWhat the agent does
security_only (default)Collects for security and fraud prevention only.
consentedThe visitor has agreed to more. agent.consent(true) sets it from any mode.
blockedCollects and sends nothing. identify() rejects with collection_blocked until agent.consent(true).

agent.consent(false) moves a consented visitor back to security_only; it does not unblock a blocked agent.

Each event records consent in consent:

FieldMeaning
consent.modeThe mode the page set.
consent.gpctrue when the browser sent the Global Privacy Control signal.
consent.tcf_purpose1The visitor's choice for purpose 1 from your IAB TCF consent platform, or null when the page has none.
consent.effective_modeHow the event was processed: security_only or consented.

knownprint processes every event for security and fraud prevention, never for advertising. Privacy covers consent, retention, deletion and the disclosures your privacy notice needs.