---

title: SDKs
description: The libraries for knownprint in the browser and on your server, what each one does, which are available today and which come with the SDK release.
---

knownprint has two halves, and so do its libraries. In the browser, a script identifies the visit and hands your page a request id. On your server, your backend reads the event behind that id with your secret key, verifies it and acts on it. Everything the server libraries do is a thin layer over the [HTTP API](/api), which you can call from any language today.

## What is available

| Library                      | Where it runs       | What it does                                                                                                      | State                       |
| ---------------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------- | --------------------------- |
| Browser agent `/kp/agent.js` | Browser             | Loads from your own domain through your proxy and defines `window.knownprint`.                                    | Available                   |
| `@knownprint/web`            | Browser, bundled    | The same browser agent as an ES module, for applications that bundle their own JavaScript.                        | Coming with the SDK release |
| `@knownprint/sdk-js`         | Browser, bundled    | A small layer over the agent that puts a fresh request id into your forms before each submit.                     | Coming with the SDK release |
| `@knownprint/sdk-node`       | Node.js 22 or later | The server API client, `verifyRequestId` with a shared store of used ids, and webhook verification.               | Coming with the SDK release |
| Go, Python and PHP           | Your server         | Server libraries for the same API.                                                                                | Coming with the SDK release |
| HTTP API                     | Any server          | Every server operation: read and search events, attach account ids, feedback, visitors, deletion, webhooks, keys. | Available                   |

:::note Coming
The npm packages and the Go, Python and PHP libraries are not published yet: they come with the SDK release. Until then, load the browser agent from your domain and call the HTTP API from your backend. Every example on [Verify a request in your backend](/install/server) has a version that needs no SDK.
:::

## In the browser

### The browser agent (available)

The script tag is the way to run knownprint in the browser today. It loads `/kp/agent.js` from your own site, which your proxy forwards to knownprint ([Run knownprint from your domain](/install/proxy)), so the script and its identification requests are first party.

```html
<script src="/kp/agent.js" defer></script>
```

```js
// In a module script (<script type="module">), which runs after the deferred /kp/agent.js.
let requestId = null; // null: no request id, which your backend treats as unknown
try {
  if (window.knownprint) {
    const agent = await window.knownprint.load({ pk: 'pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' });
    ({ requestId } = await agent.identify());
  }
} catch {
  // The agent failed to load or to identify: go on without a request id.
}
```

`window.knownprint` is missing when a content blocker or a network error kept the script from loading, and `load()` rejects with `load_failed` when the agent itself cannot be fetched; in both cases your page goes on without a request id. The script defines `window.knownprint` with `load` and `version`. `load` takes the same options and returns the same `Agent` as `@knownprint/web`, so the reference on [Web SDK](/sdks/web) covers both. Setup, options and consent are on [Add the browser agent](/install/browser); sending the request id with your forms is on [Protect your forms](/install/forms).

### @knownprint/web and @knownprint/sdk-js (coming)

`@knownprint/web` is the agent as an ES module that imports nothing, for an application that bundles its own JavaScript and would rather not add a script tag. `@knownprint/sdk-js` builds on it (or on `window.knownprint`) and adds `attach(form)`, which writes a fresh request id into a hidden `kp_request_id` field before each submit. Both are described on [Web SDK](/sdks/web).

## On your server

### The HTTP API (available)

Your backend needs three calls for the core flow, each with your secret key in `Authorization: Bearer`:

| Step                               | Call                               | Scope             |
| ---------------------------------- | ---------------------------------- | ----------------- |
| Read the event behind a request id | `GET /v1/events/{request_id}`      | `events:read`     |
| Attach your account id             | `PATCH /v1/events/{request_id}`    | `events:write`    |
| Delete a visitor on request        | `DELETE /v1/visitors/{visitor_id}` | `visitors:delete` |

```bash
curl "$KNOWNPRINT_API/v1/events/$REQUEST_ID" \
  -H "Authorization: Bearer $KNOWNPRINT_SECRET_KEY"
```

The API address comes with your account; examples write it as `$KNOWNPRINT_API`. The full reference starts at [API reference](/api).

What a server SDK adds on top of these calls is small, and you can write it yourself in a few dozen lines:

- **Request id verification.** Accept each request id once, within 10 seconds, only when the event was not replayed, comes from your origin and from the address that posted the form. [Verify a request in your backend](/install/server) shows it in plain Node and in shell.
- **Webhook verification.** Check the HMAC signature of each delivery and its timestamp. [Verify webhooks](/webhooks/verify) has the algorithm and examples.
- **Typed errors.** Every error is an `application/problem+json` body with a stable `type` ([Errors](/api/errors)).

### Node SDK (coming)

`@knownprint/sdk-node` wraps the server routes, `verifyRequestId` with an in-memory or Redis store of used ids, and `Knownprint.verifyWebhook`. Its full reference is on [Node SDK](/sdks/node), so you can see what it will do and write code that is easy to move onto it.

### Go, Python and PHP (coming)

Server libraries for Go, Python and PHP come with the SDK release. Until then, use the HTTP API from those languages: the verification is one GET, one atomic "set if absent" in your cache, and five comparisons, as [Verify a request in your backend](/install/server) shows.

## Versions and compatibility

- The browser agent is served by your proxy from knownprint, so it updates without a deploy on your side. `window.knownprint.version` names the version a page runs.
- The API is versioned in its path (`/v1/`). Parse answers leniently: read the fields you use and ignore any you do not know.
- The event and webhook shapes the SDKs return are the same JSON the API answers, unchanged.
