API reference
Keys and service routes
List, create and revoke public keys, secret keys and proxy secrets, and the service routes for usage, reference data versions, health and the disclosure file.
This page covers the routes that manage access to your environment, and the small service routes around them.
| Method and path | Auth | Idempotency-Key |
|---|---|---|
GET /v1/keys | keys:manage | No |
POST /v1/keys | keys:manage | Yes |
DELETE /v1/keys/{id} | keys:manage | Yes |
GET /v1/usage | usage:read | Coming |
GET /v1/catalog/versions | None | No |
GET /health | None | No |
GET /.well-known/knownprint.json | None, served by your proxy | No |
The three kinds of key
Every key belongs to one environment. A key of a live environment starts pk_live_ or sk_live_, a key of a test environment pk_test_ or sk_test_.
| Kind | Value | Where it lives | What it does |
|---|---|---|---|
public | pk_live_ and 32 characters | In your page, through the agent | Identifies visitors on the origins you allow. Safe to publish. |
secret | sk_live_ and 32 characters | On your servers only | Calls the server API with the scopes it holds. |
proxy_secret | 32 characters | In your proxy's configuration | Proves to knownprint that agent requests came through your proxy. |
Your first keys come with your account. A secret key that holds the keys:manage scope can create more, rotate them and revoke them through the routes below.
The key object
Every key route answers keys in this shape. A key's value is never part of it, except once in the answer to its creation.
{
"id": "key_3m5hq7z2xk4ajc6d2tq7rfwz5e",
"kind": "public",
"prefix": "pk_live_k3x7m2qa",
"scopes": [],
"allowed_origins": ["https://shop.example.org", "https://www.shop.example.org"],
"allowed_ip_ranges": [],
"daily_cap": 200000,
"created_at": "2026-11-01T10:00:00.000Z",
"revoked_at": null
}| Field | Type | Meaning |
|---|---|---|
id | key_ id | The key's id, used to revoke it. Not secret. |
kind | public, secret or proxy_secret | The kind of key |
prefix | String or null | The first 16 characters of the value, such as sk_live_abcdefgh, to tell keys apart. null for a proxy secret. |
scopes | Array of strings | A secret key's scopes; empty for the other kinds |
allowed_origins | Array of strings | A public key's allowed origins; empty for the other kinds |
allowed_ip_ranges | Array of strings | A public key's allowed client address ranges; empty means any address |
daily_cap | Integer or null | A public key's daily cap on identifications; null means none |
created_at | RFC 3339 time | When the key was created |
revoked_at | RFC 3339 time or null | When it was revoked (for a proxy secret, retired); null while active |
GET /v1/keys
Lists every key and proxy secret of the environment, active and revoked, oldest first.
curl "$KNOWNPRINT_API/v1/keys" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"Response
200 with { "data": [ ... ] }, each item a key object, ordered by created_at then id. The list is not paged.
Errors
| Status | Type | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks keys:manage |
429 | rate_limited | The key's bucket is empty |
POST /v1/keys
Creates a key or a proxy secret. The answer carries its value once: store it in your secret manager straight away. No list or read shows it again.
Body
| Member | Public key | Secret key | Proxy secret |
|---|---|---|---|
kind | public | secret | proxy_secret |
scopes | Not allowed | Required: one or more scopes, no repeats | Not allowed |
allowed_origins | Required: one or more origins | Not allowed | Not allowed |
allowed_ip_ranges | Optional: addresses or CIDR ranges | Not allowed | Not allowed |
daily_cap | Optional: 1 to 2147483647, or null | Not allowed | Not allowed |
A member a kind does not take (even as null or an empty list), or an empty scopes on a secret key, answers 422 with the detail key_fields. A public key without at least one allowed origin answers the detail public_key_origins.
The rules for each member:
scopes: any ofevents:read,events:write,visitors:delete,webhooks:manage,keys:manageandusage:read. See Scopes.allowed_origins: each one a serialised origin, exactly as a browser sends it in theOriginheader: scheme, host in lower case and a port only when it is not the default, with no path and no trailing slash.https://shop.example.organdhttp://localhost:3000are origins;https://shop.example.org/andhttps://*.example.orgare not. Matching is exact, so list each host your pages run on. Anything else answers the detailpublic_key_origins.allowed_ip_ranges: client addresses or ranges such as203.0.113.0/24or2001:db8::/32, with the host bits of a range zero (203.0.113.7/24answers the detailinvalid_body). When the list is not empty, visitors from other addresses are refused withip_not_allowed. Leave it empty for a public site.daily_cap: the most identifications the key accepts per UTC day. Above it, identifications answer429until the next UTC midnight. Use it to bound what a leaked or abused public key can cost you.
curl -X POST "$KNOWNPRINT_API/v1/keys" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: create-public-key-shop" \
-d '{"kind":"public","allowed_origins":["https://shop.example.org"],"daily_cap":200000}'curl -X POST "$KNOWNPRINT_API/v1/keys" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: create-secret-key-checkout" \
-d '{"kind":"secret","scopes":["events:read","events:write"]}'curl -X POST "$KNOWNPRINT_API/v1/keys" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: create-proxy-secret-2026-11" \
-d '{"kind":"proxy_secret"}'Response
201 with the key object and its value:
{
"id": "key_w6k2m7q3z4t5a2xr7d3h6n4pbv",
"kind": "secret",
"prefix": "sk_live_m4q7z2k6",
"scopes": ["events:read", "events:write"],
"allowed_origins": [],
"allowed_ip_ranges": [],
"daily_cap": null,
"created_at": "2026-11-04T09:12:44.120Z",
"revoked_at": null,
"value": "sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}A proxy secret's prefix is null and its value is 32 characters without a prefix.
If the answer is lost, retry with the same Idempotency-Key within 24 hours: the stored answer, value included, comes back without creating a second key. knownprint stores that answer encrypted.
Errors
| Status | Type | When |
|---|---|---|
400 | schema_mismatch | The body is not JSON, or the content type is not application/json |
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks keys:manage |
409 | idempotency_conflict | The Idempotency-Key was used for another request, or is still in flight |
422 | validation_failed | invalid_body, key_fields, public_key_origins or idempotency_key |
429 | rate_limited | The key's bucket is empty |
DELETE /v1/keys/{id}
Revokes a public or secret key, or retires a proxy secret. A revoked key or retired secret stops working everywhere within 60 seconds and cannot be restored. A new proxy secret likewise starts working within 60 seconds of its creation.
curl -X DELETE "$KNOWNPRINT_API/v1/keys/key_3m5hq7z2xk4ajc6d2tq7rfwz5e" \
-H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY" \
-H "Idempotency-Key: revoke-key_3m5hq7z2xk4ajc6d2tq7rfwz5e"Response
204 with no body. Revoking a key that is already revoked also answers 204.
A key cannot revoke itself: use another secret key with keys:manage, so you never lock yourself out.
Rotating a key
- Create the new key with
POST /v1/keys. - Deploy it: the new public key in your page, the new secret key in your servers, the new proxy secret in your proxy.
- Check that traffic works with the new key.
- Revoke the old key with
DELETE /v1/keys/{id}.
Between steps 1 and 4 both keys work, so the rotation needs no downtime. Every proxy secret that is not retired is accepted, so the same steps rotate a proxy secret; wait a minute after creating it before you deploy it. See Run knownprint from your domain.
Errors
| Status | Type | When |
|---|---|---|
401 | unauthorized | No valid secret key |
403 | forbidden_scope | The key lacks keys:manage |
404 | not_found | The id is malformed or names no key of this environment |
409 | idempotency_conflict | The Idempotency-Key was used for another request, or is still in flight |
422 | validation_failed | own_key (the key is revoking itself) or idempotency_key |
429 | rate_limited | The key's bucket is empty |
GET /v1/usage
GET /v1/catalog/versions
Answers the versions of the reference data knownprint's signals run with. It needs no key. The answer changes only when knownprint deploys new reference data, so it is useful to record next to an investigation, or to quote to your knownprint contact about a signal that changed.
curl "$KNOWNPRINT_API/v1/catalog/versions"{
"catalogs": [
{
"catalog": "privacy-modes",
"schemaVersion": 1,
"dataVersion": "2026.11.03.1",
"generatedAt": "2026-11-03T00:00:00.412Z"
}
],
"mask_table_version": 2
}| Field | Type | Meaning |
|---|---|---|
catalogs | Array | One entry per reference data set, in name order |
catalogs[].catalog | String | The data set's name |
catalogs[].schemaVersion | Integer | The format version of the data set |
catalogs[].dataVersion | String | The data version, as YYYY.MM.DD.N |
catalogs[].generatedAt | RFC 3339 time | When the data set was built |
mask_table_version | Integer | A version number for knownprint's own use; do not build rules on it |
The answer is cached for 5 minutes (Cache-Control: public, max-age=300). Only GET is served.
GET /health
Answers whether the API and its storage are up. It needs no key and is cheap to call, so you can point an uptime monitor at it.
curl -i "$KNOWNPRINT_API/health"{
"ok": true,
"availability": "none",
"db": true,
"valkey": true,
"version": "0.0.0"
}| Field | Type | Meaning |
|---|---|---|
ok | Boolean | true when the database and the cache both answer |
availability | String | For knownprint's own use; ignore it. |
db | Boolean | The database answered within 500 ms |
valkey | Boolean | The cache answered within 500 ms |
version | String | The API's software version |
The status is 200 when ok is true and 503 when it is false, with the same body. Answers are reused for one second, so polling it hard costs nothing and shows nothing finer.
GET /.well-known/knownprint.json
The disclosure file: a short machine-readable statement, on your own domain, of what knownprint collects on your site, why and for how long. Your proxy serves it as a static file at https://your-site/.well-known/knownprint.json; the API does not. The proxy recipes in Run knownprint from your domain include it.
It is a JSON object with the members service (always knownprint), version, operator, purposes, signals, retention, rights_url and contact. Edit operator, rights_url and contact before you go live, and keep the retention figures in step with your own privacy notice. The disclosure file describes every member and what to put in it.