# 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 `