---

title: Errors
description: 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](/api#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

| Type                                            | Status | Routes                      |
| ----------------------------------------------- | ------ | --------------------------- |
| [`schema_mismatch`](#schema-mismatch)           | 400    | All with a body             |
| [`build_inactive`](#build-inactive)             | 400    | Agent                       |
| [`field_map_mismatch`](#field-map-mismatch)     | 400    | Agent                       |
| [`unauthorized`](#unauthorized)                 | 401    | Server API, agent challenge |
| [`invalid_token`](#invalid-token)               | 401    | Agent                       |
| [`token_expired`](#token-expired)               | 401    | Agent                       |
| [`forbidden_scope`](#forbidden-scope)           | 403    | Server API                  |
| [`origin_not_allowed`](#origin-not-allowed)     | 403    | Agent                       |
| [`ip_not_allowed`](#ip-not-allowed)             | 403    | Agent                       |
| [`ip_prefix_mismatch`](#ip-prefix-mismatch)     | 403    | Agent                       |
| [`not_found`](#not-found)                       | 404    | All                         |
| [`nonce_reused`](#nonce-reused)                 | 409    | Agent                       |
| [`idempotency_conflict`](#idempotency-conflict) | 409    | Server API writes           |
| [`deletion_pending`](#deletion-pending)         | 409    | Server API                  |
| [`late_window_closed`](#late-window-closed)     | 410    | Agent follow-up routes      |
| [`payload_too_large`](#payload-too-large)       | 413    | All with a body             |
| [`validation_failed`](#validation-failed)       | 422    | Server API, agent identify  |
| [`rate_limited`](#rate-limited)                 | 429    | All authenticated routes    |
| [`internal`](#internal)                         | 500    | All                         |

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

## Errors from the server API

### `unauthorized`

| Status | Title        | Detail                                |
| ------ | ------------ | ------------------------------------- |
| 401    | Unauthorized | The 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`

| Status | Title           | Detail                                           |
| ------ | --------------- | ------------------------------------------------ |
| 403    | Forbidden scope | The 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`](/api/keys#post-v1-keys). The scope of each route is in [Endpoints](/api#endpoints).

### `not_found`

| Status | Title     | Detail                                 |
| ------ | --------- | -------------------------------------- |
| 404    | Not found | The 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`](/api/linked#get-v1-linked-linked-id-related), no visitor carries the linked id. On [`POST /v1/labelled-pairs`](/api/linked#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`

| Status | Title            | Detail                                 |
| ------ | ---------------- | -------------------------------------- |
| 409    | Deletion pending | A 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`

| Status | Title                | Detail                     |
| ------ | -------------------- | -------------------------- |
| 409    | Idempotency conflict | One of the sentences below |

| Detail                                                        | Cause                                                                        | What 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](/api#idempotent-writes).

### `validation_failed`

| Status | Title             | Detail                                                          |
| ------ | ----------------- | --------------------------------------------------------------- |
| 422    | Validation failed | One 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:

| Detail                                                                              | Cause                                                                                                                                                            | Routes                                                            |
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| 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`](/api/events#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`](/api/linked#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`](/api/keys#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`](/api/keys#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}`](/api/keys#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](/api/webhooks)                                     |
| The delivery is still pending, so it cannot be replayed.                            | The delivery has not finished its attempts yet.                                                                                                                  | [Webhooks API](/api/webhooks)                                     |
| 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`

| Status | Title        | Detail                                                            |
| ------ | ------------ | ----------------------------------------------------------------- |
| 429    | Rate limited | Too 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](/api#rate-limits) and [Limits](/limits).

### `schema_mismatch`

| Status | Title           | Detail                                      |
| ------ | --------------- | ------------------------------------------- |
| 400    | Schema mismatch | The 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`

| Status | Title             | Detail                                                 |
| ------ | ----------------- | ------------------------------------------------------ |
| 413    | Payload too large | The 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`

| Status | Title          | Detail                                    |
| ------ | -------------- | ----------------------------------------- |
| 500    | Internal error | The 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](/api/agent) shows which route answers which.

### `invalid_token`

| Status | Title         | Detail                                                            |
| ------ | ------------- | ----------------------------------------------------------------- |
| 401    | Invalid token | The 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`

| Status | Title         | Detail                           |
| ------ | ------------- | -------------------------------- |
| 401    | Token expired | The 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`

| Status | Title        | Detail                                     |
| ------ | ------------ | ------------------------------------------ |
| 409    | Nonce reused | The 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`

| Status | Title              | Detail                                          |
| ------ | ------------------ | ----------------------------------------------- |
| 403    | Origin not allowed | The 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`](/api/keys#post-v1-keys).

### `ip_not_allowed`

| Status | Title          | Detail                                                     |
| ------ | -------------- | ---------------------------------------------------------- |
| 403    | IP not allowed | The 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](/install/proxy), including the proxy secret ([The visitor's address](/install/proxy#the-visitor-s-address)). If the key has `allowed_ip_ranges`, check that the visitor's address falls inside them.

### `ip_prefix_mismatch`

| Status | Title              | Detail                                                                      |
| ------ | ------------------ | --------------------------------------------------------------------------- |
| 403    | IP prefix mismatch | The 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`

| Status | Title          | Detail                         |
| ------ | -------------- | ------------------------------ |
| 400    | Build inactive | The 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](/api/agent#caching).

### `field_map_mismatch`

| Status | Title              | Detail                                                                  |
| ------ | ------------------ | ----------------------------------------------------------------------- |
| 400    | Field map mismatch | The 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`

| Status | Title              | Detail                                              |
| ------ | ------------------ | --------------------------------------------------- |
| 410    | Late window closed | The 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

:::note Coming
The contract reserves two more types, `plan_cap_reached` and `plan_limit`, both with status `402`. The API does not answer them today. If your client receives a `402`, treat it as a refusal that a retry will not change.
:::
