---

title: Security
description: Which knownprint credential goes where, how to create, rotate and revoke keys and proxy secrets, how to keep webhook secrets safe, and how to report a vulnerability.
---

knownprint gives you four kinds of credential. Each one belongs in exactly one place, and none of them belongs in a repository. This page says where each one goes, what it can do if it leaks, and how to replace it without downtime.

:::note Early access
Keys come with an account, and signup is not open yet ("Get early access" at https://knownprint.com). Each environment of your account starts with a public key, a proxy secret and a secret key that holds every scope. Use that secret key as your admin key: create narrower keys from it with [`/v1/keys`](/api/keys), and keep it in your secret manager rather than in any service.
:::

## Which credential goes where

| Credential     | Shape                                      | Where it lives                                                       | What it can do                                                                                               |
| -------------- | ------------------------------------------ | -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| Public key     | `pk_live_` or `pk_test_` and 32 characters | In your page, in the call to `knownprint.load()`                     | Start identifications from the origins you allow. It cannot read any result.                                 |
| Secret key     | `sk_live_` or `sk_test_` and 32 characters | Your backend only, as an environment variable or in a secret manager | Call the server API within its scopes: read events, write labels, delete visitors, manage webhooks and keys. |
| Proxy secret   | 32 characters                              | Your proxy's configuration, in a file only the proxy can read        | Vouch for the visitor address your proxy forwards with each script request.                                  |
| Webhook secret | `whsec_` and a base64 value                | Your webhook receiver                                                | Sign deliveries, so your receiver can prove they came from knownprint.                                       |

A `live` key belongs to your live environment and a `test` key to your test environment; each sees only its own environment's data. Use test keys for development and staging.

### The public key is public by design

The public key is meant to be seen: it sits in your page source. What keeps it from being useful to anyone else is the set of limits you give it when you create it:

| Setting                        | Effect                                                                                                                                                                                                                                                                 |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `allowed_origins` (required)   | A request from any other origin is refused with `403` `origin_not_allowed`. Each entry is a serialised origin such as `https://shop.example`: `https` or `http`, scheme and host in lower case, a port only when it is not the default, no path and no trailing slash. |
| `allowed_ip_ranges` (optional) | When set, only visitors from these addresses or CIDR ranges are identified; others are refused with `403` `ip_not_allowed`. Useful for a staging key used only from your office or your CI.                                                                            |
| `daily_cap` (optional)         | The most identifications the key admits in one UTC day. Past it, identifications answer `429` until the next UTC midnight, so a copied key cannot run up your usage.                                                                                                   |

A public key cannot call the server API: sent as a bearer token it answers `401` `unauthorized`.

### Secret keys stay on the server

The page only ever receives a request id (`evt_...`), never the visitor id, the confidence or the signals, so there is no answer in the page for a script to tamper with. Your backend reads the result with a secret key and your own code decides what to do ([verify in your backend](/install/server)).

- Never put a secret key in a browser, a mobile app, a client bundle, a log line or a repository.
- The API sends no `Access-Control-*` headers, so a browser page cannot call the secret routes even if a key were placed there.
- A key is read only from the `Authorization: Bearer` header, never from a query string or a cookie.

### Give each service the narrowest key

Each secret key holds one or more scopes, and each route requires one:

| 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)                                                      |

A login or checkout service usually needs `events:read` alone. Keep `keys:manage` and `webhooks:manage` out of request-serving code: a leaked key with `keys:manage` can create more keys, and one with `webhooks:manage` can add a webhook that sends your events elsewhere. Give `visitors:delete` only to the service that handles privacy requests.

## How knownprint stores your credentials

- **API keys** are stored only as a SHA-256 hash. knownprint cannot show you a key again after it is created.
- **Proxy secrets and webhook secrets** are stored encrypted, and are shown once, in the answer that creates them. `GET /v1/keys` and `GET /v1/webhooks` never show them.
- If you create a key or a webhook with an `Idempotency-Key` and repeat the request within 24 hours, the repeat answers the same value or secret. That stored answer is kept encrypted.
- Error bodies carry fixed text and a `request_id`; they never repeat a key, a secret or a value from your request ([errors](/api/errors)).
- The line knownprint logs for each API request holds no IP address, URL, header value or linked id, and names a visitor only by a one-way hash.

If you lose a key or secret, create a new one and revoke the old one.

## Managing keys

All key management goes through three routes, each with a secret key that holds `keys:manage`. The full reference is [API keys](/api/keys).

| Route                  | Does                                                                                                                                    |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /v1/keys`         | Lists the environment's public keys, secret keys and proxy secrets, oldest first, without their values. Revoked keys show `revoked_at`. |
| `POST /v1/keys`        | Creates a key or proxy secret and answers `201` with its `value`, once.                                                                 |
| `DELETE /v1/keys/{id}` | Revokes a key or retires a proxy secret. Answers `204`, also when it already was.                                                       |

Create a key for one service:

:::tabs
```bash title="Secret key"
curl -X POST "$KNOWNPRINT_API/v1/keys" \
  -H "Authorization: Bearer $KNOWNPRINT_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: checkout-key-2026-12" \
  -d '{"kind":"secret","scopes":["events:read"]}'
```

```bash title="Public key"
curl -X POST "$KNOWNPRINT_API/v1/keys" \
  -H "Authorization: Bearer $KNOWNPRINT_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: web-key-2026-12" \
  -d '{"kind":"public","allowed_origins":["https://shop.example"],"daily_cap":200000}'
```

```bash title="Proxy secret"
curl -X POST "$KNOWNPRINT_API/v1/keys" \
  -H "Authorization: Bearer $KNOWNPRINT_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: proxy-secret-2026-12" \
  -d '{"kind":"proxy_secret"}'
```
:::

```json title="201 Created"
{
  "id": "key_7mq3xk2vbn4tr6wy5hcz2dpa4e",
  "kind": "secret",
  "prefix": "sk_live_xxxxxxxx",
  "scopes": ["events:read"],
  "allowed_origins": [],
  "allowed_ip_ranges": [],
  "daily_cap": null,
  "created_at": "2026-12-02T09:14:07.512Z",
  "revoked_at": null,
  "value": "sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
```

Store `value` in your secret manager straight away. The `prefix`, the first 16 characters, is what `GET /v1/keys` shows later, so you can tell keys apart without their values. A proxy secret has no prefix.

The rules worth knowing:

- A public key takes `allowed_origins` (at least one) and optionally `allowed_ip_ranges` and `daily_cap`, never `scopes`. A secret key takes `scopes` (at least one) and nothing else. A proxy secret takes nothing else. Any other combination answers `422` [`validation_failed`](/api/errors#validation-failed) with the detail "The fields given do not fit the key kind."; a public key without a valid origin answers it with "A public key needs at least one allowed origin, each a serialised origin."
- Each entry of `allowed_ip_ranges` is an address or a CIDR range whose host bits are zero (`198.51.100.0/24`, not `198.51.100.7/24`).
- A key cannot revoke itself: `DELETE /v1/keys/{id}` with its own id answers `422` with the detail "The key making the request cannot revoke itself." Revoke an admin key from another admin key.
- A revoked key stops working everywhere within a minute.

## Rotating credentials

Rotate on a schedule, when someone with access leaves, and at once when you suspect a leak. Every rotation follows the same order: create the new credential, put it in place, then revoke the old one. Two credentials of the same kind work side by side in the meantime, so nothing breaks.

### Rotate a secret key

1. Create a new secret key with the same scopes (`POST /v1/keys`).
2. Deploy it to every service that used the old one.
3. Revoke the old key with `DELETE /v1/keys/{id}`. Within a minute it answers `401` everywhere.

```bash
curl -X DELETE "$KNOWNPRINT_API/v1/keys/$OLD_KEY_ID" \
  -H "Authorization: Bearer $KNOWNPRINT_ADMIN_KEY" \
  -H "Idempotency-Key: revoke-$OLD_KEY_ID"
```

### Rotate a public key

1. Create a new public key with the same `allowed_origins`, `allowed_ip_ranges` and `daily_cap`.
2. Ship pages that load the script with the new key.
3. Wait until no visitor can still hold a page with the old key, such as a cached page or a tab left open, then revoke it. An identification started with a revoked key fails, and the visit arrives at your backend without a request id.

### Rotate the proxy secret

Your environment accepts every proxy secret that has not been retired, so you can switch without a gap:

1. Create a new proxy secret (`POST /v1/keys` with `{"kind":"proxy_secret"}`).
2. Wait a minute: a new proxy secret takes effect within a minute.
3. Put the new value in your proxy's configuration and reload the proxy.
4. Retire the old one with `DELETE /v1/keys/{id}`. It stops being accepted within a minute.

### Rotate a webhook secret

A webhook keeps the secret it was created with, so rotation is done with a second webhook:

1. Create a webhook with the same `url`, `event_types` and `format` ([webhooks API](/api/webhooks)). Its answer holds the new `whsec_` secret, once.
2. Let your receiver accept a delivery that verifies against either secret.
3. Delete the old webhook, then remove its secret from your receiver.

While both webhooks exist, each event is delivered twice, once per webhook and each with its own `webhook-id`. Make your handler safe to run twice for the same event, as it already should be for retries.

## If a credential leaks

1. **Revoke it first.** `DELETE /v1/keys/{id}` for a key or proxy secret; delete the webhook for a webhook secret. Then create the replacement.
2. **Check what it could reach.** List your keys (`GET /v1/keys`) and webhooks (`GET /v1/webhooks`) and remove any you did not create: a leaked `keys:manage` or `webhooks:manage` key may have been used to add one.
3. **Find the cause.** Remove the value from wherever it was exposed (a commit, a log, a ticket) and from that history.
4. **Tell us** at security@knownprint.com if you think knownprint's side was involved.

## The proxy secret

Your proxy forwards each script request to knownprint together with the visitor's address and your proxy secret. The secret is what makes knownprint believe that address: anyone who holds it could send requests that claim any address for your environment. Treat it like a secret key.

**nginx**: keep it in its own file, included by the knownprint configuration ([nginx setup](/install/nginx)). Give the file mode `0640`, readable by the group of the nginx workers and nobody else, and keep it out of version control:

```nginx title="/etc/knownprint/proxy-secret.conf"
set $knownprint_proxy_secret "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
```

**Caddy**: pass it as the environment variable `KNOWNPRINT_PROXY_SECRET` through an environment file of the Caddy service that only root can read. The configuration reads it at request time, so it never appears in Caddy's stored configuration ([Caddy setup](/install/caddy)). Two more settings keep it there: remove `--environ` from Caddy's start command, since it prints the whole environment at every start, and turn Caddy's admin endpoint off (`admin off`) or bind it to a Unix socket that only root and Caddy can open.

The proxy configuration also makes sure only knownprint's own cookie goes to knownprint: your session cookies stay on your side ([proxy setup](/install/proxy)).

## Webhook security

Every delivery is signed with the webhook's secret, following the Standard Webhooks scheme: the `webhook-id`, `webhook-timestamp` and `webhook-signature` headers. Your receiver should:

- **Verify the signature** over the raw body before parsing it ([verify webhooks](/webhooks/verify)).
- **Reject old timestamps.** knownprint's own check allows 5 minutes either way; use the same window.
- **Compare in constant time**, as the standard libraries do.
- **Keep the secret out of logs**, like any other credential.

knownprint delivers only to `https` URLs that resolve to public addresses: a URL that points at a private, loopback, link-local or otherwise reserved address is refused when you create the webhook or change its URL, with `422` [`validation_failed`](/api/errors#validation-failed). The address is checked again at every delivery attempt. Deliveries never follow redirects, so a receiver that moves must be updated through the API (`PATCH /v1/webhooks/{id}`).

## Transport and the browser

- **Call the API over HTTPS**, at the address that comes with your account (`$KNOWNPRINT_API` in these pages). Never send a secret key over plain HTTP.
- **The cookie is `Secure`, `HttpOnly` and `SameSite=Lax`**, set on your own host through your proxy. No script on the page can read it ([privacy](/privacy)).
- **Results are never cached.** API answers and the script's identification requests carry `Cache-Control: no-store`; your proxy configuration keeps it that way.
- **The script runs from your own domain**, so a strict Content Security Policy needs your own origin for it, and `connect-src` for the knownprint host your account names (today https://na1.knownprint.com), which is required configuration ([Content Security Policy](/install/csp)).
- **A request id is checked on your server**, against the visit it came with ([verify in your backend](/install/server)). Treat a form that arrives without one as an unknown visit, not a pass: it is what a blocked or stripped script looks like.

### Failed authentication is rate limited

After 30 failed authentications in a minute from one client address, further failures from that address answer `429` until the bucket refills. A request with a valid key never counts against it. See [limits](/limits) for every rate limit.

## Reporting a vulnerability

If you find a security problem in knownprint, its script, its API or knownprint.com, write to **security@knownprint.com**, the address `https://knownprint.com/.well-known/security.txt` also names. Please include:

- what you found and where (the route, page or file),
- the steps to reproduce it, with the `request_id` of any API answer involved,
- what an attacker could do with it.

Test only against your own account and your own data. Do not access, change or delete other people's data, and do not run tests that degrade the service for others. Please give us the chance to fix the problem before you publish it.

## Related pages

- [API keys](/api/keys): every field of the key routes.
- [Privacy](/privacy): what is processed, retention and deletion.
- [Limits](/limits): rate limits, sizes and lifetimes.
- [Webhooks](/webhooks) and [verify webhooks](/webhooks/verify).
