knownprintDocs

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 pathAuthIdempotency-Key
GET /v1/keyskeys:manageNo
POST /v1/keyskeys:manageYes
DELETE /v1/keys/{id}keys:manageYes
GET /v1/usageusage:readComing
GET /v1/catalog/versionsNoneNo
GET /healthNoneNo
GET /.well-known/knownprint.jsonNone, served by your proxyNo

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_.

KindValueWhere it livesWhat it does
publicpk_live_ and 32 charactersIn your page, through the agentIdentifies visitors on the origins you allow. Safe to publish.
secretsk_live_ and 32 charactersOn your servers onlyCalls the server API with the scopes it holds.
proxy_secret32 charactersIn your proxy's configurationProves 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.

JSON
{
  "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
}
FieldTypeMeaning
idkey_ idThe key's id, used to revoke it. Not secret.
kindpublic, secret or proxy_secretThe kind of key
prefixString or nullThe first 16 characters of the value, such as sk_live_abcdefgh, to tell keys apart. null for a proxy secret.
scopesArray of stringsA secret key's scopes; empty for the other kinds
allowed_originsArray of stringsA public key's allowed origins; empty for the other kinds
allowed_ip_rangesArray of stringsA public key's allowed client address ranges; empty means any address
daily_capInteger or nullA public key's daily cap on identifications; null means none
created_atRFC 3339 timeWhen the key was created
revoked_atRFC 3339 time or nullWhen 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.

Shell
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

StatusTypeWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks keys:manage
429rate_limitedThe 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

MemberPublic keySecret keyProxy secret
kindpublicsecretproxy_secret
scopesNot allowedRequired: one or more scopes, no repeatsNot allowed
allowed_originsRequired: one or more originsNot allowedNot allowed
allowed_ip_rangesOptional: addresses or CIDR rangesNot allowedNot allowed
daily_capOptional: 1 to 2147483647, or nullNot allowedNot 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 of events:read, events:write, visitors:delete, webhooks:manage, keys:manage and usage:read. See Scopes.
  • allowed_origins: each one a serialised origin, exactly as a browser sends it in the Origin header: 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.org and http://localhost:3000 are origins; https://shop.example.org/ and https://*.example.org are not. Matching is exact, so list each host your pages run on. Anything else answers the detail public_key_origins.
  • allowed_ip_ranges: client addresses or ranges such as 203.0.113.0/24 or 2001:db8::/32, with the host bits of a range zero (203.0.113.7/24 answers the detail invalid_body). When the list is not empty, visitors from other addresses are refused with ip_not_allowed. Leave it empty for a public site.
  • daily_cap: the most identifications the key accepts per UTC day. Above it, identifications answer 429 until the next UTC midnight. Use it to bound what a leaked or abused public key can cost you.
Public key
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}'
Secret key
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"]}'
Proxy secret
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:

JSON
{
  "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

StatusTypeWhen
400schema_mismatchThe body is not JSON, or the content type is not application/json
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks keys:manage
409idempotency_conflictThe Idempotency-Key was used for another request, or is still in flight
422validation_failedinvalid_body, key_fields, public_key_origins or idempotency_key
429rate_limitedThe 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.

Shell
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

  1. Create the new key with POST /v1/keys.
  2. Deploy it: the new public key in your page, the new secret key in your servers, the new proxy secret in your proxy.
  3. Check that traffic works with the new key.
  4. 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

StatusTypeWhen
401unauthorizedNo valid secret key
403forbidden_scopeThe key lacks keys:manage
404not_foundThe id is malformed or names no key of this environment
409idempotency_conflictThe Idempotency-Key was used for another request, or is still in flight
422validation_failedown_key (the key is revoking itself) or idempotency_key
429rate_limitedThe 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.

Shell
curl "$KNOWNPRINT_API/v1/catalog/versions"
JSON
{
  "catalogs": [
    {
      "catalog": "privacy-modes",
      "schemaVersion": 1,
      "dataVersion": "2026.11.03.1",
      "generatedAt": "2026-11-03T00:00:00.412Z"
    }
  ],
  "mask_table_version": 2
}
FieldTypeMeaning
catalogsArrayOne entry per reference data set, in name order
catalogs[].catalogStringThe data set's name
catalogs[].schemaVersionIntegerThe format version of the data set
catalogs[].dataVersionStringThe data version, as YYYY.MM.DD.N
catalogs[].generatedAtRFC 3339 timeWhen the data set was built
mask_table_versionIntegerA 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.

Shell
curl -i "$KNOWNPRINT_API/health"
JSON
{
  "ok": true,
  "availability": "none",
  "db": true,
  "valkey": true,
  "version": "0.0.0"
}
FieldTypeMeaning
okBooleantrue when the database and the cache both answer
availabilityStringFor knownprint's own use; ignore it.
dbBooleanThe database answered within 500 ms
valkeyBooleanThe cache answered within 500 ms
versionStringThe 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.