knownprintDocs

API reference

API reference

The knownprint server API: the address, secret keys and scopes, JSON, ids, pagination, errors, rate limits, idempotency and versioning, with every endpoint.

The knownprint server API is what your backend calls to read events and visitors, label them, delete data and manage keys and webhooks. It speaks JSON over HTTPS, authenticates with a secret key, and answers errors as application/problem+json.

This page covers the conventions every endpoint shares. Each group of endpoints has its own page, listed in Endpoints.

The address

Every example in this reference calls $KNOWNPRINT_API, the base address of the API. The address comes with your account; there is no public hostname to print here. Set it once in your shell or your server's configuration:

Shell
export KNOWNPRINT_API="https://your-api-address-from-your-account"
export KNOWNPRINT_SECRET_KEY="sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

All paths in this reference are relative to that address, for example GET $KNOWNPRINT_API/v1/events.

The browser agent does not call this address directly. It calls the /kp/ paths on your own domain, and your proxy forwards them; see Agent routes and Run knownprint from your domain.

Authentication

Send a secret key in the Authorization header with the Bearer scheme:

Shell
curl "$KNOWNPRINT_API/v1/events?limit=10" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"
node
const res = await fetch(`${process.env.KNOWNPRINT_API}/v1/events?limit=10`, {
  headers: { Authorization: `Bearer ${process.env.KNOWNPRINT_SECRET_KEY}` },
});

The rules:

  • A secret key is sk_live_ or sk_test_ followed by 32 lower case letters and digits 2 to 7. A live key belongs to a live environment and a test key to a test environment; each sees only its own environment's data.
  • The scheme name is case insensitive (Bearer, bearer); the key itself is exact.
  • A public key (pk_live_...) is never accepted here. It is meant for the browser and has no access to the server API.
  • A key is never read from a query string or a cookie.
  • A missing, malformed, unknown or revoked key answers 401 unauthorized with WWW-Authenticate: Bearer.
  • After 30 failed authentications in a minute from one client address, further failures from that address answer 429 rate_limited until the bucket refills. A valid key is never slowed by this.

Every query runs inside the key's environment. An id that belongs to another environment, even one of your own, answers 404 exactly as an id that does not exist.

Scopes

Each secret key holds one or more scopes, and each route requires one. The scope is checked before anything is looked up, so a key without it answers 403 forbidden_scope whatever the id in the path.

ScopeLets the key
events:readRead and search events, read visitors and their related accounts
events:writeSet the linked id and tags of an event, record feedback, record labelled pairs
visitors:deleteDelete a visitor or a linked id
webhooks:manageCreate, change, test and delete webhooks, list and replay deliveries
keys:manageList, create and revoke keys and proxy secrets
usage:readRead daily usage (coming)

Give each service the narrowest key it needs. A backend that only checks events at login needs events:read; a moderation tool that labels events needs events:write as well; a privacy request handler needs visitors:delete.

Key kinds

KindShapeUsed by
Public keypk_live_ or pk_test_ and 32 charactersThe browser agent, through your proxy. Limited to the origins you allow.
Secret keysk_live_ or sk_test_ and 32 charactersYour servers, against this API.
Proxy secret32 charactersYour proxy, to prove that agent requests came through it.

Keys and service routes explains how to create and revoke each kind.

Requests and responses

  • Request bodies are JSON with Content-Type: application/json. Any other media type, an empty body where one is required, or text that is not JSON answers 400 schema_mismatch. JSON that parses but does not match the route's schema answers 422 validation_failed with the detail invalid_body.
  • Request bodies are limited to 64 KB and to 64 levels of nesting. Larger bodies answer 413 payload_too_large.
  • Bodies are strict: a member the schema does not name is refused, not ignored.
  • Strings must be valid Unicode without U+0000.
  • Successful responses are application/json; charset=utf-8. Errors are application/problem+json; charset=utf-8.
  • Every API response carries Cache-Control: no-store, except the agent files and GET /v1/catalog/versions.
  • Timestamps are RFC 3339 in UTC and end in Z, for example 2026-11-03T14:00:00.412Z.
  • Unknown paths and unsupported methods answer 404 not_found, including OPTIONS.

Ids

Every id is a short type prefix followed by 26 characters of lower case base32 (a to z and 2 to 7). Treat ids as opaque strings and store them as text.

PrefixNamesExample
evt_An event, also called the request idevt_udrovzh6kvpxnvjfj62hp3nape
v_A visitorv_f6i63ol6cpthl5uajnmobnbm5k
c_A device clusterc_4jh7wuqdiu3h5527vtz2tbcfno
env_An environmentenv_b5l7rluhuy37x7qxlnu5qtjlsl
key_A key or proxy secretkey_3m5hq7o2xk4ajc6d2tq7rfwz5e
del_A deletion jobdel_7xq4bqv2m3rd5kz6h2l4wz7nya
wh_A webhookwh_k2v6z4m7qd3a5xh2rq6t4n7bce
dl_A webhook deliverydl_p4z7k3q2w6m5x2rd7h4a6t3nvb
lp_A labelled pairlp_q6t3m7z2k4w5a2xr7d6h3n4pbv
obs_A stored observation, named in a labelled pairobs_r4n7t2k6m3w5z2qa7d4h6x3pbv

A linked id is different: it is your own identifier for an account (a user id, an account number), 1 to 128 characters, which you attach to events. See Linked ids and labelled pairs.

Visitor ids can merge. When knownprint learns that two visitor ids are the same browser, the older id survives and the other becomes its alias. An alias keeps answering on every read, so a stored id never breaks; GET /v1/visitors/{visitor_id} tells you which visitor holds it now.

Pagination

GET /v1/events and the webhook delivery list are paged with an opaque cursor, newest first.

ParameterMeaning
limitPage size, 1 to 500. Default 50.
cursorThe next_cursor of the previous page. Omit it for the first page.

A page is { "data": [...], "next_cursor": "..." }. next_cursor is null on the last page. Keep the same filters when you pass a cursor: the cursor only marks a position.

node
async function* allEvents(params) {
  let cursor = null;
  do {
    const q = new URLSearchParams(params);
    if (cursor) q.set('cursor', cursor);
    const res = await fetch(`${process.env.KNOWNPRINT_API}/v1/events?${q}`, {
      headers: { Authorization: `Bearer ${process.env.KNOWNPRINT_SECRET_KEY}` },
    });
    if (!res.ok) throw new Error(`knownprint answered ${res.status}`);
    const page = await res.json();
    yield* page.data;
    cursor = page.next_cursor;
  } while (cursor);
}

for await (const event of allEvents({ linked_id: 'account-1842', limit: '100' })) {
  console.log(event.request_id, event.visitor_id);
}

Query parameters are strict on paged routes: a name the route does not take, or a name given twice, answers 422 validation_failed with the detail invalid_filter. A malformed cursor answers the detail invalid_cursor.

Errors

Every error is a problem document (RFC 9457) with the same five members:

JSON
{
  "type": "https://knownprint.dev/problems/forbidden_scope",
  "title": "Forbidden scope",
  "status": 403,
  "detail": "The API key lacks the scope this route requires.",
  "request_id": "evt_k4m2q7z3w6a5x2rd7h4t6n3pbv"
}
MemberMeaning
typeA stable identifier for the kind of error. The part after /problems/ is the slug, such as forbidden_scope. Branch on this.
titleA short fixed title for the type.
statusThe HTTP status, repeated.
detailOne fixed sentence. Some types have several, each naming a precise cause. Never a value from your request.
request_idThe id of the request that failed. Quote it to your knownprint contact.

Branch on type (or status), never on detail text. Errors lists every type, when it happens and what to do.

Rate limits

Each key has a bucket of 150 requests that refills at 50 requests a second. A request that finds the bucket empty answers 429 rate_limited with Retry-After in whole seconds.

Once the key and its scope check out, every response reports the key's bucket:

HTTP
RateLimit: limit=150, remaining=149, reset=1
RateLimit-Policy: 150;w=3
HeaderMeaning
RateLimitlimit is the burst, remaining the requests left now, reset the seconds until the bucket is full again.
RateLimit-PolicyThe burst and the window in seconds over which it refills.
Retry-AfterOn a 429 only: seconds to wait before retrying.

Deletions have their own, tighter bucket: 2 a second per key, burst 2, on top of the key bucket. Agent routes are limited per client address, per visitor and per public key; see Agent routes and Limits.

When you get a 429, wait for Retry-After and retry. For batch jobs, pace requests below 50 a second per key rather than relying on retries.

Idempotent writes

Every write route accepts an Idempotency-Key header. Send one when you might retry a write after a timeout or a network error:

Shell
curl -X POST "$KNOWNPRINT_API/v1/events/$REQUEST_ID/feedback" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: feedback-$REQUEST_ID-fraud" \
  -d '{"label":"fraud"}'
  • The key is 1 to 255 visible ASCII characters (no spaces). Anything else answers 422 with the detail idempotency_key.
  • A key is remembered for 24 hours within your environment.
  • A repeat with the same key, method, path and body answers the stored status and body, with Idempotency-Replayed: true. The write is not done twice.
  • The same key with a different method, path or body answers 409 idempotency_conflict (body_mismatch).
  • While the first request is still running, a repeat waits up to 5 seconds for it, then answers 409 (in_flight). Retry it a moment later.
  • Answers of 500 and above, and 429, are not stored: a retry with the same key runs again.
  • Every other answer is stored and replayed, errors included: a repeat of a write that answered 404 or 422 answers the same again. Fix the request and send it with a new key.
  • A request without the header is not deduplicated.

The routes that take it: PATCH /v1/events/{request_id}, POST /v1/events/{request_id}/feedback, DELETE /v1/visitors/{visitor_id}, DELETE /v1/linked/{linked_id}, POST /v1/labelled-pairs, the key writes and the webhook writes.

Timeouts and retries

The API closes a connection whose request has not fully arrived within 60 seconds. Set your own client timeout, and retry on a timeout, a 429 or a 5xx. Send an Idempotency-Key with every write you may retry, so a write whose answer you never saw is not done twice.

StatusRetry?
400, 401, 403, 404, 413, 422No. Fix the request, the key or the id.
409 deletion_pendingNot for that subject: it is being deleted.
409 idempotency_conflictin_flight: yes, shortly. body_mismatch: no, use a new key.
429Yes, after Retry-After.
500Yes, with backoff. Use an Idempotency-Key on writes.

Versioning

The API version is the first segment of the path: /v1. Within v1, changes are additive only:

  • new endpoints, new optional parameters and new members in responses;
  • new keys in open maps such as signals and tags;
  • new webhook types, which you receive only if you subscribe to them.

Write your client to ignore members it does not know. A change that would remove or rename a field, change a type or tighten a rule comes as a new version.

Endpoints

Events

Method and pathScopePurpose
GET /v1/eventsevents:readSearch events by visitor, linked id, address, time and signals
GET /v1/events/{request_id}events:readRead one event
PATCH /v1/events/{request_id}events:writeSet or clear the event's linked id and tags
POST /v1/events/{request_id}/feedbackevents:writeLabel an event as fraud or legit

Visitors

Method and pathScopePurpose
GET /v1/visitors/{visitor_id}events:readRead a visitor and its recent events
GET /v1/visitors/{visitor_id}/relatedevents:readVisitors and linked ids related to a visitor
DELETE /v1/visitors/{visitor_id}visitors:deleteDelete a visitor and its data
GET /v1/visitors/{visitor_id}/exportevents:readExport a visitor's data (coming)

Linked ids and labelled pairs

Method and pathScopePurpose
GET /v1/linked/{linked_id}/relatedevents:readVisitors and linked ids related to one of your account ids
DELETE /v1/linked/{linked_id}visitors:deleteRemove one of your account ids from knownprint
POST /v1/labelled-pairsevents:writeTell knownprint that two events are the same person

Webhooks

Method and pathScopePurpose
GET /v1/webhookswebhooks:manageList webhooks
POST /v1/webhookswebhooks:manageCreate a webhook
PATCH /v1/webhooks/{id}webhooks:manageChange a webhook
DELETE /v1/webhooks/{id}webhooks:manageDelete a webhook
POST /v1/webhooks/{id}/testwebhooks:manageSend a test delivery
GET /v1/webhooks/{id}/deliverieswebhooks:manageList a webhook's deliveries
POST /v1/deliveries/{id}/replaywebhooks:manageSend a delivery again

These are documented on Webhooks API.

Keys and service routes

Method and pathAuthPurpose
GET /v1/keyskeys:manageList keys and proxy secrets
POST /v1/keyskeys:manageCreate a key or proxy secret
DELETE /v1/keys/{id}keys:manageRevoke a key or retire a proxy secret
GET /v1/usageusage:readDaily usage (coming)
GET /v1/catalog/versionsNoneReference data versions
GET /healthNoneService health
GET /.well-known/knownprint.jsonNoneYour site's disclosure file, served by your proxy

Agent routes

The browser agent calls /kp/agent.js, /kp/a/{build}.js, /kp/c, /kp/i, /kp/l/{request_id} and /kp/b/{request_id} through your proxy. Your own code never calls them. Agent routes lists them with their status codes, for troubleshooting.