# ProctorKit: full documentation for coding agents
Site: https://proctorkit.com API base: https://proctorkit.com/api
ProctorKit adds proctoring to the quiz page you already have. A small browser library runs a system check, gets consent, keeps the test in full screen with the entire screen shared and the camera on, and records the session against each question. You keep your questions, answers and scoring.
There are two ways to use it:
- **The SDK on its own, free and open source.** The recording and events go to your own code, and you store them where you choose. No account, nothing sent to us.
- **With ProctorKit Cloud.** The recording and events are stored for you, and each candidate gets a report and a dashboard entry. Each key runs in one of two modes: **Recording only** (free during launch) or **AI review**, where AI reviews each session and ranks sessions by review priority (₹15 in India or $0.25 elsewhere per [candidate session](#what-counts-as-a-candidate-session), first 50 free).
Step-by-step guides: [React](/docs/react/), [Next.js](/docs/nextjs/), [plain HTML](/docs/html/).
The SDK is written in TypeScript, ships its type declarations, and is MIT licensed [on GitHub](https://github.com/aproli90/proctorkit). Coding agents can read these docs as plain text at [/llms-full.txt](/llms-full.txt).
## Requirements
- Desktop Chrome or Edge for the full set of checks. Other browsers get a clear `unsupported` result, never a broken test. Phones and tablets cannot share their screen from a browser.
- A page served over HTTPS, or `localhost` while you build. Browsers only allow the camera and screen sharing there.
## Install
```bash
npm install proctorkit
```
Or with a script tag, which gives you a global `ProctorKit` with the same exports:
```html
```
## What is recorded
During the test the SDK records the webcam and the screen as video, and takes a photo of each about every 10 seconds, plus extra photos when something happens. Every part of the recording carries the question that was on screen. You can turn the video off with `clips: false`, or both with `snapshots: false`.
The candidate is told all of this on the consent screen before anything is recorded.
## Which key
Does your quiz have its own backend? Then use a [server key](#with-a-server-key): one for all your tests, kept on your server. If it is only a web page, use a page key, one per website. Either way, your quiz names each test, and the dashboard lists candidates under that name. A key is only access: the websites it works on, the plan and a daily limit.
## Quick start with a page key
5 lines in your quiz, and no server code. Results appear in your dashboard.
**1. Get a page key.** [Create an account](/app/?new), answer **No** to "Does your quiz have its own backend?", give the key a name you will recognise (like your site's), add the website it runs on, and choose **Recording only** or **AI review**. You get a key that starts with `pk_pub_`. It goes in the page, so anyone taking the test can copy it. It works only on the websites listed on it (and on `localhost`), up to a daily limit you set, and it spends your AI-reviewed sessions. For AI review we recommend a [server key](#with-a-server-key) instead: your server starts each session and the key never reaches the page.
**2. Add it to your quiz.** React:
```tsx
import { useEffect, useState } from 'react';
import { createProctor } from 'proctorkit';
export function Quiz({
user,
questions,
}: {
user: { id: string; name: string; email?: string };
questions: { id: string }[];
}) {
// once per candidate; the dashboard lists them under the test
const [proctor] = useState(() =>
createProctor({
key: 'pk_pub_...',
candidate: { id: user.id, name: user.name, email: user.email },
test: { id: 'sales-1', name: 'Sales screening' },
}),
);
const [started, setStarted] = useState(false);
const [i, setI] = useState(0);
// the Start button: system check, consent, then the test
const begin = async () => {
const check = await proctor.runChecks();
if (check.ok && proctor.start()) setStarted(true);
};
// tell ProctorKit which question is on screen
useEffect(() => {
if (started) proctor.setContext({ questionId: questions[i].id });
}, [started, i]);
const submit = () => {
proctor.stop(); // then save the answers as you do today
};
// ...render the quiz once started
}
```
`candidate.id` and `candidate.name` are required with a key; `email` is optional. `test: { id, name }` names the test, so one key can serve several tests; a session without it is listed under the key's name.
`runChecks()` shows its own system check (camera, entire screen shared, full screen, consent) and resolves when the candidate is ready, or with the reason they are not. Use any question ID; ProctorKit never sees your questions or answers.
**3. Read the results.** Each candidate appears in your dashboard under their test, with the recording and flags laid out by question. With AI review, each also gets a review priority from 0 to 100, so you can look at the riskiest first. A person makes the decision.
If the key is refused or the service cannot be reached, the test still runs with the on-device checks, the SDK fires a [`cloud_unavailable`](#events) event and logs the reason to the console. Proctoring problems never block a candidate's test.
## With a server key
Use this when your quiz has its own backend. Your account has one secret server key (`pk_live_`) for all its tests. Your server starts each candidate's session, naming the test, and hands the page a short-lived session token. The page code is the same apart from how the proctor is created.
**1. Create a session on your server** when a candidate opens the test:
```bash
curl -X POST https://proctorkit.com/api/v1/sessions \
-H "Authorization: Bearer $PROCTORKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"candidate": { "id": "c-1042", "name": "Asha Rao", "email": "asha@example.com" },
"test": { "id": "sales-1", "name": "Sales screening" }
}'
```
The same in Node, as an Express route:
```ts
app.post('/api/proctor-session', async (req, res) => {
const r = await fetch('https://proctorkit.com/api/v1/sessions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PROCTORKIT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
candidate: {
id: req.user.id,
name: req.user.name,
email: req.user.email,
},
test: { id: 'sales-1', name: 'Sales screening' },
}),
});
if (!r.ok) return res.status(502).json({ error: (await r.json()).error });
const s = await r.json();
// keep these on your side
await saveForCandidate(req.user.id, {
sessionId: s.sessionId,
reportUrl: s.reportUrl,
});
res.json({
endpoint: s.endpoint,
sessionToken: s.sessionToken,
settings: s.settings,
organisation: s.organisation,
retentionDays: s.retentionDays,
});
});
```
The full response is under [Create a session](#create-a-session).
**2. Start it on the page:**
```ts
const s = await fetch('/api/proctor-session', { method: 'POST' }).then((r) =>
r.json(),
);
const proctor = createProctor({
cloud: { endpoint: s.endpoint, sessionToken: s.sessionToken },
settings: s.settings,
consent: { organisation: s.organisation, retentionDays: s.retentionDays },
});
// then runChecks, start, setContext and stop, as in the quick start
```
Pass `endpoint` exactly as you received it; it can carry a query string. The page never needs the session ID: your server kept it in step 1, so `proctor.sessionId` stays `null` with a server key.
Create the proctor once per attempt, after the session response arrives. In React, fetch the session in a parent and mount the quiz component only when it is there, so `useState(() => createProctor(...))` runs exactly once:
```tsx
function TestPage() {
const [s, setS] = useState(null);
useEffect(() => {
fetch('/api/proctor-session', { method: 'POST' })
.then((r) => r.json())
.then(setS);
}, []);
return s ? :
Loading…
;
}
function Quiz({ session: s }) {
// runs once: Quiz mounts only after the session has arrived
const [proctor] = useState(() =>
createProctor({
cloud: { endpoint: s.endpoint, sessionToken: s.sessionToken },
settings: s.settings,
consent: { organisation: s.organisation, retentionDays: s.retentionDays },
}),
);
// ...the quiz, as in the React guide
}
```
Creating it in the component that fetches (on every render, or before the response is in) makes several proctors, each asking for the camera.
**3. Read the result:** open the `reportUrl`, set a [webhook](#webhooks) to be told when it is ready, or call [Get a session](#get-a-session).
## On its own, without an account
```ts
const proctor = createProctor({
consent: { organisation: 'Acme Hiring', retentionDays: 30 },
onEvent: (event) => sendToYourServer(event),
// the session video, half a minute at a time
onClip: (clip) => uploadToYourStorage(clip.mp4),
// optional: a photo about every 10 s as well
onSnapshot: (snapshot) => uploadToYourStorage(snapshot.dataUrl),
});
```
Everything else is the same: `runChecks()`, `start()`, `setContext()`, `stop()`. Nothing leaves the page except through your handlers. The video is built only when `onClip` is given.
You store the recording, so you decide how long it is kept. Set `consent.retentionDays` to what your storage really does; if you leave it out, the consent notice tells candidates the recording is kept as set out in your privacy notice, instead of promising a period.
Each clip is an MP4 of JPEG pictures. Some browsers will not play it in a `` element; `clipFrames(bytes)` returns the pictures, so you can show them as a slideshow.
## Pauses and your timer
If the candidate leaves full screen, stops sharing, loses the camera or plugs in a second display, the test pauses and tells them how to fix it. ProctorKit has no timer of its own. Drive your countdown from `proctor.activeMs()`, which leaves out paused time, or listen:
```ts
// e.data.reason: 'fullscreen' | 'screen' | 'camera' | 'display'
proctor.on('paused', (e) => myTimer.stop());
// e.data.pausedMs: how long this pause lasted
proctor.on('resumed', (e) => myTimer.start());
```
## Webhooks
Set one webhook address for your account in the dashboard (**Account**, then **Webhook**), and ProctorKit posts to it for every session any of your keys starts. `data.test` tells you which test it came from:
| Event | When |
| --- | --- |
| `session.ended` | The candidate finished; or left without finishing: within about 2 minutes of closing the page, or after 10 minutes with no contact (the session then has a `left_unfinished` flag) |
| `session.reviewed` | The result is final: AI review is done (or did not run), usually within a minute or two of the end |
Each delivery is a `POST` with a JSON body:
```json
{
"id": "whd_7f3a…",
"event": "session.reviewed",
"createdAt": "2026-11-19T10:46:02.000Z",
"data": {
"sessionId": "3f6c1e2a-…",
"candidate": {
"id": "c-1042",
"name": "Asha Rao",
"email": "asha@example.com"
},
"test": { "id": "sales-1", "name": "Sales screening" },
"status": "ended",
"riskScore": 62,
"…": "…"
}
}
```
`data` has the same fields as [Get a session](#get-a-session).
**Optional: check that it came from us.** You get deliveries either way; checking the signature lets your server ignore anything not sent by ProctorKit. The `ProctorKit-Signature` header looks like `t=1795100000,v1=5f2b…`. Compute HMAC-SHA256 of `"."` with your account's signing secret (**Account**, then **Webhook**), compare it to `v1` in constant time, and reject deliveries whose `t` is more than 5 minutes old.
Sign the body **exactly as it arrived**. If your framework parses the JSON first and you `JSON.stringify` it again, the bytes change (spacing, key order, escaped characters) and every signature fails with your server answering `400`. Express needs `express.raw()` on this route, as below:
```ts
import crypto from 'node:crypto';
app.post(
'/proctorkit',
express.raw({ type: 'application/json' }),
(req, res) => {
const [t, v1] = (req.get('ProctorKit-Signature') || '')
.split(',')
.map((p) => p.split('=')[1]);
const want = crypto
.createHmac('sha256', process.env.PROCTORKIT_WEBHOOK_SECRET)
.update(`${t}.${req.body}`)
.digest('hex');
const ok =
v1 &&
want.length === v1.length &&
crypto.timingSafeEqual(Buffer.from(want), Buffer.from(v1));
if (!ok || Math.abs(Date.now() / 1000 - Number(t)) > 300)
return res.sendStatus(400);
const delivery = JSON.parse(req.body); // delivery.event, delivery.data
res.sendStatus(200);
},
);
```
In a Next.js route handler, read the text before anything parses it:
```ts
// app/api/proctorkit-webhook/route.ts
import crypto from 'node:crypto';
export async function POST(req: Request) {
const raw = await req.text(); // not req.json(): the signature covers these exact bytes
const [t, v1] = (req.headers.get('ProctorKit-Signature') || '')
.split(',')
.map((p) => p.split('=')[1]);
const want = crypto
.createHmac('sha256', process.env.PROCTORKIT_WEBHOOK_SECRET!)
.update(`${t}.${raw}`)
.digest('hex');
const ok =
v1 &&
want.length === v1.length &&
crypto.timingSafeEqual(Buffer.from(want), Buffer.from(v1));
if (!ok || Math.abs(Date.now() / 1000 - Number(t)) > 300)
return new Response('bad signature', { status: 400 });
const delivery = JSON.parse(raw); // delivery.event, delivery.data
return new Response('ok');
}
```
Answer with any `2xx` within 10 seconds. Anything else is retried after 1, 5, 30, 120, 360, 720 and 1,440 minutes. A delivery can arrive more than once; use `id` to ignore repeats. The header `ProctorKit-Event` carries the event name, and **Send a test event** in the dashboard posts a `ping`. The Account page shows each delivery of the last 30 events, with the exact request, your server's answer and a **Send again** button.
## Teams and sharing
- **Invite your team.** In the dashboard, **Team** lets an owner invite people by email as an **Owner** (everything, including keys and the team) or a **Reviewer** (candidates, reports and decisions). They join when they sign in with that email address.
- **Several accounts.** One person can be in several accounts and switch between them; **New account** in the switcher makes another, for example one per client. Each account has its own keys, candidates, team and billing.
- **Share one report.** On a report, **Create a share link** makes a link that opens it without signing in. Any member can turn it off.
- **Emails.** Each member chooses, per account, whether to get a reminder about a week before flagged candidates with no decision lose their recording, and (owners) a notice when AI-reviewed sessions run low.
## REST API
Base URL: `https://proctorkit.com/api`
Your server calls the routes under `/v1` with a server key in the `Authorization` header. They send no CORS headers, so a browser page cannot call them, and the key must never be in a page. The SDK calls the other routes for you.
Every error has the same shape, with an HTTP status code that says what kind it is:
```json
{
"error": "This key has reached its daily limit of sessions. Raise it in the dashboard."
}
```
### Create a session
`POST /v1/sessions`, with `Authorization: Bearer pk_live_...`
| Body field | Type | Notes |
| --- | --- | --- |
| `candidate` | object, required | `{ id, name, email? }`. `id` is your ID for the candidate (up to 200 characters), `name` is shown in the dashboard and report |
| `test` | object, optional | `{ id?, name? }`. One server key serves all your tests: this is how the dashboard tells them apart. Without it, sessions are listed together as "Server key" |
| `aiReview` | boolean, optional | `false` for a Recording only session, `true` for AI review. Defaults to the plan set on your server key |
| `metadata` | object, optional | Anything you want back later. Up to 4,000 characters as JSON |
| `ttlMinutes` | number, optional | How long the session token stays valid. 10 to 720, default 240 |
Response `201`:
```json
{
"sessionId": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b8e0c4a91",
"sessionToken": "pks_6e0f…",
"expiresAt": "2026-11-19T14:00:00.000Z",
"endpoint": "https://proctorkit.com/api?…",
"settings": { "snapshotIntervalSec": 10, "automatedChecks": true, "…": "…" },
"organisation": "Acme Hiring",
"retentionDays": 90,
"reportToken": "pkr_9b2d…",
"reportUrl": "https://proctorkit.com/report/?s=3f6c1e2a-8b4d-4c1e-9a7f-2d5b8e0c4a91&k=pkr_9b2d…"
}
```
| Field | What to do with it |
| --- | --- |
| `sessionToken`, `endpoint` | Send to the page and pass as `cloud: { endpoint, sessionToken }`, unchanged |
| `settings` | Send to the page and pass as `settings`, unchanged. `automatedChecks` says whether AI review runs for this session: it is `false` when the account has no AI-reviewed sessions left, and the test [records only](#when-ai-reviewed-sessions-run-out) |
| `organisation`, `retentionDays` | Send to the page for the consent notice |
| `sessionId` | Keep on your server, to fetch the result |
| `reportUrl`, `reportToken` | Keep on your server and give the link to the reviewer. It is private: never send it to the candidate's page |
| `expiresAt` | When the session token stops working |
| Status | When |
| --- | --- |
| `400` | `candidate.id` or `candidate.name` is missing, or `metadata` is too large |
| `401` | The key is missing, wrong or deleted |
| `403` | The key is switched off in the dashboard |
| `429` | The key reached its daily limit of sessions |
### Get a session
`GET /v1/sessions/{sessionId}`, with `Authorization: Bearer pk_live_...`
Response `200`:
```json
{
"sessionId": "3f6c1e2a-8b4d-4c1e-9a7f-2d5b8e0c4a91",
"candidate": {
"id": "c-1042",
"name": "Asha Rao",
"email": "asha@example.com"
},
"test": { "id": "sales-1", "name": "Sales screening" },
"metadata": {},
"status": "ended",
"createdAt": "2026-11-19T10:00:00.000Z",
"startedAt": "2026-11-19T10:01:12.000Z",
"endedAt": "2026-11-19T10:44:05.000Z",
"blocksBilled": 1.5,
"riskScore": 62,
"flagCounts": { "info": 14, "warn": 3, "high": 2 },
"flagSummary": {
"phone_in_use": { "incidents": 1, "frames": 3, "seconds": 20 },
"focus_returned": { "incidents": 2, "frames": 0, "seconds": 0 }
},
"verdict": null,
"verdictNote": null,
"verdictAt": null,
"automatedChecks": true,
"aiReviewSkipped": null,
"flags": [
{
"type": "phone_in_use",
"severity": "high",
"source": "server",
"at": "2026-11-19T10:12:40.000Z",
"ms": 688000,
"endMs": 716000,
"context": { "questionId": "Q07" }
},
{
"type": "focus_returned",
"severity": "warn",
"source": "client",
"at": "2026-11-19T10:20:03.000Z",
"ms": 1131000,
"context": { "questionId": "Q11" },
"data": { "awayMs": 9400 }
}
],
"note": "Flags are prompts for a person to review. Do not fail a candidate on a score alone."
}
```
| Field | Meaning |
| --- | --- |
| `status` | `created` (token issued, test not started), `active`, `ended`, `expired` (the page never said it finished), `archived` (the recording was deleted at the end of the retention period; the result is kept) |
| `blocksBilled` | Candidate sessions charged so far: 1 for up to 30 minutes, then by the minute (45 minutes is 1.5). Always 0 for Recording only keys during launch |
| `riskScore` | The review priority, 0 to 100: who to look at first, not a test result. Computed from browser events alone when AI review is off |
| `flagCounts` | Number of flags by severity |
| `flagSummary` | For each kind of flag: how many separate incidents, and roughly how long they lasted |
| `verdict`, `verdictNote`, `verdictAt` | What a reviewer recorded in the dashboard: `clear`, `concern` or `null` |
| `automatedChecks`, `aiReviewSkipped` | Whether AI review ran. When the key asks for AI review but the account had none left, `automatedChecks` is `false` and `aiReviewSkipped` is `no_credits`; otherwise `aiReviewSkipped` is `null` |
| `flags` | Every `warn` and `high` flag in time order (up to 1,000), each with the question on screen in `context`. `source` is `server` for AI review, `client` for the browser. Some flags cover a stretch of time: then `endMs` is set, and the event happened at some moment between `ms` and `endMs` |
AI review finishes shortly after the test ends, so a session read straight away can still gain flags. Use the `session.reviewed` [webhook](#webhooks), or read it again a minute or two later.
### List sessions
`GET /v1/sessions`, with `Authorization: Bearer pk_live_...`
Newest first. Query parameters, all optional:
| Parameter | Meaning |
| --- | --- |
| `candidateId` | Only this candidate's sessions (every attempt) |
| `testId` | Only this test's sessions |
| `status` | `created`, `active`, `ended`, `expired` or `archived` |
| `since` | Only sessions created after this ISO time |
| `limit` | 1 to 200, default 50 |
| `cursor` | The `next` value from the previous page |
Response `200`: `{ "sessions": [ … ], "next": "2026-11-18T09:12:00.000Z" }`. Each entry has the top-level fields of [Get a session](#get-a-session) without `flags`. `next` is `null` on the last page.
### Get the recording
`GET /v1/sessions/{sessionId}/media`, with `Authorization: Bearer pk_live_...`
Links to the session's photos and video, to copy into your own storage. Links expire after 10 minutes; ask again for fresh ones.
```json
{
"photos": [
{
"kind": "webcam",
"reason": "interval",
"ms": 12000,
"at": "…",
"context": { "questionId": "Q1" },
"url": "https://…"
}
],
"clips": [
{
"kind": "screen",
"startMs": 0,
"endMs": 28000,
"frames": 15,
"flagged": false,
"url": "https://…"
}
],
"next": null,
"linksExpireInSeconds": 600
}
```
A photo's `reason` is `interval` (the regular photo), `event` (taken because something happened) or `evidence` (the picture that shows a flag from AI review). Photos come 500 at a time by default (`limit` up to 1,000); pass `afterMs` with the `next` value for the next page. `flagged` marks parts of the video that raised a flag. An `archived` session returns empty lists.
### Flag types
| Type | From | Meaning |
| --- | --- | --- |
| `other_person_near` | AI review | Another person close to the candidate or their screen |
| `other_person_background` | AI review | Another person in the room, away from the desk |
| `phone_in_use` | AI review | A phone held, at the ear, or propped up facing the candidate or screen |
| `phone_idle` | AI review | A phone lying flat on the desk |
| `candidate_absent` | AI review | Nobody at the device |
| `camera_covered` | AI review | The camera's view is covered or blank. Replaces `candidate_absent` for the same moment |
| `looking_away` | AI review | Keeps looking away from the screen at something out of view (below the camera, to the side, at a wrist). Writing on rough paper does not count. Only ever worth a look |
| `other_app_visible` | AI review | Another app or window on the shared screen |
| `test_not_visible` | AI review | The test is not the main window on screen |
| `focus_returned` | Browser | Came back to the test after leaving it; `data.awayMs` says for how long |
| `page_closed` | Browser | The tab was closed, reloaded or left while the test ran |
| `left_unfinished` | Server | The test stopped without finishing: the page was closed (`data.closed`), or the browser went silent for 10 minutes. The session ends at the last contact |
| `fullscreen_exit`, `screen_share_stopped`, `camera_lost`, `extra_display` | Browser | A requirement broke and the test paused |
| `no_face` | Browser | No face in view for a while; the candidate was prompted |
| `camera_blocked` | Browser | No face and a featureless picture for a few seconds, as when the lens is covered (or the room is very dark); the candidate was prompted. Reported instead of `no_face`. From SDK 0.2.5 |
| `paste_blocked`, `copy_blocked`, `cut_blocked` | Browser | A clipboard attempt was blocked |
| `pointer_left_page` | Browser | The pointer left the page for a while |
| `screen_surface_unverified` | Browser | The browser did not say what was shared |
| `virtual_camera` | Browser | The camera's name says it is software (OBS, ManyCam and the like) |
| `virtual_machine` | Browser | The test ran inside a virtual machine (VMware, VirtualBox, Parallels, QEMU), so the real computer was out of sight. From SDK 0.2.6 |
New flag types can be added over time. Treat a type you do not recognise as something to look at.
### Routes the SDK calls
You do not call these yourself; they are listed so you know what the page sends.
| Route | Sent by | What it does |
| --- | --- | --- |
| `POST /page/session` | The SDK, with a page key | Opens a session for this candidate. Refusals reach your page as a `cloud_unavailable` event with `data.code`: `key_invalid`, `key_off`, `domain_not_allowed`, `daily_cap`, `candidate_required` or `unavailable`. Running out of AI-reviewed sessions is not a refusal: the session [records only](#when-ai-reviewed-sessions-run-out) |
| `POST /clip` | The SDK | Half a minute of the webcam or screen video, as an MP4, with the session token in the `X-PK-Token` header |
| `POST /snapshot` | The SDK | One webcam photo or screenshot, with the session token, the time and the question on screen |
| `POST /events` | The SDK | A batch of browser events, every 5 seconds |
### Limits you can set
| Setting | Default | How to change it |
| --- | --- | --- |
| Candidates a day, per key | 50 for a page key, 2,000 for a server key | **Keys**, then **Edit**: any number up to 100,000 |
| Session token lifetime | 240 minutes | `ttlMinutes` when your server creates a session: 10 to 720 |
| How long AI-reviewed recordings are kept | 90 days | **Account** (owners): 7, 14, 30, 60 or 90 days, for tests that start after the change |
Parts of an AI-reviewed video with nothing flagged go after 7 days, and Recording only keeps recordings 30 days. Results and flags stay until you delete the record. Upload sizes and rates are handled by the SDK; there is nothing to manage.
### What counts as a candidate session
- One person taking one test, up to 30 minutes.
- Longer tests count by the minute: 45 minutes is 1.5 sessions.
- Tests that never start are not counted.
### When AI-reviewed sessions run out
Nothing stops. A test that starts after the last AI-reviewed session is used still runs and records, kept 30 days, without AI review. A test already under way finishes with AI review. The dashboard marks those candidates *Recorded only*, and the [session](#get-a-session) has `aiReviewSkipped` set.
Account owners get an email when 10 AI-reviewed sessions are left and another when none are left, and the dashboard shows the same notice. AI review starts again on the next candidate once sessions are added.
Prices are ₹ for customers in India and US$ elsewhere: AI review is ₹15 or $0.25 per candidate session; after launch, Recording only is ₹5 or $0.10 per session beyond the free 100 a month.
## SDK reference
### createProctor(config)
Every option is optional, except `candidate` when you pass a `key`.
| Option | Type | Default | What it does |
| --- | --- | --- | --- |
| `key` | `string` | | A page key (`pk_pub_`) from the dashboard. The page opens its own session |
| `candidate` | `{ id: string; name: string; email?: string }` | | Who is taking the test. Required with `key` |
| `test` | `{ id?: string; name?: string }` | the key's name | Groups candidates by test in the dashboard |
| `cloud` | `{ endpoint: string; sessionToken: string }` | | A session your server created with a server key |
| `require` | `{ camera?, screenShare?, fullscreen?, singleDisplay?: boolean }` | all `true` | What must be true before and during the test |
| `clips` | `false | { frameSec?: number; windowSec?: number }` | on | The session video. Built only when something receives it: a key, `cloud` or `onClip` |
| `snapshots` | `false | { intervalSec?: number }` | every 10 s | Photos of the webcam and screen. `false` also turns the video off |
| `blockClipboard` | `boolean` | `true` | Block copy, cut, paste and right-click, and log each attempt |
| `consent` | `{ organisation?, retentionDays?, seenBy? }` | | Shown in the consent notice. Filled in for you with a key. Without one, set `retentionDays` to what your storage really does |
| `faceDetection` | `false | FaceDetectionOptions` | on | The on-device face-in-view check. See the README for hosting its files yourself |
| `ui` | `'default' | 'headless'` | `'default'` | `headless` renders nothing, so you can build your own screens |
| `theme` | `'light' | 'dark' | 'auto'` | `'auto'` | |
| `cameraTile` | `boolean` | setup only | The candidate's own camera preview |
| `strings` | `Partial>` | | Replace any text the candidate sees; keys are in `defaultStrings` |
| `settings` | `Partial` | built in | Timings and thresholds. With a server key, pass `settings` from the session response |
| `context` | `Record` | `{}` | Starting context carried by events and the recording |
| `onEvent` | `(event: ProctorEvent) => void` | | Called for every event |
| `onClip` | `(clip: Clip) => void` | | Called with each part of the session video |
| `onSnapshot` | `(snapshot: Snapshot) => void` | | Called with every photo |
### Methods
| Method | Returns | What it does |
| --- | --- | --- |
| `runChecks()` | `Promise` | Runs the system check and consent. Call it from a click handler |
| `start()` | `boolean` | Starts guarding and recording. `false` if the checks have not passed |
| `stop()` | `ProctorReport` | Stops, releases camera and screen, removes the interface |
| `setContext(patch)` | `void` | Merges values into the context carried by later events and the recording |
| `on(type, listener)` | `() => void` | Listens for one event type, or `'*'` for all. Returns an unsubscribe function |
| `activeMs()` | `number` | Time since `start()`, not counting pauses |
| `isBlocked()` | `boolean` | True while the system check or a pause is on screen |
| `pausedFor()` | `('fullscreen' | 'screen' | 'camera' | 'display')[]` | Why the test is paused right now |
| `retry(reason)` | `Promise` | Tries to fix one pause reason, for headless screens |
| `getReport()` | `ProctorReport` | The report so far, without stopping |
| `support()` | `{ ok: boolean; missing: string[] }` | Missing browser features, without asking for anything |
| `ready()` | `boolean` | True when every requirement is met and `start()` would succeed |
| `requestCamera()`, `prepareFaceDetection()`, `requestScreenShare()`, `giveConsent()` | | The separate steps, for headless screens |
| `sessionId` | `string | null` | The cloud session's ID once a page key has connected. With a server key it stays `null` in the page: your server already has it from [Create a session](#create-a-session) |
With the built-in screens, `runChecks()` resolves with `{ ok: true }` once every check has passed; a failed step stays on screen with a way to try again. With `ui: 'headless'` it resolves at the first requirement that fails with `{ ok: false, reason }`, where `reason` is `unsupported` (with `missing`), `extra_display`, `camera`, `face_detection`, `screen_share` or `consent`. What each means is under [Troubleshooting](#troubleshooting).
### Events
Every event has `type`, `at` (ISO time), `ms` (since `start()`), `severity` (`info`, `warn` or `high`), `context` (the question on screen and anything else you set) and sometimes `data`.
| Type | Severity | `data` |
| --- | --- | --- |
| `unsupported` | high | `missing` |
| `check_passed`, `check_failed` | info | `check`: `camera`, `face_detection`, `face_visible` or `screen_share` |
| `consent_given` | info | `retentionDays` |
| `started`, `stopped` | info | |
| `cloud_connected` | info | `sessionId` (page key only; with a server key your server has it) |
| `cloud_unavailable` | warn | `code`, `message`: why the page key was refused or the service could not be reached |
| `context_changed` | info | the values that changed |
| `paused`, `resumed` | info | `reason`; `pausedMs` on `resumed` |
| `fullscreen_exit` | warn | |
| `screen_share_stopped`, `camera_lost` | high | |
| `screen_share_resumed`, `camera_restored` | info | |
| `no_face` | warn | `seconds` without a face |
| `face_returned` | info | `awayMs` |
| `screen_surface_unverified` | warn | |
| `virtual_camera` | high | `label` |
| `virtual_machine` | warn | `renderer`; once, at `start()`. From SDK 0.2.6 |
| `extra_display` | warn before the test, high during | `phase` |
| `focus_lost` | warn | `sinceQuestionMs` |
| `focus_returned` | info, or warn after 5 s away | `awayMs` |
| `page_closed` | warn | the tab was closed, reloaded or left while the test ran |
| `pointer_left_page` | info | `awayMs` |
| `copy_blocked`, `cut_blocked`, `paste_blocked`, `contextmenu_blocked` | info | `target` |
| `clip` | info | `kind`, `startMs`, `endMs`, `frames`, `bytes` (the video goes to `onClip`) |
| `clip_upload_failed` | warn | `kind`, `startMs`; the photos still cover that stretch |
| `snapshot` | info | `kind`, `reason`, `bytes` |
| `snapshot_upload_failed` | warn | |
### TypeScript
The package ships its declarations. These are exported:
```ts
import {
createProctor,
Proctor,
defaultSettings,
defaultStrings,
clipFrames,
} from 'proctorkit';
import type {
ProctorConfig,
ProctorEvent,
ProctorEventType,
Severity,
ProctorContext,
ProctorSettings,
Snapshot,
Clip,
Candidate,
TestInfo,
CheckResult,
ProctorReport,
ConsentInfo,
FaceDetectionOptions,
} from 'proctorkit';
```
The shapes you will use most:
```ts
interface ProctorEvent {
type: ProctorEventType;
at: string; // ISO time
ms: number; // since start(); 0 before the test starts
severity: 'info' | 'warn' | 'high';
// e.g. { questionId: 'Q07' }
context: Record;
data?: Record;
}
interface Clip {
kind: 'webcam' | 'screen';
startMs: number; // since start()
endMs: number;
frames: number;
// clipFrames(new Uint8Array(await mp4.arrayBuffer())) gives the pictures
mp4: Blob;
context: Record;
}
interface Snapshot {
kind: 'webcam' | 'screen';
// JPEG; webcam up to 600 px, screen up to 1200 px on the longer side
dataUrl: string;
// regular cadence, or taken because something happened
reason: 'interval' | 'event';
at: string;
ms: number;
context: Record;
}
interface CheckResult {
ok: boolean;
reason?:
| 'unsupported'
| 'extra_display'
| 'camera'
| 'face_detection'
| 'screen_share'
| 'consent'
| 'cancelled';
missing?: string[]; // when reason is 'unsupported'
}
interface ProctorReport {
startedAt: string | null;
endedAt: string | null;
durationMs: number;
pausedMs: number; // time behind the pause screen
awayMs: number; // time the test page was out of focus
context: Record;
counts: Partial>;
events: ProctorEvent[];
}
```
## Common mistakes
- Putting a server key (`pk_live_`) in browser code. Create sessions on your server; only the page key (`pk_pub_`) belongs in a page.
- Creating the proctor before you know who the candidate is. With a key, `candidate.id` and `candidate.name` are required.
- Calling `runChecks()` outside a click handler. Browsers allow screen sharing and full screen only after a click.
- Showing questions before `start()` returns `true`.
- Never calling `setContext({ questionId })`, so the report cannot point at questions.
- Changing the `endpoint` from the session response. Pass it to the page as it is.
- Testing on a phone, or on `http://` other than `localhost`: the camera and screen sharing are not available there.
- Adding a separate timer that keeps running during a pause. Use `activeMs()`.
## Troubleshooting
**What the candidate sees, and what it means.** The built-in system check keeps the candidate on the step that failed, with the message below and a way to try again. With `ui: 'headless'`, `runChecks()` resolves with `{ ok: false, reason }` instead, and your screen shows the message.
| The candidate sees | `reason` (headless) | Usually |
|---|---|---|
| "Camera access was denied." | `camera` | They clicked Block, or the browser or operating system blocks the camera for this site. |
| "Part of the camera check didn't download." (before 0.2.5: "The camera check could not be loaded.") | `face_detection` | The on-device face check's files could not be fetched: a slow or filtered network, or a Content Security Policy that blocks them (allowed sources are in the [Next.js guide](/docs/nextjs/)). Not a camera problem. |
| "We could not see your face." | `face_detection` | The camera works but no face was found: poor light, or sitting out of frame. |
| "Screen sharing was cancelled." or "That shared a window or tab." | `screen_share` | They cancelled, or chose a window or tab instead of the entire screen. |
| "A second screen is connected." | `extra_display` | A second monitor is attached. |
| "This test needs a desktop browser…" | `unsupported` | A phone, or a browser without camera or screen sharing; `missing` lists what is absent. |
**"The camera check could not be loaded" on a good connection (SDK before 0.2.2).** Some bundlers rewrote the SDK's on-demand import of the face check. Update to 0.2.2 or later: `npm install proctorkit@latest`.
**Every webhook gets `400` from your server.** Almost always the signature is computed on a re-serialised body. Read the raw text before parsing, as in [Webhooks](#webhooks). **Send a test event** on the Account page shows your server's answer, and **Copy exact body** gives the bytes we sent.
**`proctor.sessionId` is `null`.** Expected with a server key: the ID is in your server's [Create a session](#create-a-session) response. With a page key it is set once `cloud_connected` fires.
**The camera asks twice, or two camera tiles appear.** More than one proctor was created: in React, create it in `useState(() => createProctor(...))` in a component that mounts once per attempt, as in [With a server key](#with-a-server-key).
**`cloud_unavailable` fires.** The key was refused or the service could not be reached; the event's data says which, and the console logs it. The test keeps running with the on-device checks.
**What changed in a release.** See the [changelog](https://github.com/aproli90/proctorkit/blob/main/CHANGELOG.md) or the [releases page](https://github.com/aproli90/proctorkit/releases).
## What is flagged, and what is not
| From the browser | From AI review |
| --- | --- |
| Leaving the test window, and for how long; leaving full screen; stopping the screen share; camera off or covered; a software camera; a second display; no face in view; paste, copy and right-click attempts; a virtual machine (SDK 0.2.6) | Another person close to the candidate; someone else in the room for a while; a phone in use; the candidate out of view; another app or window on screen; the test window hidden |
### What it can't see
It sees only what the camera and the shared screen show, records no sound, and does not check identity. So these can get through:
- A phone or notes kept fully out of the camera's view
- Tools built to hide from screen sharing, such as invisible overlays
- Someone helping by voice, off camera
- A virtual machine set up to hide that it is one
It's built to catch everyday cheating and make it easy to spot, not to stop people set on beating it. Telling candidates the rules up front also discourages casual cheating.
## For your coding agent
Paste this into Claude Code, Cursor or the tool that built your quiz. Your dashboard gives you the same prompt with your key already in it.
```text
Add ProctorKit proctoring to this quiz. Read https://proctorkit.com/llms-full.txt first.
Page key (it goes in the page; it only works on your website): PASTE_YOUR_pk_pub_KEY
1. npm install proctorkit. Create one proctor per attempt (in React, inside useState(() => ...) so a re-render does not make a new one): createProctor({ key, candidate: { id, name, email }, test: { id, name } }). candidate.id and candidate.name are required.
2. When the candidate clicks Start, await proctor.runChecks(); show the quiz only if .ok and proctor.start() returns true.
3. Call proctor.setContext({ questionId }) whenever the visible question changes.
4. Call proctor.stop() when the test is submitted.
Do not add a timer, and change nothing else.
```
## More
The SDK's source, its README with every setting, and the issue tracker are on [GitHub](https://github.com/aproli90/proctorkit).
---
# Add proctoring to a plain HTML quiz
No build step, no framework: one script tag and a few lines of JavaScript. This works for a hand-written quiz page, a WordPress or Webflow page where you can add custom code, or any tool that lets you add a script to the page the candidate takes the test on.
## 1. Get a page key
[Create an account](/app/?new), choose **Record** or **Record + AI review**, and add the website your quiz runs on. You get a key that starts with `pk_pub_`. It is safe in the page: it works only on the websites you list, and on `localhost`.
## 2. Add the script and wire it to your page
```html
Start test
```
That is the whole integration. Open the page over HTTPS (or `localhost`) in desktop Chrome or Edge to try it.
## 3. See the results
Each candidate appears in your [dashboard](/app/) under their test, with the recording and flags laid out by question.
## Good to know
- **Pin the version** in production: `https://cdn.jsdelivr.net/npm/proctorkit@0.2.0/dist/proctorkit.global.js`.
- **Countdown:** use `proctor.activeMs()`, which leaves out paused time.
- **No account:** leave out `key` and pass `onEvent`, `onClip` and `onSnapshot` to keep everything yourself; see [the docs](/docs/#on-its-own-without-an-account).
- **Hosted form builders** (Google Forms, Microsoft Forms, Typeform) do not let you add scripts to the form, so ProctorKit cannot run inside them. Put the questions on a page you control instead.
Next: the [React](/docs/react/) and [Next.js](/docs/nextjs/) guides, or [the full docs](/docs/).
---
# Add proctoring to a Next.js quiz
This guide adds ProctorKit to a quiz built with Next.js and the App Router. The proctor runs in a client component. For paid use you add one route handler that creates each candidate's session with your secret server key. ProctorKit can be imported and created during server rendering; its methods only run in the browser after the candidate clicks Start.
## 1. Install
```bash
npm install proctorkit
```
## 2. Quickest start: a page key
[Create an account](/app/?new), choose **Record** or **Record + AI review**, add your site's domain, and copy the `pk_pub_` key into `.env.local`:
```bash
NEXT_PUBLIC_PROCTORKIT_KEY=pk_pub_...
```
```tsx
// app/test/quiz.tsx
'use client';
import { useEffect, useState } from 'react';
import { createProctor } from 'proctorkit';
export default function Quiz({
user,
questions,
}: {
user: { id: string; name: string; email?: string };
questions: { id: string; text: string }[];
}) {
// once per attempt; the dashboard shows the candidate by name
const [proctor] = useState(() =>
createProctor({
key: process.env.NEXT_PUBLIC_PROCTORKIT_KEY,
candidate: user,
test: { id: 'round-1', name: 'Screening round 1' },
}),
);
const [started, setStarted] = useState(false);
const [i, setI] = useState(0);
const begin = async () => {
const check = await proctor.runChecks(); // system check and consent
if (check.ok && proctor.start()) setStarted(true);
};
useEffect(() => {
if (started) proctor.setContext({ questionId: questions[i].id });
}, [started, i]);
const submit = () => {
proctor.stop(); // then save the answers
};
if (!started) return Start test ;
return {/* render questions[i]; call submit() at the end */}
;
}
```
Render ` ` from any page. Results appear in your [dashboard](/app/).
## 3. For paid use: create sessions on the server
A server key (`pk_live_`) is secret, so it stays in a route handler. The page asks your route for a session and passes the short-lived token to the proctor.
```bash
# .env.local (never NEXT_PUBLIC_)
PROCTORKIT_API_KEY=pk_live_...
```
```ts
// app/api/proctor-session/route.ts
import { NextResponse } from 'next/server';
export async function POST(req: Request) {
// your own auth: { id, name, email }
const user = await currentUser();
const r = await fetch('https://proctorkit.com/api/v1/sessions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PROCTORKIT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
candidate: { id: user.id, name: user.name, email: user.email },
test: { id: 'round-1', name: 'Screening round 1' },
}),
});
const s = await r.json();
if (!r.ok) return NextResponse.json({ error: s.error }, { status: 502 });
// keep s.sessionId and s.reportUrl on your side (database), never in the page
return NextResponse.json({
endpoint: s.endpoint,
sessionToken: s.sessionToken,
settings: s.settings,
organisation: s.organisation,
retentionDays: s.retentionDays,
});
}
```
```tsx
// in the client component, instead of the page key
const s = await fetch('/api/proctor-session', { method: 'POST' }).then((r) =>
r.json(),
);
const proctor = createProctor({
cloud: { endpoint: s.endpoint, sessionToken: s.sessionToken },
settings: s.settings,
consent: { organisation: s.organisation, retentionDays: s.retentionDays },
});
```
Create this proctor once per attempt, after the session response arrives: fetch the session in a parent component and mount the quiz only when it is there, so `useState(() => createProctor(...))` runs exactly once (example in [the docs](/docs/#with-a-server-key)). `proctor.sessionId` stays `null` here; your server kept the ID. Everything else (`runChecks()`, `start()`, `setContext()`, `stop()`) is the same. Pass `endpoint` to the page exactly as you received it. Read the result later with `GET /v1/sessions/{sessionId}`, or set a [webhook](/docs/#webhooks) to be told when it is ready.
## Good to know
- **Countdown:** use `proctor.activeMs()`, which leaves out time the test was paused.
- **Content Security Policy:** if you set one, allow `connect-src https://proctorkit.com`. The on-device face check also loads code from `https://cdn.jsdelivr.net` (`script-src` and `connect-src`, plus `'wasm-unsafe-eval'`) and a model from `https://storage.googleapis.com` (`connect-src`), unless you [host those files yourself](https://github.com/aproli90/proctorkit#face-detection).
- **Permissions-Policy:** if you send this header, allow `camera` and `display-capture` for your own origin.
- **Browsers:** desktop Chrome or Edge for the full set of checks. Others get a clear `unsupported` result.
See the [React guide](/docs/react/) for a timer example, and [the full docs](/docs/) for every option, event and response.
---
# Add proctoring to a React quiz
This guide adds ProctorKit to a React quiz you already have (Vite, Create React App or any other setup). The ProctorKit part is 5 lines; the rest is the React wiring you already have. Candidates get a system check and a consent screen, the test runs in full screen with the entire screen shared and the camera on, and the recording and every event are tied to the question on screen. For Next.js, see the [Next.js guide](/docs/nextjs/).
## 1. Install
```bash
npm install proctorkit
```
## 2. Get a page key
[Create an account](/app/?new), choose **Record** or **Record + AI review**, and add the website your quiz runs on. You get a key that starts with `pk_pub_`. It is safe in the page: it works only on the websites you list (and on `localhost` while you build). Without a key, ProctorKit still runs and hands everything to your own code instead; see [the docs](/docs/#on-its-own-without-an-account).
## 3. Create one proctor per candidate
```tsx
// proctor.ts
import { createProctor } from 'proctorkit';
// who is taking the test: the dashboard shows them by name
export const makeProctor = (user: {
id: string;
name: string;
email?: string;
}) =>
createProctor({
key: import.meta.env.VITE_PROCTORKIT_KEY,
candidate: user,
test: { id: 'round-1', name: 'Screening round 1' },
});
```
`candidate.id` and `candidate.name` are required with a key; `test` is optional and groups candidates in the dashboard.
## 4. Start it from your Start button
```tsx
import { useEffect, useState } from 'react';
import { makeProctor } from './proctor';
export function Quiz({
user,
questions,
}: {
user: { id: string; name: string; email?: string };
questions: { id: string; text: string }[];
}) {
// once per attempt, stable across re-renders
const [proctor] = useState(() => makeProctor(user));
const [started, setStarted] = useState(false);
const [problem, setProblem] = useState(null);
const [i, setI] = useState(0);
const begin = async () => {
// shows the system check and consent
const check = await proctor.runChecks();
if (check.ok && proctor.start()) setStarted(true);
// e.g. 'unsupported', 'camera', 'screen_share', 'cancelled'
else setProblem(check.reason ?? 'not ready');
};
useEffect(() => {
// every event now carries this question
if (started) proctor.setContext({ questionId: questions[i].id });
}, [started, i]);
const submit = () => {
// releases camera and screen
proctor.stop();
// ...save the answers as you do today
};
if (!started) return Start test ;
return (
setI(i + 1)}
onSubmit={submit}
/>
);
}
```
`runChecks()` must run from a click, because browsers only allow screen sharing and full screen after one.
## 5. A timer that stops during pauses
When the candidate leaves full screen or stops sharing, ProctorKit pauses the test until they fix it. Base your countdown on `activeMs()`, which leaves out paused time:
```tsx
import type { Proctor } from 'proctorkit';
// in Quiz: const left = useTimeLeft(proctor, 30 * 60_000, started, submit);
function useTimeLeft(
proctor: Proctor,
limitMs: number,
running: boolean,
onEnd: () => void,
) {
const [left, setLeft] = useState(limitMs);
useEffect(() => {
if (!running) return;
const t = setInterval(() => {
const l = limitMs - proctor.activeMs();
setLeft(l);
if (l <= 0) {
clearInterval(t);
onEnd();
}
}, 500);
return () => clearInterval(t);
}, [running]);
return left;
}
```
## 6. See the results
Each candidate appears in your [dashboard](/app/) under their test, with the recording and flags laid out by question. With AI review on, sessions are ranked by review priority so you look at the riskiest first.
## Good to know
- **If the key is refused** (wrong website, switched off, daily limit), the test still runs with the on-device checks. Listen for it: `proctor.on('cloud_unavailable', (e) => console.warn(e.data))`.
- **Desktop Chrome or Edge** gives the full set of checks. Other browsers get `check.reason === 'unsupported'` straight away, never a broken test.
- **HTTPS** is required in production; `localhost` works while you build.
- **TypeScript** types ship with the package.
- **Paid use at volume:** create sessions on your server with a server key instead; see [With a server key](/docs/#with-a-server-key).
[Try the demo](/demo/) to see what candidates see, then read [the full docs](/docs/) for every option and event.
---
# ProctorKit browser SDK README
**Proctoring for the quiz you already built.**
[](https://www.npmjs.com/package/proctorkit) [](#typescript) [](https://bundlephobia.com/package/proctorkit) [](LICENSE)
One small browser library turns any web test into a proctored one: a system check, consent, full screen, entire-screen sharing, camera and face checks, a video of the webcam and the screen for the whole test, photos every 10 seconds, and an event log tied to each question. It pauses the test when something breaks and helps the candidate fix it. Free, MIT licensed, written in TypeScript, no dependencies, about 13 kB gzipped.
```js
import { createProctor } from 'proctorkit';
const proctor = createProctor({
key: 'pk_pub_...',
candidate: { id: 'c-1042', name: 'Asha Rao' },
test: { id: 'sales-1', name: 'Sales screening' },
});
if ((await proctor.runChecks()).ok) proctor.start(); // on the Start button
// whenever the question changes
proctor.setContext({ questionId: 'Q1' });
// on submit: returns the session report
proctor.stop();
```
The key comes free from [proctorkit.com](https://proctorkit.com), which stores the recording and gives each candidate a report. No account? Leave out `key` and `candidate`, and keep everything yourself with `onEvent`, `onClip` and `onSnapshot` (see the [quick start](#quick-start)).
## Why teams use it
- **Keep your test.** It works on any web page you control: React, Vue, Svelte, Angular, a plain HTML form or a tool you built. Your questions, answers and scoring never pass through ProctorKit.
- **A ready interface, or none.** The built-in screens handle the system check, consent and pauses, with light and dark themes and every word replaceable. Or go headless and drive your own screens from events.
- **Fair to candidates.** Plain consent before anything is recorded, a pause screen with one button to fix each problem, and a timer that stops while the test is paused.
- **Evidence you can watch.** A video of the whole test, plus regular photos, so a reviewer sees what actually happened. Every clip, photo and event carries the question on screen at that moment.
- **Hard to get wrong.** It checks browser support up front, never hangs, and keeps the test running if an upload fails.
- **Private by default.** Nothing is captured before `runChecks()`, and nothing leaves the page except through your own handlers, or to ProctorKit Cloud when you pass a key.
## Everything in the free SDK
| Before the test | During the test | After the test |
| --- | --- | --- |
| Browser support check, with what is missing | Pauses on leaving full screen, stopping the share, losing the camera or adding a display, and resumes when fixed | A session report: duration, paused time, time away, counts per event type |
| Camera, with a preview for framing | Time away from the test window, per question | The full event log, each event with its question |
| Face in view, checked on the candidate's device | Prompts the candidate back into view | The video, photos and screenshots, tagged with their question |
| Entire-screen share required, window and tab shares refused | Copy, cut, paste and right-click blocked and logged | |
| Single display required (Chromium) | A video of the webcam and the screen, the whole way through | |
| Consent: what is recorded, why, for how long, who sees it | A photo and screenshot about every 10 seconds, plus extra ones when something happens | |
| | Pointer leaving the page | |
Plus, for developers: TypeScript types, ES module and script-tag builds, a headless mode, themes, replaceable text, every timing in one settings object, and `activeMs()` for a countdown that never counts a pause.
## Free SDK or ProctorKit Cloud
The SDK gives you the signals; what you do with them is up to you. [ProctorKit Cloud](https://proctorkit.com) is the optional hosted service for teams that would rather not build storage, review screens and checks themselves. Switching is one line: pass a key.
| | Free SDK | ProctorKit Cloud |
| --- | --- | --- |
| Everything in the table above | Yes | Yes |
| Where the video, photos and events go | Your handlers and your storage | Stored for you, deleted on schedule |
| A report per candidate, with the recording laid out by question | Build your own | Yes, with a private link for each reviewer |
| Results sent to your server when a session ends or its review is done | | Webhooks and a REST API |
| Your team: invite reviewers, one account per client, share a report by link | | Yes |
| Dashboard for your team, keys locked to your domains | | Yes |
| AI reviews each session and marks the moments worth a look: a phone in use, another person, another app on screen, the test hidden | | With AI review |
| Review priority from 0 to 100, so the riskiest sessions come first | | With AI review |
| Price | Free, forever | Recording only: free during launch. AI review: $0.25 per candidate session\* (₹15 in India), first 50 free |
```js
// the same proctor, now reporting to your dashboard
const proctor = createProctor({
key: 'pk_pub_...',
candidate: { id: user.id, name: user.name },
test: { id: 'sales-1', name: 'Sales screening' },
});
```
[Create a key](https://proctorkit.com/app/?new), [try the demo](https://proctorkit.com/demo/) (try to cheat; you get the report), or read the [docs](https://proctorkit.com/docs/) for the REST API.
\* One candidate session is one person taking one test of up to 30 minutes. Longer tests count by the minute: 45 minutes is 1.5 sessions. Tests that never start are not counted. Customers in India pay in rupees.
## Install
```bash
npm install proctorkit
```
or with a script tag (global `ProctorKit`):
```html
```
## Quick start
React, with a page key from the [ProctorKit dashboard](https://proctorkit.com/app/?new) (results and reports in the dashboard). A page key needs to know who is taking the test: `candidate.id` and `candidate.name` are required, `email` is optional. Add `test: { id, name }` to group candidates by test; without it they are grouped under the key's name.
```jsx
import { useEffect, useState } from 'react';
import { createProctor } from 'proctorkit';
export function Quiz({ user, questions }) {
// once per candidate: the dashboard and report show this person by name
const [proctor] = useState(() =>
createProctor({
key: 'pk_pub_...',
candidate: { id: user.id, name: user.name, email: user.email },
test: { id: 'sales-1', name: 'Sales screening' },
}),
);
const [started, setStarted] = useState(false);
const [i, setI] = useState(0);
const begin = async () => {
// the Start button
if ((await proctor.runChecks()).ok && proctor.start()) setStarted(true);
};
useEffect(() => {
if (started) proctor.setContext({ questionId: questions[i].id });
}, [started, i]);
const submit = () => {
proctor.stop(); // then save answers as before
};
// ...render the quiz once started
}
```
Without an account (free, nothing leaves the page except through your handlers): leave out `key` and take the events and the video yourself.
```js
const proctor = createProctor({
consent: { organisation: 'Acme Hiring', retentionDays: 90 },
onEvent: (event) => sendToYourServer(event),
// a half-minute stretch of the session video, webcam or screen
onClip: (clip) => uploadToYourStorage(clip.mp4),
// optional: a photo about every 10 s as well
onSnapshot: (snapshot) => uploadToYourStorage(snapshot.dataUrl),
});
// runChecks(), start(), setContext() and stop() work the same way
```
Plain HTML, no build step:
```html
```
A complete page is in [`examples/basic.html`](examples/basic.html).
## Feature details
| Capability | Default | Notes |
| --- | --- | --- |
| Browser support check | on | Returns `{ ok: false, reason: 'unsupported', missing }` at once; never hangs |
| Camera required | on | Pauses if the camera stops; the candidate can turn it back on |
| Entire-screen share required | on | Rejects a window or tab share; pauses if sharing stops |
| Full screen required | on | Pauses on exit; one button returns |
| Single display required | on | Checked before and during the test (Chromium; ignored elsewhere) |
| Consent notice | on | States what is recorded, why, for how long, and who sees it |
| Copy, cut, paste, context menu blocked | on | Each attempt is logged |
| Time away from the test window | on | `focus_lost` and `focus_returned` with `awayMs` |
| Per-question behaviour | on | Time since the question appeared on each focus loss; the pointer leaving the page |
| Face in view, checked on the candidate's device | on | The test cannot start until the detector has loaded and a face is in view. During the test it asks the candidate to move back into view and reports `no_face`. It never reports other people. No frame leaves the page for it |
| Camera preview | setup only | Shown while the candidate sets up, hidden during the test |
| Session video | on when something receives it | A video of the webcam and of the screen, delivered as one MP4 per half minute to `onClip` or ProctorKit Cloud. Built from a picture about every 2 seconds (the moment varies by up to a second). Off without `onClip`, a key or `cloud`, so nothing is built that nobody receives |
| Webcam and screen photos | about every 10 s | JPEG data URLs to `onSnapshot`; the exact moment varies by a few seconds; extra photos when something happens |
| Question tagging | `setContext()` | Every event and frame carries the context at that moment |
| Session report | `stop()` | Totals, counts per event type, full event list |
Everything above runs in the browser, including building the video: no server-side processing is needed. The video, photos and events go only to your own handlers unless you pass a key or configure `cloud`.
## What it cannot do
Browser proctoring deters cheating and gives a reviewer evidence. It does not stop a determined cheat, and you should not present it as if it does.
- It sees only what the camera and the shared screen show, and it records no sound.
- It does not check who the candidate is.
- Everything runs on a page the candidate controls. Treat a clean log as "nothing was observed", not as proof.
- Phones and tablets cannot share their screen from the browser, so the default setup needs a desktop browser. Chrome and Edge give the fullest checks.
## Configuration
```ts
createProctor({
require: {
camera: true,
screenShare: true,
fullscreen: true,
singleDisplay: true,
},
snapshots: { intervalSec: 10 }, // or false (also turns the video off)
// the session video; or false for photos only
clips: { frameSec: 2, windowSec: 30 },
blockClipboard: true,
consent: { organisation, retentionDays: 90, seenBy },
ui: 'default', // or 'headless'
theme: 'auto', // 'light' | 'dark' | 'auto'
// setup preview only; true keeps it in the test, false hides it
cameraTile: undefined,
faceDetection: {}, // or false; see below
settings: {}, // timings and thresholds; see below
// replace any text; see defaultStrings
strings: { pausedTitle: 'Test paused' },
context: {},
onEvent,
onClip,
onSnapshot,
// optional: a page key from the ProctorKit dashboard
key: 'pk_pub_...',
// required with a page key: who is taking the test
candidate: { id, name, email },
// names the test in the dashboard; one key can serve many tests
test: { id, name },
// optional: a session your server created with a server key
cloud: { endpoint, sessionToken },
// where ProctorKit Cloud lives; leave unset
apiBase: undefined,
});
```
Lightest setup, with no camera or screen share:
```js
createProctor({
require: { camera: false, screenShare: false },
snapshots: false,
});
```
### Settings
Every timing and threshold is in one object, `defaultSettings`. Pass only what you want to change:
| Setting | Default | Meaning |
| --- | --- | --- |
| `snapshotIntervalSec` | 10 | Seconds between regular frames |
| `snapshotJitterSec` | 3 | Each frame is taken up to this many seconds early or late |
| `clipFrameSec` | 2 | Seconds between the pictures that make up the video |
| `clipJitterSec` | 1 | Each video picture is taken up to this many seconds early or late |
| `clipWindowSec` | 30 | Seconds of the session in each clip |
| `hideCameraAfterSetup` | true | Show the camera preview during the system check only |
| `faceSetupWaitSec` | 12 | During setup, how long to wait for a face before asking the candidate to adjust |
| `absencePromptSec` | 4 | No face for this long: ask the candidate to move back into view |
| `absenceReportSec` | 10 | Still no face after this long: report `no_face` (moving back sooner is only a reminder) |
| `coverReportSec` | 3 | No face and a featureless picture, dark or red-lit (lens covered, or a very dark room), for this long: report `camera_blocked` |
| `faceCheckIntervalSec` | 2 | Seconds between face checks |
| `multipleFacesChecks` | 2 | Consecutive checks with two or more faces before an extra frame is taken |
| `minFocusLossMs` | 800 | Shorter focus losses are ignored |
| `longFocusLossSec` | 5 | A longer focus loss is `warn`, a shorter one `info` |
| `pointerAwayMinMs` | 1500 | The pointer must be off the page this long to be reported |
| `virtualCameraNames` | `['obs', 'virtual', …]` | Lower-case fragments of camera names that mean a software camera |
| `virtualMachineNames` | `['vmware', 'virtualbox', …]` | Lower-case fragments of the graphics renderer's name that mean the browser runs inside a virtual machine |
With a ProctorKit backend, pass the `settings` object from the create-session response as it is.
### Face detection
Face detection uses [MediaPipe](https://ai.google.dev/edge/mediapipe/solutions/vision/face_detector) and runs in the candidate's browser. Its runtime and model (about 4.5 MB compressed, cached by the browser afterwards) are fetched during the camera step, by default from jsDelivr and Google's model storage.
While it is on, it is a prerequisite: the camera step passes only when the detector has loaded and the candidate's face is in view, and `start()` returns `false` until then. If the files cannot be loaded the candidate is told to check their connection and try again. Headless hosts call `prepareFaceDetection()` after `requestCamera()`; `runChecks()` returns `reason: 'face_detection'` when it fails.
It only answers "is the candidate's face in view". When it sees a second face it takes an extra frame and reports nothing, so that judging who else is present is left to whatever checks the frames afterwards.
```js
// off
createProctor({ faceDetection: false });
// host the files yourself
createProctor({ faceDetection: { moduleUrl, wasmUrl, modelUrl } });
createProctor({ faceDetection: { detect: (video) => myOwnFaceCount(video) } });
```
It finds faces, not people: a candidate looking down at the keyboard can read as no face, which is why the prompt waits ten seconds. It sees faces up to about two metres away.
Call `setContext({ questionId })` whenever the question changes. The per-question signals depend on it.
## API
| Method | Returns | What it does |
| --- | --- | --- |
| `runChecks()` | `Promise` | Runs the system check and consent. Call from a click handler |
| `start()` | `boolean` | Starts guarding and recording. `false` if the checks have not passed |
| `stop()` | `ProctorReport` | Stops, releases camera and screen, removes the interface |
| `setContext(patch)` | `void` | Merges values into the context on later events and frames |
| `on(type, fn)` | `() => void` | Listens for one event type or `'*'`; returns an unsubscribe function |
| `isBlocked()` | `boolean` | True while the system check or a pause overlay is up |
| `pausedFor()` | `string[]` | Current pause reasons: `fullscreen`, `screen`, `camera`, `display` |
| `activeMs()` | `number` | Time since `start()` minus all pauses. Use it for your countdown |
| `retry(reason)` | `Promise` | Tries to fix one pause reason (for headless hosts) |
| `getReport()` | `ProctorReport` | The report so far, without stopping |
| `support()` | `{ ok, missing }` | Missing browser features, without prompting |
| `ready()` | `boolean` | True when every requirement is met and `start()` would succeed |
| `requestCamera()`, `prepareFaceDetection()`, `requestScreenShare()`, `giveConsent()` | | The individual steps, for headless hosts |
| `sessionId` | `string \| null` | The ProctorKit Cloud session's ID once a page key has connected. With a server key it stays `null` in the page: your server already has it from the create-session response |
## TypeScript
The package ships its declarations; nothing extra to install. Exported types:
```ts
import {
createProctor,
Proctor,
defaultSettings,
defaultStrings,
} from 'proctorkit';
import type {
ProctorConfig,
ProctorEvent,
ProctorEventType,
Severity,
ProctorContext,
ProctorSettings,
Snapshot,
Clip,
Candidate,
TestInfo,
CheckResult,
ProctorReport,
ConsentInfo,
FaceDetectionOptions,
} from 'proctorkit';
// clipFrames(mp4Bytes) gives back the JPEG pictures of a clip
import { clipFrames } from 'proctorkit';
```
`ProctorEvent` is `{ type, at, ms, severity, context, data? }`; `Snapshot` is `{ kind: 'webcam' | 'screen', dataUrl, reason: 'interval' | 'event', at, ms, context }`; `Clip` is `{ kind, startMs, endMs, frames, mp4, context }`, where `mp4` is a Blob that plays in any player that reads Motion JPEG; `CheckResult` is `{ ok, reason?, missing? }`; `ProctorReport` is `{ startedAt, endedAt, durationMs, pausedMs, awayMs, context, counts, events }`. Hover them in your editor for every field.
## Pauses and your timer
ProctorKit pauses the test by itself when the candidate leaves full screen, stops sharing the screen, loses the camera or plugs in a second display, and resumes it when the problem is fixed. It has no timer of its own; your page keeps the clock. Two ways to stay in step:
```js
// 1. Let ProctorKit do the arithmetic: the time used never includes a pause.
const LIMIT_MS = 30 * 60 * 1000;
setInterval(() => {
const left = LIMIT_MS - proctor.activeMs();
showCountdown(left);
if (left <= 0) submitTest();
}, 500);
// 2. Or listen, and stop and start your own timer.
// e.data.reason: fullscreen | screen | camera | display
proctor.on('paused', (e) => {
myTimer.stop();
});
// e.data.pausedMs: how long this pause lasted
proctor.on('resumed', (e) => {
myTimer.start();
});
```
`paused` can fire more than once while the test is already paused, once per reason; `resumed` fires once, when every reason is cleared. `isBlocked()` is true for the whole time.
## Events
Every event has `type`, `at` (ISO time), `ms` (since `start()`), `severity` (`info`, `warn`, `high`), `context` and optional `data`.
| Type | Severity | Data |
| --- | --- | --- |
| `unsupported` | high | `missing` |
| `check_passed`, `check_failed` | info | `check` (`camera`, `face_detection`, `face_visible`, `screen_share`), `error` or `surface` |
| `consent_given` | info | `retentionDays` |
| `started`, `stopped` | info | |
| `cloud_connected` | info | `sessionId` (page key only; with a server key your server has it) |
| `cloud_unavailable` | warn | `code` and `message`: the page key was refused (`key_invalid`, `key_off`, `domain_not_allowed`, `daily_cap`, `candidate_required`) or the service (`unavailable`) could not be reached. The test carries on with the on-device checks |
| `context_changed` | info | the values that changed |
| `paused`, `resumed` | info | `reason`, `pausedMs` |
| `fullscreen_exit` | warn | |
| `screen_share_stopped`, `camera_lost` | high | |
| `screen_share_resumed`, `camera_restored` | info | |
| `no_face` | warn | `seconds` with no face; the candidate is prompted |
| `camera_blocked` | high | `seconds`: no face and a dark, featureless picture, as when the lens is covered (or the room is very dark); the candidate is prompted. Reported instead of `no_face` |
| `camera_uncovered` | info | `coveredMs`: the picture came back |
| `face_returned` | info | `awayMs` |
| `screen_surface_unverified` | warn | the browser did not report what was shared |
| `extra_display` | warn before the test, high during | `phase` |
| `virtual_camera` | high | `label`: the camera's name says it is software (OBS, ManyCam and the like), which can replay a recording |
| `virtual_machine` | warn | `renderer`: the browser draws with a virtual machine's graphics card (VMware, VirtualBox, Parallels, QEMU), so anything open on the real computer is out of sight. Reported once, at `start()`. A machine set up to hide this is not caught |
| `focus_lost` | warn | `sinceQuestionMs` |
| `focus_returned` | info, or warn after 5 s away | `awayMs` |
| `pointer_left_page` | info | `awayMs` |
| `page_closed` | warn | the tab was closed, reloaded or left while the test ran |
| `copy_blocked`, `cut_blocked`, `paste_blocked`, `contextmenu_blocked` | info | `target` |
| `snapshot` | info | `kind`, `reason`, `bytes` (the image goes to `onSnapshot`) |
| `snapshot_upload_failed` | warn | |
| `clip` | info | `kind`, `startMs`, `endMs`, `frames`, `bytes` (the video goes to `onClip`) |
| `clip_upload_failed` | warn | `kind`, `startMs`; the photos still cover that stretch |
Severity describes how much attention an event deserves, not guilt. Do not fail a candidate automatically on any of them.
## Headless mode
Set `ui: 'headless'` to render your own screens. `runChecks()` then tries each requirement once and returns the first that fails (`camera`, `screen_share`, `consent`, `extra_display`). Call `giveConsent()` when the candidate agrees, listen for `paused`, and call `retry(reason)` from your own button.
## Sending data to a backend
`cloud` posts to three routes on `endpoint`:
- `POST {endpoint}/clip?kind&startMs&endMs&frames&context` with the MP4 as the body (`Content-Type: video/mp4`) and the token in the `X-PK-Token` header
- `POST {endpoint}/snapshot` with `{ token, kind, image, reason, at, ms, context, page }`, where `page` is the test page's title and host
- `POST {endpoint}/events` with `{ token, events }`
`sessionToken` must be a short-lived token your server issues for one session. Never put an API key in the page. Failed uploads are retried and then dropped with a `snapshot_upload_failed` or `clip_upload_failed` event; a backend outage never stops the test.
### ProctorKit Cloud (hosted, optional)
[ProctorKit Cloud](https://proctorkit.com) stores the video and gives you a dashboard, candidates grouped by test, and a private report link per candidate, laid out by question. Each key runs in one of two modes:
- **Recording only**: the session video, photos and browser flags, for you to look through. Free during launch; afterwards 100 candidate sessions a month stay free, then $0.10 per session (₹5 in India).
- **AI review**: AI reviews each session (a phone in use, another person close by, another app on screen), marks the moments worth a look so you can jump straight to them, and gives each session a 0 to 100 review priority: which candidates to look at first, not a test result. You can mark any session clear or a concern yourself. $0.25 per candidate session at launch price (list $0.40; ₹15 in India), first 50 free.
A candidate session is one person taking one test of up to 30 minutes; longer tests count by the minute (45 minutes is 1.5). If your quiz has its own backend, use your account's server key (one for all your tests; it never reaches the page). If it is only a web page, use a page key per test (`createProctor({ key, candidate })`, shown above). With a server key:
1. Your server creates a session with your server key: `POST https://proctorkit.com/api/v1/sessions` with `Authorization: Bearer pk_live_...` and `{ candidate: { id, name, email }, test: { id, name }, aiReview, metadata }` (`candidate.id` and `candidate.name` are required; `test` tells your tests apart; `aiReview` chooses AI review or Recording only for this session). The response has `sessionToken`, `endpoint`, `settings`, `organisation`, `retentionDays`, `sessionId` and `reportUrl`.
2. Pass `endpoint`, `sessionToken` and `settings` to the page:
```js
const proctor = createProctor({
cloud: { endpoint: s.endpoint, sessionToken: s.sessionToken },
settings: s.settings,
consent: { organisation: s.organisation, retentionDays: s.retentionDays },
});
```
3. Keep `reportUrl` on your server and give it to whoever reviews the candidate. Or read the result with `GET https://proctorkit.com/api/v1/sessions/{sessionId}`, list sessions with `GET /api/v1/sessions?candidateId=...`, download the recording with `GET /api/v1/sessions/{sessionId}/media`, or set your account's webhook (dashboard, **Account**) to be told when a session ends and when its review is done.
Every request and response, the flag types, limits and a prompt for coding agents are in the [docs](https://proctorkit.com/docs/). There is also a [demo you can try to cheat](https://proctorkit.com/demo/).
## Privacy
- Nothing is requested or recorded before `runChecks()`.
- Without a key you store the recording yourself, so the consent notice only states a retention period if you set `consent.retentionDays`; otherwise it points candidates to your privacy notice.
- When the session video is on, the consent notice says so in plain words: video of the webcam and the screen for the whole test.
- The consent notice appears before the test and states what is captured, why, for how long and who sees it. Set `consent` so it is accurate for you.
- With no `key` or `cloud` setting, ProctorKit sends nothing anywhere. You are responsible for what your handlers store.
- Face counting happens on the candidate's device. The only network requests it makes are to download the MediaPipe files; host them yourself or set `faceDetection: false` to avoid those.
- The camera preview is hidden during the test by default. The consent notice says the webcam is recorded for the whole test.
- You are responsible for meeting the privacy law that applies to you and your candidates.
## Troubleshooting
- **"Part of the camera check didn't download."** (`reason: 'face_detection'` in headless mode) The on-device face check's files could not be fetched: a slow or filtered network, or a Content Security Policy that blocks `cdn.jsdelivr.net` and `storage.googleapis.com`. It is not a camera problem. You can [host the files yourself](#face-detection).
- **"The camera check could not be loaded" on a good connection, before 0.2.2.** Some bundlers rewrote the SDK's on-demand import. Update: `npm install proctorkit@latest`.
- **Webhook signatures never match.** Sign the raw request body exactly as it arrived; parsing the JSON and stringifying it again changes the bytes. In Next.js read `await req.text()`, not `req.json()`.
- **`proctor.sessionId` is `null` with a server key.** Expected: your server has the ID from the create-session response.
- **The camera is requested twice.** More than one proctor was created. Create one per attempt, after the session (if any) has arrived; in React, `useState(() => createProctor(...))` in a component that mounts once.
Every message the candidate can see, with its `reason`: [proctorkit.com/docs#troubleshooting](https://proctorkit.com/docs/#troubleshooting). What changed in each version: [CHANGELOG.md](CHANGELOG.md).
## Development
```bash
npm install
npm run build # dist/: the ES module, the script-tag build and the types
npm test # headless Chromium, fake camera (PW_CHROME: a system browser)
```
Releases: a merge to `main` that changes `version` in `package.json` (with its `CHANGELOG.md` entry) stages that version on npm and creates its tag and GitHub release. A maintainer approves it on npmjs.com. No tags by hand.
## Licence
MIT