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:
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:
curl "$KNOWNPRINT_API/v1/events?limit=10" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"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_orsk_test_followed by 32 lower case letters and digits 2 to 7. Alivekey belongs to a live environment and atestkey 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
401unauthorizedwithWWW-Authenticate: Bearer. - After 30 failed authentications in a minute from one client address, further failures from that address answer
429rate_limiteduntil 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.
| Scope | Lets the key |
|---|---|
events:read | Read and search events, read visitors and their related accounts |
events:write | Set the linked id and tags of an event, record feedback, record labelled pairs |
visitors:delete | Delete a visitor or a linked id |
webhooks:manage | Create, change, test and delete webhooks, list and replay deliveries |
keys:manage | List, create and revoke keys and proxy secrets |
usage:read | Read 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
| Kind | Shape | Used by |
|---|---|---|
| Public key | pk_live_ or pk_test_ and 32 characters | The browser agent, through your proxy. Limited to the origins you allow. |
| Secret key | sk_live_ or sk_test_ and 32 characters | Your servers, against this API. |
| Proxy secret | 32 characters | Your 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 answers400schema_mismatch. JSON that parses but does not match the route's schema answers422validation_failedwith the detailinvalid_body. - Request bodies are limited to 64 KB and to 64 levels of nesting. Larger bodies answer
413payload_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 areapplication/problem+json; charset=utf-8. - Every API response carries
Cache-Control: no-store, except the agent files andGET /v1/catalog/versions. - Timestamps are RFC 3339 in UTC and end in
Z, for example2026-11-03T14:00:00.412Z. - Unknown paths and unsupported methods answer
404not_found, includingOPTIONS.
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.
| Prefix | Names | Example |
|---|---|---|
evt_ | An event, also called the request id | evt_udrovzh6kvpxnvjfj62hp3nape |
v_ | A visitor | v_f6i63ol6cpthl5uajnmobnbm5k |
c_ | A device cluster | c_4jh7wuqdiu3h5527vtz2tbcfno |
env_ | An environment | env_b5l7rluhuy37x7qxlnu5qtjlsl |
key_ | A key or proxy secret | key_3m5hq7o2xk4ajc6d2tq7rfwz5e |
del_ | A deletion job | del_7xq4bqv2m3rd5kz6h2l4wz7nya |
wh_ | A webhook | wh_k2v6z4m7qd3a5xh2rq6t4n7bce |
dl_ | A webhook delivery | dl_p4z7k3q2w6m5x2rd7h4a6t3nvb |
lp_ | A labelled pair | lp_q6t3m7z2k4w5a2xr7d6h3n4pbv |
obs_ | A stored observation, named in a labelled pair | obs_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.
| Parameter | Meaning |
|---|---|
limit | Page size, 1 to 500. Default 50. |
cursor | The 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.
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:
{
"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"
}| Member | Meaning |
|---|---|
type | A stable identifier for the kind of error. The part after /problems/ is the slug, such as forbidden_scope. Branch on this. |
title | A short fixed title for the type. |
status | The HTTP status, repeated. |
detail | One fixed sentence. Some types have several, each naming a precise cause. Never a value from your request. |
request_id | The 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:
RateLimit: limit=150, remaining=149, reset=1
RateLimit-Policy: 150;w=3| Header | Meaning |
|---|---|
RateLimit | limit is the burst, remaining the requests left now, reset the seconds until the bucket is full again. |
RateLimit-Policy | The burst and the window in seconds over which it refills. |
Retry-After | On 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:
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
422with the detailidempotency_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
409idempotency_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
500and above, and429, 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
404or422answers 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.
| Status | Retry? |
|---|---|
400, 401, 403, 404, 413, 422 | No. Fix the request, the key or the id. |
409 deletion_pending | Not for that subject: it is being deleted. |
409 idempotency_conflict | in_flight: yes, shortly. body_mismatch: no, use a new key. |
429 | Yes, after Retry-After. |
500 | Yes, 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
signalsandtags; - 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 path | Scope | Purpose |
|---|---|---|
GET /v1/events | events:read | Search events by visitor, linked id, address, time and signals |
GET /v1/events/{request_id} | events:read | Read one event |
PATCH /v1/events/{request_id} | events:write | Set or clear the event's linked id and tags |
POST /v1/events/{request_id}/feedback | events:write | Label an event as fraud or legit |
Visitors
| Method and path | Scope | Purpose |
|---|---|---|
GET /v1/visitors/{visitor_id} | events:read | Read a visitor and its recent events |
GET /v1/visitors/{visitor_id}/related | events:read | Visitors and linked ids related to a visitor |
DELETE /v1/visitors/{visitor_id} | visitors:delete | Delete a visitor and its data |
GET /v1/visitors/{visitor_id}/export | events:read | Export a visitor's data (coming) |
Linked ids and labelled pairs
| Method and path | Scope | Purpose |
|---|---|---|
GET /v1/linked/{linked_id}/related | events:read | Visitors and linked ids related to one of your account ids |
DELETE /v1/linked/{linked_id} | visitors:delete | Remove one of your account ids from knownprint |
POST /v1/labelled-pairs | events:write | Tell knownprint that two events are the same person |
Webhooks
| Method and path | Scope | Purpose |
|---|---|---|
GET /v1/webhooks | webhooks:manage | List webhooks |
POST /v1/webhooks | webhooks:manage | Create a webhook |
PATCH /v1/webhooks/{id} | webhooks:manage | Change a webhook |
DELETE /v1/webhooks/{id} | webhooks:manage | Delete a webhook |
POST /v1/webhooks/{id}/test | webhooks:manage | Send a test delivery |
GET /v1/webhooks/{id}/deliveries | webhooks:manage | List a webhook's deliveries |
POST /v1/deliveries/{id}/replay | webhooks:manage | Send a delivery again |
These are documented on Webhooks API.
Keys and service routes
| Method and path | Auth | Purpose |
|---|---|---|
GET /v1/keys | keys:manage | List keys and proxy secrets |
POST /v1/keys | keys:manage | Create a key or proxy secret |
DELETE /v1/keys/{id} | keys:manage | Revoke a key or retire a proxy secret |
GET /v1/usage | usage:read | Daily usage (coming) |
GET /v1/catalog/versions | None | Reference data versions |
GET /health | None | Service health |
GET /.well-known/knownprint.json | None | Your 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.