REST API Reference
The complete endpoint catalogue for the Lab Kiosk Cloudflare control plane, plus the client agent's loopback API.
Endpoints below are verified against
cloudflare-control/src/index.ts. Where the in-repodocs/API.mdand the implementation disagree, this page follows the implementation — see Known documentation drift.
Conventions
- Protocol: HTTPS only in production, enforced by HSTS and edge redirection.
- Content type:
application/json; charset=utf-8, except for HTML pages and redirects. - Caching: API responses carry
Cache-Control: no-storeandX-Content-Type-Options: nosniff. - Errors:
{ "error": "<human-readable message>" }with the appropriate status.
Authentication schemes
| Scheme | Header | Used by |
|---|---|---|
| Session cookie | Cookie: __Host-labkiosk_session=<hex32> (HttpOnly; Secure; SameSite=Lax, host-only; labkiosk_session on plain-HTTP dev hosts) | Operator Lab Dashboard, Super Admin console |
| Device bearer token | Authorization: Bearer <hex32> | agent.py on each workstation, for /api/devices/ws, /api/telemetry, /api/devices/boot-report, /api/devices/restart-report, /api/devices/disk-health, /api/devices/video-decoding, /api/devices/hardware and /api/devices/usage |
| Public / key-exchanged | none, or a one-time enrollmentKey in the body | Landing page, legal pages, sign-in, registration, user portal, enrolment, health probe |
Session tokens are random 32-byte hex strings; only their SHA-256 hash is stored in D1. Device tokens are handled the same way — the plaintext token exists only on the workstation that was issued it.
Guards
Every route passes through src/guard.ts before its handler runs:
| Guard | Rejects with | Applies to |
|---|---|---|
resolveTenant() | 404 | every tenant-scoped route |
requireTenantAdmin() | 401 anonymous, 400 no organization, 403 wrong tenant (and a super admin outside its own demos) | GET /api/broadcast-presets, GET /api/whitelist, the /admin pages |
requireTenantPermission(…, permission) | as above, plus 403 without the permission | settings: /api/settings/* (but /api/settings/updates), /api/tenant/subdomain, /api/tenant/homepage, /api/tenant/settings, /api/audit-logs, /api/workstation-issues; workstations: /api/clients*, /api/console/ws, /api/console/remote, /api/groups*; staff: /api/tenant/staff*; portal: mutating /api/portal-sites*; broadcast: mutating /api/broadcast-presets*; whitelist: POST /api/whitelist; updates: /api/settings/updates, /api/clients/check-update, /api/clients/install-update; /api/command: broadcast for navigate, workstations otherwise |
requireSuperAdmin() | 401 / 403 | all /api/super/* |
requireDevice() | 401 | /api/devices/ws, /api/telemetry, /api/devices/boot-report, /api/devices/restart-report, /api/devices/disk-health, /api/devices/video-decoding, /api/devices/hardware, /api/devices/usage, /api/devices/remote |
rejectCrossSiteMutation() | 403 | every cookie-authenticated POST/DELETE under /api/ |
Rate limiting
- Sign-in: repeated failures trigger exponential back-off per identifier, answered with
429 Too Many Requests. - Registration and failed enrolment: throttled per source address via
rateLimitWait()/recordRateLimitHit()indb.ts.
Payload limits
- Thumbnails: capped at 256 KB. Anything larger, or not prefixed
data:image/jpeg;base64,ordata:image/png;base64,, is dropped server-side. The agent drops oversized frames before sending, so the heartbeat still lands. - Lock messages: truncated to 280 characters.
- VNC passwords: truncated to 64 characters (x11vnc itself uses only the first 8 — see Remote Control).
- Client identifiers: must match
^[A-Z0-9][A-Z0-9_-]{0,63}$(enrolment inindex.ts, the hub inorg_hub.ts). The agent is stricter,{0,62}, so a wizard-chosen id always passes. - URLs: every navigable URL passes
safeHttpUrl(), which accepts onlyhttp:/https:and prependshttps://to scheme-less domains.
Endpoint summary
Public
| Endpoint | Method | Description |
|---|---|---|
/api/status | GET | Platform health and the tenant's current kiosk target |
/api/auth/register/email-code | POST | Email a six-digit registration code |
/api/auth/register | POST | Register an organization for review |
/api/contact/email-code | POST | Emails the code that proves the sender's address ({ email, turnstileToken? }) |
/api/contact | POST | The contact page's message ({ name, organization?, email, emailCode, reason, message }); filed in Mail under its reason |
/api/auth/login | POST | Sign in as operator or super admin |
/api/auth/sso/start | GET | ?provider=google|microsoft: start single sign-on from the organization's sign-in page (its host, or ?tenant= on the platform host); redirects to the provider |
/api/auth/sso/callback | GET | The provider's redirect URI, on the platform host only; spends the state, verifies the ID token and sends the browser back to its sign-in page with a one-time code |
/api/auth/sso/redeem | POST | { code } on the sign-in page's host, in the browser that started; answers as /api/auth/login does (a session, or the second step) |
/api/portal-sites | GET | List the host tenant's user portal cards |
/api/devices/enroll | POST | Exchange an enrollment key for a device token |
Session-authenticated
| Endpoint | Method | Description |
|---|---|---|
/api/auth/me | GET | Current user profile and tenant |
/api/auth/logout | POST | Invalidate this session and clear the cookie |
/api/auth/change-password | POST | Rotate password, revoking the account's other sessions and trusted browsers |
/api/auth/login/verify | POST | Second step of a two-factor sign-in (passkey, app code, emailed code or recovery code) |
/api/auth/login/email-code | POST | Email a sign-in code for a pending two-factor sign-in |
/api/auth/login/passkey | POST | The WebAuthn request options for a pending two-factor sign-in |
/api/auth/two-factor[/email,/setup,/enable,/recovery-codes,/disable,/passkey-options,/passkey-register,/passkey-delete] | GET/POST | The signed-in account's own two-factor sign-in |
Operator admin
| Endpoint | Method | Description |
|---|---|---|
/api/clients | GET | Fleet state with live thumbnails and remote-control details |
/api/clients/remote-session | POST | Open a Remote Control session through the console's relay; asks the workstation to join (409 when it is not connected, 429 when every seat is in use) |
/api/tenant/remote-control/disable | POST | The organization turns Remote Control off for itself; open sessions end (settings) |
/api/notifications | GET | The platform's notifications for this organization, each with read for this user |
/api/notifications/read | POST | { ids? }: dismiss these notifications for this user, or all of them |
/api/console/remote | GET (WebSocket) | The viewer's side of a Remote Control session (VNC bytes) |
/api/clients/remove | POST | Decommission a workstation and revoke its token |
/api/clients/group | POST | Assign workstations to a group |
/api/clients/wake | POST | { clientIds }: switch on workstations that are off, through one that is on at the same site (Wake-on-LAN; workstations) |
/api/power-schedules | GET POST | List the organization's power schedules (with its groups), or create or replace one (settings) |
/api/power-schedules/:id | DELETE | Delete a power schedule (settings) |
/api/groups | GET POST | List and create workstation groups |
/api/groups/:id | DELETE | Delete a workstation group |
/api/tenant/staff | GET POST | List and create delegated staff (requires staff; see the delegation limits in docs/API.md) |
/api/tenant/staff/update | POST | Change a staff account's role or permissions |
/api/tenant/staff/:id | DELETE | Remove a staff account and end its sessions |
/api/command | POST | Dispatch a command to one, selected, or all workstations |
/api/whitelist | GET POST | Read and modify the permanent domain allowlist |
/api/portal-sites | POST | Add a user portal card |
/api/portal-sites/:id | DELETE | Remove a user portal card |
/api/broadcast-presets | GET POST | List and add quick-launch broadcast shortcuts |
/api/broadcast-presets/:id | DELETE | Remove a broadcast shortcut |
/api/settings/mode | POST | Switch between portal and single_url |
/api/settings/customization | GET POST | Organization branding, portal copy, default lock message |
/api/tenant/subdomain | POST | { subdomain }: change the console address at once, at most once every 7 days (429 sooner); earlier addresses keep working. /api/settings/subdomain is the same route |
/api/tenant/remote-control/enable | POST | Turn Remote Control on; 409 when it is on, revoked by the platform, or the plan has no Remote Control seats |
/api/plan/custom | GET POST | The latest Custom plan request, or ask for one: { workstations, remoteSeats?, staff?, period: "month"|"year", notes? }; 409 while one is open or its link is unpaid |
/api/settings/enrollment-key | GET POST | View or rotate the enrollment key |
/api/settings/custom-domain | POST DELETE | Connect a custom domain (included in Pro and Custom, an add-on on Starter, Standard and Education; 403 otherwise; bound at once and its Cloudflare custom hostname is created) or disconnect it |
/api/audit-logs | GET | Paginated organization audit log |
/api/workstation-issues | GET | Errors and warnings workstations reported (Settings → Errors & Warnings), newest first, with each one's bug report state; plus the organization's automatic bug report settings (requires settings) |
/api/workstation-issues/log | GET | ?id=: the journal a restart report carried, kept 30 days (requires settings) |
/api/usage | GET | ?days=1..366: usage reports for Settings → Usage: per-day totals, per-workstation totals (with its group), the 100 sites with the most time in use, and whether sites are recorded (requires settings) |
/api/usage/settings | POST | { recordSites: boolean }: whether workstations send the sites they spend time on; pushed to workstations at once (requires settings) |
/api/usage/sites/delete | POST | Delete every site the organization recorded; the time on and in use stays (requires settings) |
/api/settings/bug-reports | POST | Opt in to or out of automatic, redacted GitHub bug reports; turning them on accepts the current terms version (requires settings) |
/api/settings/sso | GET POST | Single sign-on: { google: { enabled, domains }, microsoft: { enabled, tenants }, requireSso }. Reading requires settings; changing it also an administrator (owner or org_admin), 409 when turning on a provider the platform has not set up |
/api/settings/printing | GET POST | Settings → Printing: whether workstations may print, and the organization's network printers (requires settings) |
Device
| Endpoint | Method | Description |
|---|---|---|
/api/devices/ws | GET (WebSocket) | The control channel: status and frames up; configuration, commands and frame requests down |
/api/telemetry | POST | The HTTP fallback: a heartbeat (3 s while a console is open, 15 s otherwise) carrying the same |
/api/devices/boot-report | POST | An installed workstation's boot outcome (update installed, failed, rolled back, fallback, error) |
/api/devices/restart-report | POST | A boot that ended without shutting down (power cut, hang, watchdog reset), with the end of its journal |
/api/devices/disk-health | POST | The workstation's disks that are wearing out or failing, as labkiosk-health found them |
/api/devices/video-decoding | POST | What the workstation's GPUs decode in hardware (VA-API), read with vainfo at each agent start |
/api/devices/hardware | POST | The machine it runs on, once per agent start: { vendor, model, cpu, cores, memoryMb, bootMode: "uefi"|"bios", keyboard, touch, macs } (keyboard/touch are null when the agent could not tell; at most 8 wired MAC addresses). 400 on a malformed report, 409 before the workstation's row exists |
/api/devices/usage | POST | Time switched on and in use since the last report, every 15 minutes: { days: [{ day, onSeconds, activeSeconds, sessions, sites: [{ domain, seconds, visits }] }] }. Days are the workstation's own calendar days, at most 7 days old; amounts are added to what is stored. sites is ignored while the organization does not record sites |
/api/devices/power-report | POST | A workstation switching off by its power schedule could not set its hardware clock to switch it on again |
/api/devices/remote | GET (WebSocket) | The workstation's side of a Remote Control session, with X-Labkiosk-Session; piped to its loopback x11vnc |
Release build
| Endpoint | Method | Description |
|---|---|---|
/api/release-notes/sync | POST | The ISO build, right after publishing a release: re-reads GitHub's releases so /download offers the new one at once. Authorization: Bearer <RELEASE_NOTES_TOKEN>. 200 {stored, latest}; 401 wrong token; 502 GitHub unreadable; 503 token not configured |
/api/release-support | GET | The daily security rebuild: the support status of every major release the platform has set (supported, security_only, end_of_life; a passed end-of-life date counts as end_of_life), so it rebuilds only lines of majors not at end of life, and every unrevoked feature release classified stable, so it skips a line a newer stable line of its major supersedes. Authorization: Bearer <RELEASE_NOTES_TOKEN>. 200 {majors: [{major, status, endOfLifeAt}], stable: ["3.1.0", …]}; 401 wrong token; 503 token not configured |
Super admin
| Endpoint | Method | Description |
|---|---|---|
/api/super/inbox | GET | Tasks or Mail, ?box=tasks|support&mailbox=<address> |
/api/super/inbox/compose | POST | Write a new email as any address on the mail domain |
/api/super/inbox/:id | GET | One conversation, its messages and registration details |
/api/super/inbox/:id/{reply,note,phone-link,status,unread,trash,restore,delete} | POST | Answer by email, note, send a registration made before approvals ended a link to prove its phone, open or close, mark unread, move to or from the bin, delete |
/api/super/custom-plans | GET | Every Custom plan request, open ones first, with billingEnabled and gstPercent |
/api/super/custom-plans/approve | POST | { id, price, workstations?, remoteSeats?, staff?, period?, validDays?, note? }: price is whole rupees before GST for one period; creates the Razorpay payment link (open validDays, 1–30, default 7) and emails it to the owner. 502 when Razorpay refuses, leaving the request open |
/api/super/custom-plans/decline | POST | { id, reason }: the organization is told the reason |
/api/super/inbox/:id/attachment/:messageId/:index | GET | Download an attachment, or original for the whole message |
/api/super/usage | GET | ?days=1..366: the platform's anonymous daily totals and the sites at least 3 organizations visited on a day, plus hardware: { models, computedAt }, every model workstations reported (System → Usage and System → Hardware) |
/api/super/tenants/suspend | POST | Suspend an active organization |
/api/super/tenants/reactivate | POST | Reactivate a suspended organization |
/api/super/tenants/workstation-limit | POST | { tenantId, limit }: how many workstations may enrol (1–100000) |
/api/super/tenants/license | POST | { tenantId, plan, expiresOn }: the license plan (education, evaluation, subscriber, commercial) and end date (YYYY-MM-DD or null) |
/api/super/notifications | GET / POST | Every notification sent; POST { tenantId | null, title, body, email? } notifies one organization or all of them in their consoles, and with email emails each owner |
/api/super/tenants/remote-control | POST | { tenantId, action: "revoke" | "restore" | "seats", seats?, reason? }: revoking ends every open session and emails the owner |
/api/super/tenants/custom-domain/remove | POST | Unbind an assigned custom domain |
HTML routes
| Path | Serves |
|---|---|
/ | Landing page on the platform apex; User Portal on a tenant host |
/ | Organization homepage (organization-authored headline, intro and content blocks) |
/home | User Portal (approved app grid) |
/admin | Operator Lab Dashboard |
/super | Super Admin Master Console |
/login, /register, /contact | Landing-page sections |
/privacy, /terms | Privacy Policy and Terms of Service |
/content-policy | The Content Policy, part of the Terms of Service (public) |
/dpa | The Data Processing Agreement and its subprocessor list, part of the Terms of Service (public) |
/terms/bug-reports | The Automatic Bug Report Terms (public) |
/download, /iso | Redirect to ISO_DOWNLOAD_URL |
Detailed reference
POST /api/devices/enroll
Exchanges an organization's enrollment key for a persistent device bearer token. This is the only moment a workstation proves who it is with a shared secret; afterwards it holds its own token.
Access: public, throttled per source address on failure.
{
"subdomain": "oakridge",
"clientId": "PC-01",
"enrollmentKey": "KEY-ABCD-1234-EFGH",
"customDomain": "kiosk.oakridge.edu"
}
customDomain is optional; the agent sends it when the workstation was pointed at a custom domain rather than a platform subdomain.
**200 OK**
{
"status": "ok",
"deviceToken": "32_byte_hex_bearer_token",
"clientId": "PC-01",
"subdomain": "oakridge",
"organizationName": "Oakridge Holdings",
"schoolName": "Oakridge Holdings",
"mode": "portal",
"targetUrl": "https://oakridge.labkiosk.example.com"
}
schoolName is also sent, with the same value, for agents installed from an ISO older than the organization vocabulary. It is deprecated: new code reads organizationName, and the field will be removed once no workstation in the field depends on it.
The agent writes the token to /etc/labkiosk/config.json with mode 0600. On live media that file lives in the RAM overlay and is lost at power-off, which is intended — the workstation is meant to be installed. On an installed disk, /etc/labkiosk is a mount point for the LABKIOSK_DATA partition, which is what makes a post-install enrolment persist.
Failure modes: an empty or wrong key, an unapproved or suspended organization, or a clientId failing CLIENT_ID_PATTERN are all rejected. Organizations begin with an empty enrollment key, which authenticates nothing until an operator generates one.
GET /api/devices/ws
The workstation's control channel: a WebSocket to its organization's OrgHub. Current agents use it whenever the image has python3-websocket.
Access: Authorization: Bearer <deviceToken> on the upgrade. 401/403 when the token or the organization is refused, 426 without an upgrade.
| Direction | Message |
|---|---|
| hub → workstation | {"type":"config", whitelist, mode, targetUrl, broadcastUrl, broadcastEpoch, commands?} on connect and after every admin change |
| hub → workstation | {"type":"commands", commands} the moment a command is dispatched |
| hub → workstation | {"type":"frames", on, intervalSeconds} when a console starts or stops showing this screen |
| workstation → hub | {"type":"status", clientNum, activeUrl, isLocked, vncPassword?} on connect and on change |
| workstation → hub | {"type":"frame", thumbnail} every intervalSeconds while asked |
| workstation → hub | {"type":"ping"} every 15 s, byte for byte; answered {"type":"pong"} at the edge |
Close codes: 4001 the workstation was removed, 4003 the organization is not active (both send the screen to re-enrolment), 4000 replaced by a newer connection, 4008 silent for 75 s.
GET /api/console/ws
The Workstations page's live channel. Access: a session with the workstations permission and an Origin of this site. The console sends {"type":"watch", clientIds} for the screens it is showing and receives snapshot, status, frame and removed messages.
POST /api/telemetry
The HTTP heartbeat, used by agents without the WebSocket client (and by any agent whose server has no WebSocket route, or whose network drops WebSocket upgrades). The reply paces it: every 3 seconds while a console is open or was used in the last minute, every 15 seconds otherwise. It carries the same state as the control channel in one request and reply.
Access: Authorization: Bearer <deviceToken>.
Request — exactly these keys; post_telemetry() in agent.py is the reference implementation:
{
"clientNum": 1,
"activeUrl": "https://scratch.mit.edu",
"isLocked": false,
"thumbnail": "data:image/jpeg;base64,...",
"vncPassword": "a1b2c3d4"
}
| Field | Notes |
|---|---|
clientNum | Integer workstation number; non-numeric values fall back to 1. |
activeUrl | Validated by safeHttpUrl(); falls back to the tenant default. |
isLocked | Whether the lock curtain is currently up. |
thumbnail | Base64 JPEG from scrot -t 20 -q 35. Sent only while the last reply's frames was true (an agent older than the field sends it every time). Omitted when the encoded payload would exceed MAX_THUMBNAIL_BYTES (256 KB), so an oversized frame is dropped rather than allowed to bloat the loop. No PIL/Pillow is involved — the agent is standard library only. |
vncPassword | Per-boot ephemeral secret from /tmp/labkiosk/vnc.secret. Sent only when present, so the control plane keeps what it already knows otherwise. |
There is **no currentUrl key and no metrics object.** The agent collects no CPU, RAM, or storage statistics; do not build a dashboard against fields that do not exist.
Identity is taken from the token, never the body. Any clientId or tenant the payload claims is discarded.
**200 OK**
{
"status": "ok",
"commands": [
{ "id": "cmd-123", "action": "lock", "message": "Eyes to the board please." }
],
"whitelist": ["scratch.mit.edu", "khanacademy.org", "oakridge.labkiosk.example.com"],
"mode": "portal",
"targetUrl": "https://oakridge.labkiosk.example.com",
"broadcastUrl": "",
"broadcastEpoch": 0,
"heartbeatSeconds": 15,
"frames": false
}
| Field | Notes |
|---|---|
heartbeatSeconds | Seconds until the next heartbeat: 3 while a console is open or was used in the last minute, 15 otherwise. Every heartbeat is a billed request that wakes the organization's hub. A workstation is shown offline after 36 seconds without one. |
frames | Whether a console is showing this screen; send thumbnail only while it is true. |
commands | Pending commands for this workstation. The hub records each delivery, so each command executes exactly once rather than on every heartbeat. |
whitelist | Effective allowlist: the organization's own domains plus every portal app host, plus the active broadcast host if it is not already present. Merged into the Chromium managed policy. |
targetUrl | Where the kiosk should point. Validated as http(s) by safe_navigable_url() before the agent stores it, because it ends up in window.location. |
broadcastUrl / broadcastEpoch | The authoritative synchronised page. The epoch is a monotonic marker letting a workstation distinguish a new broadcast from a replayed one. |
printing | { "enabled": false, "printers": [] } until the organization turns printing on; then the printers meant for this workstation (every-workstation ones and its group's), each { id, name, uri }. The hub's config message carries the same. |
**403** if the organization is not active — a suspended organization's workstations stop receiving commands and policy.
POST /api/devices/boot-report
What an installed workstation's last boot did with its system image, as labkiosk-boot-slots check recorded it in /run/labkiosk-update/status.json. The agent sends only the outcomes worth an administrator's attention; the latest is kept on the workstation's row (client_devices.image_version, update_state, update_error, update_state_at). A failure, rollback, fallback or error is also listed in workstation_issues (Settings → Errors & Warnings) as update_failed, update_rolled_back, boot_error (severity error) or boot_fallback (warning). None of it goes to the audit log, which records what people did.
Access: Authorization: Bearer <deviceToken>; the token decides the organization and the workstation.
Request: state (installed | failed | rolled-back | fallback | error), version (the image running), at (when the workstation recorded it, Unix seconds, within the last 7 days); optional previous, failed (release versions) and error (text, cut to 300 characters).
{ "state": "rolled-back", "version": "2.5.1", "failed": "2.6.0", "at": 1791100000 }
**200 OK** → { "status": "ok", "recorded": true }; recorded: false for a report the workstation already sent (or one less than 60 s after the last). **400 malformed, not sent again. 409** the workstation has not checked in yet, sent again later.
POST /api/devices/restart-report
A boot of an installed workstation that ended without shutting down: a power cut, a forced power-off, a hang the hardware watchdog restarted, or a kernel panic. At the next start labkiosk-logs (root) sees that the previous boot never recorded a clean shutdown and saves the last 300 lines of its journal on the data partition; the agent sends that here once. It is listed in workstation_issues as unexpected_restart (warning) or watchdog_reset (error), one row per boot, and its log is kept 30 days. Restart reports are never filed as automatic bug reports.
Access: Authorization: Bearer <deviceToken>; the token decides the organization and the workstation.
Request: bootId (32 hex digits), kind (unexpected_restart | watchdog_reset), version (or null), startedAt, endedAt (Unix seconds; endedAt within the last 7 days and not before startedAt), log (the last 16 KB are kept).
**200 OK** → { "status": "ok", "recorded": true }; recorded: false for a boot already reported. **400 malformed, not sent again. 409 the workstation has not checked in yet, sent again later. 429** more than 24 in a day from this workstation; the rest wait for its next start.
POST /api/devices/disk-health
The machine's own disks that labkiosk-health (root, 90 s after boot and every six hours) found wearing out or failing, from SMART (SATA, NVMe) or an eMMC card's wear figures. The agent sends them after each check that found a problem; a healthy disk, or one with no data (a virtual disk), is never sent. Each disk is listed in workstation_issues as disk_health once per state — severity warning for a disk wearing out, error for one failing — with details such as Disk Example SSD 256GB (nvme0n1): Wearing out: 93% of its rated life used. Plan to replace it. (a failing disk ends Replace it before it stops working.). Never filed as an automatic bug report.
Access: Authorization: Bearer <deviceToken>; the token decides the organization and the workstation.
Request: disks, 1 to 8 objects with device (a kernel disk name: sda, nvme0n1, mmcblk0, …), model, serial, state (warning | failing) and summary.
{ "disks": [ { "device": "nvme0n1", "model": "Example SSD 256GB", "serial": "S1234", "state": "warning", "summary": "Wearing out: 93% of its rated life used." } ] }
**200 OK** → { "status": "ok", "recorded": 1 }; recorded counts the disks newly listed (0 when each is already listed in that state). **400 malformed, not sent again. 401 bad token. 409 the workstation has not checked in yet, sent again later. 429** more than 8 disk issues in a day from this workstation; the next check sends again.
POST /api/devices/video-decoding
What the workstation's GPUs decode in hardware, read by the agent with vainfo --display drm on each render node once per start; Chromium decodes everything else on the CPU. The latest report replaces the last (client_devices.video_decoding) and comes back as videoDecoding (with reportedAt, ms) in GET /api/clients.
Access: Authorization: Bearer <deviceToken>; the token decides the organization and the workstation.
Request: gpus, 0 to 4 objects with vendor (intel | amd | nvidia | virtual | other), kernelDriver (may be empty), vaDriver (≤ 120 characters), decode and encode (from h264, hevc, vp8, vp9, av1, mpeg2, vc1, jpeg) and an optional problem (≤ 200 characters). With no GPU, a top-level problem says why.
{ "gpus": [ { "vendor": "intel", "kernelDriver": "i915", "vaDriver": "Intel iHD driver for Intel(R) Gen Graphics - 23.1.1 ()", "decode": ["av1", "h264", "hevc", "vp9"], "encode": ["h264"] } ] }
**200 OK** → { "status": "ok" }. **400 malformed, not sent again. 401 bad token. 409** the workstation has not checked in yet, sent again later.
POST /api/devices/power-report
Sent just before a power schedule shuts the workstation down, when labkiosk-wake-alarm could not set the hardware clock to switch it on again. Listed under Settings → Errors & Warnings as Cannot switch itself on (warning), once per workstation, problem and day, and never sent as an automatic bug report.
Access: Authorization: Bearer <deviceToken>.
Request: problem (no-rtc: the machine has no RTC that can wake it; failed: the RTC refused the alarm), wakeAt (YYYY-MM-DD HH:MM, the workstation's local time it should have switched on) and an optional detail (≤ 300 characters, control characters removed).
{ "problem": "no-rtc", "wakeAt": "2026-10-26 07:30", "detail": "/sys/class/rtc/rtc0/wakealarm does not exist" }
**200 OK** → { "status": "ok", "recorded": true } (false when already listed today). **400 malformed. 401 bad token. 409** the workstation has not checked in yet.
Power schedules: GET / POST /api/power-schedules, DELETE /api/power-schedules/:id
Access: a session with the settings permission, on the organization's own host (cross-site Origin refused).
GET → { "schedules": [ { "id", "groupId", "groupName", "days": [1,2,3,4,5], "off": "18:00", "on": "07:30", "updatedAt" } ], "groups": [ { "id", "name" } ] }. Days are 0 Sunday to 6 Saturday.
POST { id?, days, off, on?, groupId? } creates a schedule, or replaces the one named by id. off and on are HH:MM on each workstation's own clock; leave on out to switch the workstations on by hand. groupId limits it to one workstation group; without it the schedule is for every workstation. The rule: for each day, a workstation follows its group's schedule for that day when there is one, else the all-workstations one. **200** { "status": "ok", "schedule": {…} }. **400 no day, a malformed time, or switch-on within 15 minutes of switch-off. 404** unknown group or id. **409** another schedule for the same workstations already covers one of those days, or the organization already has 50.
DELETE /api/power-schedules/:id → **200, or 404**.
Every change writes power.schedule_create, power.schedule_update or power.schedule_delete to the audit log, and the workstations receive their new schedule at once: power in the control channel's configuration and in the POST /api/telemetry reply, { "week": [ { "off": 1080, "on": 450 } | null, … seven, Sunday first ] } in minutes, or null.
POST /api/clients/wake
Switches on workstations that are off, by Wake-on-LAN. Access: a session with the workstations permission, on the organization's own host.
Request: { "clientIds": ["PC-01", …] }, 1 to 500.
For each one the Worker takes the wired MAC addresses from that workstation's own hardware report in this organization's rows (never from the request), picks a workstation of the same organization that is on at the same LAN site (the private network it last reported; an installed disk's agent reports it) and runs an agent that can send it, and queues that one a wake command carrying those addresses (at most 64 per command). The agent broadcasts a magic packet (six 0xFF bytes, then the MAC sixteen times) to UDP port 9 on each of its wired networks.
**200 OK** → { "status": "ok", "sent": [ { "clientId", "via" } ], "skipped": [ { "clientId", "reason" } ] }, audit command.wake. **409** when none could be woken, with error and the same lists; the reasons are: already on; no wired adapter reported; its local network not known yet; no workstation on at its site; the ones on at its site run an agent too old to send it. **400** malformed or more than 500.
The machine's firmware must allow it (Wake on LAN / Power on by PCI-E), and the network must carry the broadcast to it.
GET /api/workstation-issues
Errors and warnings the organization's workstations reported, newest first (?limit=, default 100, at most 200; rows older than 90 days are deleted by the hourly cron).
Access: organization admin or staff with the settings permission.
Each issue carries id, client_id, severity, kind, image_version, details, occurred_at, created_at, has_log (1 when a restart report's log is kept; read it with GET /api/workstation-issues/log?id=<id>, which answers {id, log} or 404), report_state (none | pending | sent), report_match (new | existing), and, once sent, issue_url, issue_number, report_status (open | in_progress | pr_open | resolved | closed) and pr_url. The response also carries the organization's opt-in state:
{
"issues": [ … ],
"bugReports": {
"enabled": false,
"available": true,
"repository": "owner/repo",
"termsVersion": "2026-10-04",
"acceptedTermsVersion": null,
"termsAcceptedAt": null
}
}
available is false, and repository null, unless the platform has set up the AI binding, GITHUB_ISSUES_TOKEN and a valid GITHUB_ISSUES_REPO.
POST /api/settings/bug-reports
Opts the organization in to or out of automatic, redacted GitHub bug reports. Turning them on accepts the current Automatic Bug Report Terms (/terms/bug-reports), by version.
Access: organization admin or staff with the settings permission.
{ "enabled": true, "acceptTerms": "2026-10-04" }
{ "enabled": false }
**200 OK** → { "status": "ok", "enabled": true }, with an audit-log row (settings.bug_reports). **400** when enabled is not a boolean, or when turning on without the current terms version. **409** when the platform has not set automatic bug reports up.
POST /api/command
Dispatches a remote action to one workstation or the whole lab.
Access: organization admin.
Supported actions (ALLOWED_COMMANDS in index.ts, mirrored by execute_command() in agent.py):
| Action | Effect on the workstation |
|---|---|
lock | Raises the full-screen lock curtain across every tab, with the message. |
unlock | Drops the curtain. |
navigate | Navigates top-level to url. With resetPortal: true, returns to the organization portal and clears the broadcast. |
reload | Reloads the current page. |
reboot | Reboots the workstation through logind. |
shutdown | Powers the workstation off. |
mute | Mutes audio output via alsa-utils. |
Anything else is rejected with 400 Unsupported action. There is no broadcast action — a broadcast is navigate to target: "all", which additionally writes broadcast_url and broadcast_epoch onto the tenant row.
{ "targets": ["PC-01", "PC-02"], "action": "lock", "message": "Midterm examination is beginning." }
{ "target": "all", "action": "navigate", "url": "https://scratch.mit.edu" }
{ "target": "all", "action": "navigate", "resetPortal": true }
Targeting supports either targets: string[] (array of clientId strings) or target: string ("all" or a single clientId). Duplicates are dropped, "all" replaces named targets, and at most 500 targets are accepted. When action is lock and no message is supplied, the tenant's default_lock_message is used.
**200 OK** → { "status": "ok", "commandId": "cmd-uuid-99" }
The hub pushes the command to a connected workstation at once; the console sees the new state as soon as the workstation reports it. Every dispatch writes an audit-log row (command.<action>).
GET /api/clients
Returns the organization's fleet: the D1 registry merged with the hub's live status. POST with {"watch": ["PC-01", …]} also asks the hub for those screens' frames for the next 10 seconds -- the fallback for a console without its live channel; thumbnail is present only for watched, online workstations.
Access: organization admin.
{
"clients": {
"PC-01": {
"clientId": "PC-01",
"clientNum": 1,
"activeUrl": "https://scratch.mit.edu",
"isLocked": false,
"thumbnail": "data:image/jpeg;base64,...",
"timestamp": 1726300000,
"lastSeen": "2026-09-14T09:26:40.000Z",
"online": true,
"vncPassword": "a1b2c3d4"
}
}
}
vncPassword is what makes one-click remote control work without an operator typing anything. It is readable only by an authenticated admin of that specific organization. A remoteHost an older agent still sends is ignored.
POST /api/clients/remove
Decommissions a workstation and revokes its device token. The machine's next heartbeat fails with 401 and it stops appearing on the dashboard.
{ "clientId": "PC-01" }
→ { "status": "ok", "remaining": 14 }
POST /api/auth/register
Creates an organization and its owner, active at once on the Free plan; no one approves it. Both the email address and the phone number must be proved: ask for emailCode first with POST /api/auth/register/email-code { "email" }, and send phoneToken, the Firebase ID token from verifying the phone by a texted code. Without Firebase configured, registration answers 503. The owner then signs in and enters the organization's details (POST /api/tenant/organization) before the console, enrolment and billing open.
{
"contactName": "Jane Smith",
"email": "it@oakridge.example",
"emailCode": "482913",
"phone": "+91 98765 43210",
"phoneToken": "<Firebase ID token>",
"password": "StrongPassword123!",
"subdomain": "oakridge",
"acceptTerms": true
}
→ { "status": "ok", "active": true, "signIn": "https://labkiosk.org/login" }
The organization's details, signed in as the owner, once:
POST /api/tenant/organization
{
"name": "Oakridge Holdings",
"legalName": "Oakridge Holdings Pvt Ltd",
"organizationType": "business",
"addressLine1": "12 Market Road",
"city": "Bhubaneswar",
"region": "Odisha",
"postalCode": "751001",
"country": "India",
"taxId": "21ABCDE1234F1Z5",
"billingEmail": "accounts@oakridge.example",
"workstationEstimate": 40
}
country is an ISO 3166-1 alpha-2 code (IN) or the English name as listed in src/geo.ts, and is stored as the name. Where that country's states are listed, region must be one of them; postalCode is checked against the country's format and may be empty where addresses carry none; taxId, when given, is checked against the country's format (GSTIN, EIN, VAT number and so on). phone is the calling code and the number without its leading 0. The registration form reads the same table from /assets/geo-<hash>.json.
Reserved slugs are refused. Passwords are checked by validatePasswordStrength() and stored as PBKDF2-HMAC-SHA256, 100 000 iterations, 32-byte random salt, 256 derived bits.
POST /api/auth/login
{ "email": "operator@oakridge.edu", "password": "StrongPassword123!" }
→ { "status": "ok", "role": "org_admin", "subdomain": "oakridge", "redirect": "…" }, plus the host-only __Host-labkiosk_session and labkiosk_device cookies. When the console is on another host than the sign-in, the session cookie is not set here: redirect is that host's /api/auth/handoff?code=…&next=…, which spends the one-time, host-bound code (valid 60 s) and sets the cookie there. An account with two-factor sign-in, on a browser it has not trusted, gets { "status": "two_factor", "challenge": "…" } instead, completed with POST /api/auth/login/verify.
Repeated failures back off exponentially per identifier, tracked in login_attempts. Staff of an organization that requires single sign-on get 403 once their password checked out (the owner never does).
Single sign-on: /api/auth/sso/start, /callback, /redeem
- The sign-in page links
GET /api/auth/sso/start?provider=google&tenant=<slug>. The Worker stores asso_statesrow, sets the host-onlylabkiosk_ssocookie (Path=/api/auth/sso,SameSite=Strict) and answers302to the provider withstate,nonce,code_challenge(S256) and the platform's redirect URI. An organization that did not turn the provider on, or a platform without its secrets, goes back to the sign-in page withsso_error=unavailable. - The provider returns to
GET /api/auth/sso/callback?state&codeon the platform host. A missing, unknown, used or expired state is a400page. Otherwise the browser goes back to<sign-in page>/?login=1&tenant=<slug>&sso=<code>, or withsso_error=one ofcancelled,unavailable,directory,no_account,locked,provider,identity. - The page posts
POST /api/auth/sso/redeem { "code": "<64 hex>" }.401when the code is spent, expired, from another host or another browser, or the account was removed meanwhile;403for a cross-siteOrigin. Success is the/api/auth/loginanswer above.
POST /api/auth/change-password
Rotates the password and revokes the account's other sessions, so a stolen cookie does not survive a password change. This is the only path by which a password changes.
{ "currentPassword": "OldPassword123!", "newPassword": "NewStrongPassword456!" }
GET / POST /api/portal-sites
GET is public and scoped to the host tenant; it is what the User Portal renders from. POST requires organization admin.
{
"title": "Scratch Programming",
"url": "https://scratch.mit.edu",
"category": "Computer Science",
"icon": "🐱",
"thumbnailUrl": "https://example.com/scratch.jpg"
}
Adding a card implicitly authorises its host: buildEffectiveWhitelist() unions the permanent allowlist with every portal app domain, so an operator never has to add a site in two places.
POST /api/settings/mode
{ "mode": "single_url", "defaultUrl": "https://canvas.example.edu" }
safeHttpUrl() prepends https:// to a scheme-less domain, so canvas.example.edu is accepted.
POST /api/settings/customization
{
"name": "Oakridge STEM Academy",
"defaultLockMessage": "Examination active. No talking.",
"portalTitle": "Digital Learning Lab",
"portalSubtitle": "Select an approved page to begin",
"portalDescription": "Computer Science Lab 304",
"portalFooter": "For technical assistance, raise your hand."
}
Every one of these strings is attacker-controlled from the platform's perspective and is escaped on render. The test suite asserts that hostile input renders inert.
POST /api/tenant/settings
Settings → General. Guard: requireTenantPermission(…, "settings"). Takes any of name, mode, defaultUrl, defaultLockMessage, homeRoute, the four portal strings, and homeReset (a boolean: Home in the kiosk bar asks "Start over?" and signs everyone out; 400 for anything but true or false). Answers { "status": "ok", "updates": { … } } with the columns changed, records them in the audit log as settings.update and pushes the change to the workstations (homeReset in their configuration).
GET / POST /api/settings/printing
Settings → Printing. Guard: requireTenantPermission(…, "settings"). GET returns
{ "status": "ok", "enabled": false, "printers": [], "groups": ["Library"], "maxPrinters": 20 }
POST takes { "enabled": true, "printers": [{ "id": "…", "name": "Front desk", "uri": "ipp://192.168.1.40/ipp/print", "groupName": null }] } and replaces the whole list. enabled must be a boolean and printers a list of at most 20. Each name is 1–64 characters without control characters and unique case-insensitively; each uri is ipp:// or ipps://, a host name or a private address (10/8, 172.16/12, 192.168/16, 169.254/16, fc00::/7), an optional port and a plain path, at most 255 characters (no file:, usb:, user info, query, fragment, spaces or shell characters, and never localhost or a public address). groupName is an existing workstation group or null. An id is kept only when the organization already has it; any other printer gets a new one. Answers 400 with the first problem, 404 for an unknown group, otherwise the same shape as GET. Recorded in the audit log as settings.printing and pushed to the workstations at once.
POST /api/settings/enrollment-key
Rotates the key. Already-enrolled workstations keep their bearer tokens and are unaffected — rotation only prevents new enrolments with the old key.
→ { "status": "ok", "enrollmentKey": "KEY-WXYZ-7890-HIJK" }
Super admin endpoints
The organization endpoints take a tenantId, and all require a super_admin session.
{ "tenantId": "tenant-uuid-1" }
Suspension is the platform's kill switch: a suspended organization's workstations receive 403 on telemetry, stop getting commands and policy, and its portal stops serving.
Connecting a custom domain binds an FQDN to a tenant. Once bound, Cloudflare routes it to the worker and resolveTenant() recognises it from the Host header. → Super Admin Guide
The client agent's loopback API
agent.py also serves a small HTTP API on **127.0.0.1:8888**, used only by the local setup wizard. It is not reachable from the network, from the organization LAN, or from a visited web page.
Every request must satisfy both _is_expected_host() (the Host header is loopback) and _is_local_caller() (the Origin, when present, is 127.0.0.1 or localhost). Either check failing returns 403.
One further origin is accepted: the kiosk extension's own origin (chrome-extension://hfjmbeplebjipenkfabncgkpadnjmmoe, pinned by the key in manifest.json). Chromium stamps every non-GET fetch from the extension's service worker with it, and that worker is what the top bar's administrator modal uses to reach POST /api/admin/verify.
| Endpoint | Method | Description |
|---|---|---|
/setup | GET | Serves wizard.html. Returns 403 once the workstation is enrolled unless accessed via #network with admin authentication. |
/api/status | GET | Local state: clientId, clientNum, isLocked, lockMessage, targetUrl, broadcastUrl, broadcastEpoch, isConfigured, baseDomain, isLive, isInstalled, isOnline, persistentStorage, installRequested, secureBoot (on, off, legacy-bios or unknown), clockSynchronized (true once a time server has set the clock since boot), hostname, keyboardPresent and touchPresent (from /proc/bus/input/devices; null when that lists no device or cannot be read — the kiosk bar opens its on-screen keyboard by itself only on false). persistentStorage is false when /etc/labkiosk is not the LABKIOSK_DATA partition, i.e. an enrolment made now would not survive a reboot. |
/api/localization/options | GET | Continents, countries, timezones, locales, keyboard layouts and interface catalogs, all read from the workstation's own tzdata, locale and X11 tables. |
/api/localization/languages | GET | Interface languages the organization's control plane offers, with the installed ones marked. |
/api/localization/language/download | POST | Downloads one catalog from the control plane into /etc/labkiosk/i18n. Administrator token required once installed. |
/api/localization/configure | POST | Applies language, region, timezone, keyboard and (when syncTime is false) the clock by hand. Administrator token required once installed. |
/i18n/<tag>.json | GET | An interface catalog. en-US is bundled; others come from /etc/labkiosk/i18n. |
/api/network/status | GET | Comprehensive network status: active device, IPv4/IPv6 addresses, gateway, DNS, proxy, interfaces, and connectivity check. |
/api/network/interfaces | GET | List of hardware interfaces with device name, type (ethernet / wifi), state, and physical carrier link status. |
/api/network/wifi/scan | GET | Live Wi-Fi scan results: SSID, BSSID, signal strength (0-100), channel, security mode, and encrypted flag. |
/api/network/configure | POST | Configures and connects interface (Ethernet/Wi-Fi) with IPv4/IPv6 mode (auto, custom_dns, manual), DNS, and optional HTTP proxy. |
/api/network/test | POST | Probes DNS resolution and internet route reachability (1.1.1.1:53 / 8.8.8.8:53). |
/api/log | GET | Tail of /tmp/lab-agent.log (max 64 KB, text/plain). Needs the X-LabKiosk-Admin token on an installed workstation. Shown by the wizard's Agent Log & Diagnostics panel. |
/api/admin/verify | POST | Verifies administrator password against the GRUB PBKDF2 hash (/run/live/medium/boot/grub/labkiosk-password.cfg: boot/grub on the installed disk's LABKIOSK_ROOT, outside every system image) and returns a 10-minute token for /api/network/configure (header X-LabKiosk-Admin, required on installed systems). Throttled: 5 failures lock it for 60 s. |
/api/install/disks | GET | Candidate target disks. Returns [] when not a live session. |
/api/install/status | GET | Installation state and progress percentage. |
/api/install | POST | Starts the disk install. 400 when the system is already installed. |
/api/reboot | POST | Reboots the workstation. |
/api/setup | POST | Performs enrolment against the control plane. 409 once already enrolled. |
POST /api/install takes targetDisk (re-validated against TARGET_DISK_PATTERN) an optional grubPasswordHash (re-validated against GRUB_PBKDF2_PATTERN) and an optional hostname (one lowercase DNS label; generated when absent). Only a digest is accepted: the wizard derives PBKDF2 in the browser with WebCrypto, so the plaintext boot-menu password never crosses the agent's API, never appears in a process argument, and is never written to disk.
POST /api/network/configure manages NetworkManager connections. On installed machines, connection keyfiles are persisted in LABKIOSK_DATA (/etc/labkiosk/system-connections/) and bind-mounted to /etc/NetworkManager/system-connections by a mount unit in the image (no /etc/fstab is written) so configurations persist across overlayroot="tmpfs" reboots.
→ Client Agent · Disk Installer
Known documentation drift
None currently tracked. docs/API.md was brought back in line with ALLOWED_COMMANDS in src/index.ts (lock, unlock, navigate, reload, reboot, shutdown, clear-session, mute); ALLOWED_COMMANDS and CommandAction in src/types.ts remain the authority.