knownprintDocs

API reference

Agent routes

The routes the knownprint browser agent calls through your proxy, what each is for and the status codes each answers, as a troubleshooting aid.

The knownprint agent is the script that runs on your pages. It talks to knownprint through a handful of routes under /kp/ on your own domain, which your proxy forwards to the API. Your own code never calls these routes, and their bodies are not a public interface: they change with the agent, which knownprint keeps in step.

This page lists them so that you can recognise them in your proxy logs, your Content Security Policy and the browser's network panel, and tell what a status code means while you set up or troubleshoot. To install the agent and the proxy, follow Run knownprint from your domain and Add the browser agent.

How a visit flows

  1. Your page loads the loader, GET /kp/agent.js.
  2. The loader fetches the agent bundle for its build, GET /kp/a/{build}.js (or .s.js).
  3. The agent asks for a challenge, POST /kp/c, with your public key.
  4. The agent sends its identification, POST /kp/i. The answer gives your page the request id.
  5. Your page sends the request id to your backend, which reads the result with GET /v1/events/{request_id}.
  6. Afterwards the agent may call its follow-up routes, POST /kp/l/{request_id} and POST /kp/b/{request_id}, which can update the stored event.

Every step from 1 to 4 and step 6 goes through your proxy. Only step 5 uses your secret key.

Incognito and the suspect score can be refined within about ten seconds of the identification, and the bot verdict can turn bad for up to 30 minutes after it. Read the event when the visitor acts, not earlier.

The routes

Route on your domainPurpose
GET /kp/agent.jsThe loader, a small script your page includes
GET /kp/a/{build}.jsThe full agent bundle of one build
GET /kp/a/{build}.s.jsThe smaller bundle of the security profile, for pages that load the agent with that profile
POST /kp/cIssues a short-lived challenge for one identification
POST /kp/iReceives the identification and answers the request id
POST /kp/l/{request_id}A follow-up route of the agent
POST /kp/b/{request_id}A follow-up route of the agent

{build} is 12 lower case hexadecimal characters naming one agent release. {request_id} is the event's evt_ id.

The API answers each route under a /v1/ alias as well. The agent uses the /kp/ paths on your own domain, so they stay first party; you do not need to forward or allow the aliases.

Status codes

Loader and bundles

StatusMeaningWhat to check
200The script, as text/javascript; charset=utf-8
404 not_foundNo such file: a mistyped path, or a bundle name that is not a current buildThat your proxy forwards /kp/ with the path unchanged

Challenge: POST /kp/c

StatusTypeMeaning
200The challenge, valid for a short time
400schema_mismatchThe body is not what the agent sends
400build_inactiveThe page runs an agent build that is no longer served
401unauthorizedThe public key is unknown or revoked
403ip_not_allowedNo client address could be told for the request, or the address is outside the key's allowed ranges (often your server's own address, when the proxy sends no valid proxy secret)
403origin_not_allowedThe page's origin is not in the key's allowed origins
413payload_too_largeThe body is over 2 KB
429rate_limitedToo many challenges from this address, or the public key's bucket is empty

Identify: POST /kp/i

StatusTypeMeaning
200Identified; the answer gives the page its request id
400schema_mismatchThe payload is not what the agent sends
400field_map_mismatchThe payload does not belong with its challenge
400build_inactiveThe agent build is no longer served
401invalid_tokenNo valid challenge, or a public key other than the challenge's
401token_expiredThe challenge has expired
403ip_not_allowedNo client address, or an address outside the key's allowed ranges
403origin_not_allowedThe origin is not allowed, or differs from the challenge's
403ip_prefix_mismatchThe visitor's address changed during the identification and the environment is set to refuse that (it is not by default)
409nonce_reusedThe challenge was already used: a replay or a retried POST
413payload_too_largeThe body is over 64 KB
422validation_failedCollection is blocked for this visitor by your consent setting, so nothing is stored
429rate_limitedToo many identifications from this address or this visitor, the public key's bucket is empty, or its daily cap is reached

A refused identification is not stored and not billed.

Follow-up routes: POST /kp/l/{request_id} and POST /kp/b/{request_id}

StatusTypeMeaning
204Recorded
410late_window_closedNot recorded

These two routes answer every failure with the same 410, whatever its cause, so a stray 410 in your logs is expected and harmless. The event they belong to is valid without them. Their bodies are limited to 1 KB.

Rate limits

Agent routes are limited per visitor address and per visitor, so that one browser or one network cannot use up your capacity.

BucketLimitApplies to
Challenges per client address60 a minutePOST /kp/c
Identifications per client address30 a minutePOST /kp/i
Identifications per visitor60 a minutePOST /kp/i
Public key50 a second, burst 150POST /kp/c and POST /kp/i
Public key daily capThe key's daily_cap, per UTC dayPOST /kp/i

An IPv6 client counts by its /64 network. Address buckets are counted separately for each knownprint account, so another site's traffic never uses up yours. Agent answers carry RateLimit and RateLimit-Policy headers for the address bucket, never for your key, so a visitor cannot read your traffic from them. A 429 carries Retry-After. Limits has every limit in one place.

Because the per-address limits count real client addresses, your proxy must pass the visitor's address to knownprint, with its proxy secret, as the install guide shows. Without a valid proxy secret knownprint takes the address that connected to it, your server's, so all your visitors share one address bucket and a key with allowed IP ranges refuses them with ip_not_allowed (The visitor's address).

Caching

RouteCache-Control from the API
GET /kp/agent.jspublic, max-age=3600
GET /kp/a/{build}.js, .s.jspublic, max-age=31536000, immutable
Every POST routeno-store

A bundle's name changes with every release, so bundles can be cached for a year; the loader is cached for an hour, so a new release reaches your pages within that hour. Keep these headers: a loader cached longer than an hour can outlive its build and answer build_inactive. Never cache the POST routes, and never let your proxy retry them.

The API adds no Access-Control-* headers. Requests to the /kp/ routes are same-origin, because they go to your own domain, so none are needed.

Your Content Security Policy

If your site sends a Content Security Policy, it must allow the agent's scripts (/kp/agent.js and /kp/a/) and its requests to the POST routes above. Content Security Policy has the exact directives to add.

Troubleshooting

You seeLikely cause
404 on /kp/agent.jsThe proxy rule for /kp/ is missing, or it rewrites the path
403 ip_not_allowed on every challengeThe key has allowed IP ranges and the address knownprint sees is outside them, often your server's own because the proxy sends no valid proxy secret
403 origin_not_allowed on one host onlyThat host's origin (with or without www., http or https) is not on the public key
401 unauthorized on the challengeThe page uses a revoked or mistyped public key
409 nonce_reused in burstsA proxy, load balancer or CDN retries POST requests
400 build_inactive after a releaseThe loader is cached longer than an hour somewhere between the browser and the API
429 rate_limited from an office or schoolMany visitors share one address; the limit applies per address
410 on /kp/l/ or /kp/b/Expected from time to time; no action needed

The go-live checklist lists what to run before you send real traffic.