knownprintDocs

API reference

Errors

Every problem type the knownprint API answers with: its status, title and detail sentences, when it happens and what your code should do.

Every error from the knownprint API is an application/problem+json document with five members. The shape is described in Errors on the overview; this page lists every type.

JSON
{
  "type": "https://knownprint.dev/problems/validation_failed",
  "title": "Validation failed",
  "status": 422,
  "detail": "A query parameter is unknown, repeated or has an invalid value.",
  "request_id": "evt_k4m2q7z3w6a5x2rd7h4t6n3pbv"
}

How to handle them:

  • Branch on type, or on the slug after /problems/. Each type always comes with the same status.
  • Where a type has several causes, detail is one of a fixed set of sentences, listed below. Log it; show it to developers, not to visitors. Do not parse it.
  • detail never contains a value from your request, a secret or an internal.
  • Quote request_id when you ask your knownprint contact about a failed request.
  • Error responses carry Cache-Control: no-store and never set a cookie. A 429 carries Retry-After.

Summary

TypeStatusRoutes
schema_mismatch400All with a body
build_inactive400Agent
field_map_mismatch400Agent
unauthorized401Server API, agent challenge
invalid_token401Agent
token_expired401Agent
forbidden_scope403Server API
origin_not_allowed403Agent
ip_not_allowed403Agent
ip_prefix_mismatch403Agent
not_found404All
nonce_reused409Agent
idempotency_conflict409Server API writes
deletion_pending409Server API
late_window_closed410Agent follow-up routes
payload_too_large413All with a body
validation_failed422Server API, agent identify
rate_limited429All authenticated routes
internal500All

"Agent" means the routes the browser agent calls through your proxy, listed on Agent routes. Your code sees those errors only in the browser console or your proxy logs.

Errors from the server API

unauthorized

StatusTitleDetail
401UnauthorizedThe request carries no valid API key.

When. The Authorization header is missing, is not Bearer followed by a secret key, or names a key that does not exist or was revoked. A public key (pk_...) sent to a server route also answers this. On the agent's challenge, the public key is unknown or revoked. The answer carries WWW-Authenticate: Bearer.

What to do. Check that the header is Authorization: Bearer sk_live_... with no quotes or stray whitespace, that the key belongs to the environment you mean, and that it has not been revoked. Do not retry in a loop: after 30 failures in a minute from one address, failures answer 429 instead.

forbidden_scope

StatusTitleDetail
403Forbidden scopeThe API key lacks the scope this route requires.

When. The key is valid but does not hold the scope the route requires. The check comes before any lookup, so it says nothing about whether the id in the path exists.

What to do. Use a key with the right scope, or create one with POST /v1/keys. The scope of each route is in Endpoints.

not_found

StatusTitleDetail
404Not foundThe requested resource does not exist.

When. The path or method does not exist (including OPTIONS); an id in the path is malformed; or the id names nothing in the key's environment. Ids of another environment, events past retention, expired visitors and deleted visitors all answer this. On GET /v1/linked/{linked_id}/related, no visitor carries the linked id. On POST /v1/labelled-pairs, either request id names no event.

What to do. Check the id and the environment of your key. For an event you just received from the page, check that the page and your backend use keys of the same environment. Do not retry.

deletion_pending

StatusTitleDetail
409Deletion pendingA deletion of this visitor is pending.

When. A deletion job for the visitor is queued, running or being retried, and the route reads or writes that visitor or one of its events.

What to do. Treat the visitor as gone. Once the job completes the same request answers 404. Do not retry.

idempotency_conflict

StatusTitleDetail
409Idempotency conflictOne of the sentences below
DetailCauseWhat to do
The Idempotency-Key was already used for a different request.The key was used in the last 24 hours with a different method, path or body.Use a new key for a new request. Never reuse a key across different writes.
A request with this Idempotency-Key is still in progress.The first request with this key had not finished after 5 seconds of waiting.Retry the same request with the same key shortly.

See Idempotent writes.

validation_failed

StatusTitleDetail
422Validation failedOne of the sentences below, or "The request failed validation."

The JSON parsed but something in it, in the query or in a header is not acceptable. Each cause has its own detail sentence:

DetailCauseRoutes
The request body does not satisfy the schema of this route.A required member is missing, a member is unknown or of the wrong type, a value is out of range, tags are too large, or two values that must differ are equal.All with a body
A query parameter is unknown, repeated or has an invalid value.A filter the route does not take, a filter given twice, a malformed value or a limit outside 1 to 500.GET /v1/events, webhook deliveries
The cursor is malformed.The cursor was altered, truncated, repeated, or does not come from this API.Paged routes
The subject is malformed.A linked id that is empty, over 128 characters or holds U+0000, or a visitor id to delete that is not v_ and 26 characters.Linked id routes, visitor deletion, event PATCH
The Idempotency-Key header must be 1 to 255 visible ASCII characters.The header is empty, too long, or holds spaces or non-ASCII characters.All writes
Only an event collected for the security purpose can be labelled.One of the two events was collected for a purpose other than security. Reserved: every event is collected for the security purpose today.POST /v1/labelled-pairs
A public key needs at least one allowed origin, each a serialised origin.allowed_origins is missing or empty, or holds a value such as https://example.org/ or a wildcard.POST /v1/keys
The fields given do not fit the key kind.A member the key kind does not take, or scopes empty on a secret key.POST /v1/keys
The key making the request cannot revoke itself.DELETE /v1/keys/{id} names the key that sent it.DELETE /v1/keys/{id}
The webhook URL is refused: it must use https and resolve only to public addresses.The URL is not https, or its host resolves to a private, loopback or otherwise non-public address.Webhooks API
The delivery is still pending, so it cannot be replayed.The delivery has not finished its attempts yet.Webhooks API
The payload consent mode is blocked, so nothing is collected.The page told the agent that collection is blocked for this visitor.Agent identify

What to do. Fix the request. Retrying it unchanged answers the same error.

rate_limited

StatusTitleDetail
429Rate limitedToo many requests; retry after the interval given in Retry-After.

When. A bucket is empty:

  • the key's bucket on any route (50 a second, burst 150);
  • the deletion bucket on the two delete routes (2 a second per key, burst 2);
  • 30 failed authentications in a minute from one client address;
  • on agent routes, the per-address and per-visitor buckets, or a public key's daily_cap (until the next UTC midnight).

What to do. Wait the number of seconds in Retry-After, then retry. Pace batch jobs below the limit rather than relying on retries. The RateLimit header on successful answers tells you how much room is left; see Rate limits and Limits.

schema_mismatch

StatusTitleDetail
400Schema mismatchThe request body does not match its schema.

When. On the server API: the body is not JSON, is empty where one is required, nests deeper than 64 levels, or the Content-Type is not application/json. On agent routes: the payload does not match what the agent should send, which usually means the request did not come from the agent.

What to do. Send Content-Type: application/json and a JSON body. If an agent request answers this, check that your proxy passes request bodies through unchanged.

payload_too_large

StatusTitleDetail
413Payload too largeThe request body exceeds the size limit of this route.

When. The body is larger than the route accepts: 64 KB on the server API and on identify, 2 KB on the challenge, 1 KB on the agent's follow-up routes.

What to do. On the server API, send less (large tags are the usual cause). On agent routes, check that your proxy does not add to the body.

internal

StatusTitleDetail
500Internal errorThe server failed to process the request.

When. Something failed on knownprint's side.

What to do. Retry with backoff. Writes sent with an Idempotency-Key are safe to retry: a 500 is never stored as the answer for the key. If it persists, tell your knownprint contact, with the request_id.

Errors from agent routes

The browser agent handles these itself. You see them in the browser's network panel or your proxy's logs while you set up or troubleshoot; Agent routes shows which route answers which.

invalid_token

StatusTitleDetail
401Invalid tokenThe challenge token or the key presented with it does not verify.

When. An identify arrives without a valid challenge token from knownprint, or with a public key that does not match the one the token was issued for.

What to do. Load the agent from your own domain as the install guide shows, and let your proxy forward its requests unchanged, headers and body included. An identify that the agent's own challenge did not prepare (a forged or hand-made request) answers this by design.

token_expired

StatusTitleDetail
401Token expiredThe challenge token has expired.

When. The identify arrived too long after its challenge.

What to do. Nothing in normal use: the agent refreshes a challenge it has held for a while before it uses it. If this is frequent, check that nothing between the browser and the API holds or delays the agent's requests.

nonce_reused

StatusTitleDetail
409Nonce reusedThe challenge token has already been used.

When. A challenge token was presented to identify twice: a replayed request, or a proxy that retries POST requests.

What to do. Make sure your proxy never retries the agent's POST requests. Replays are expected from attackers and are refused by design.

origin_not_allowed

StatusTitleDetail
403Origin not allowedThe request origin is not allowed for this key.

When. The page's origin is not in the public key's allowed_origins, or the request carries no usable origin.

What to do. Add the exact origin (https://shop.example.org, no trailing slash) to the key, or use the key made for that site. Every host needs its own entry: www. and the bare domain are two origins. See POST /v1/keys.

ip_not_allowed

StatusTitleDetail
403IP not allowedThe client address is unknown or not allowed for this key.

When. knownprint could tell no client address for the request, or the address is outside the public key's allowed_ip_ranges. A request without a valid proxy secret is not refused for that alone: knownprint then takes the address that connected to it, usually your own server's, which a key with allowed_ip_ranges often refuses.

What to do. Check your proxy configuration against Run knownprint from your domain, including the proxy secret (The visitor's address). If the key has allowed_ip_ranges, check that the visitor's address falls inside them.

ip_prefix_mismatch

StatusTitleDetail
403IP prefix mismatchThe client address is outside the prefix the challenge token was issued to.

When. The client address changed during the identification, where knownprint is configured to refuse that. It is not answered under the default settings.

What to do. Nothing on your side. The visitor's next page load starts with a fresh challenge from its new network.

build_inactive

StatusTitleDetail
400Build inactiveThe agent build is not active.

When. The page is running an agent build that knownprint no longer serves, usually because a cached copy outlived a release.

What to do. Do not cache the loader /kp/agent.js longer than the API's own Cache-Control says, and do not self-host agent files. See Agent routes.

field_map_mismatch

StatusTitleDetail
400Field map mismatchThe payload does not decode under the field map of its challenge token.

When. The identify payload does not belong with its challenge: a forged request, or an agent bundle that does not match the challenge it fetched.

What to do. Same as build_inactive: serve the agent files only through your proxy, with the API's cache headers.

late_window_closed

StatusTitleDetail
410Late window closedThe late beacon window for this request has closed.

When. A request to one of the agent's follow-up routes was refused. Every refusal on these routes answers this same type.

What to do. Nothing. The event stays valid without it.

Reserved types