# HTTP /control API Reference `/control` and `/events` are compiled only into `USE_CONTROL` builds (default on — see [Building](Building.md)). They live in `src/control.c` (JSON parsing/serialization + apply logic) and `src/events.c` (notification plumbing), wired into the HTTP server in `src/mp4/httpd.c`. No JSON library is used — both request parsing and response building are hand-rolled targeted scanning, consistent with the rest of the codebase's minimal-dependency philosophy. ## Authentication and access control `/control`, `/events`, and the HTTP media endpoints (`/stream.mp4`, `/stream.mjpeg`, `/snapshot.jpg`, including their `?chn=N` forms) share one access-control gate (`http_check_auth`/`http_check_token` in `httpd.c`). A request is allowed if **any one** of the following holds; otherwise it gets `401`/`403`: 1. **Loopback bypass** — the peer address is `127.0.0.0/8`. This is what lets an on-device WebUI always reach the streamer without a password; it replaces prudynt's separate "web UI auth key" mechanism. 2. **A valid token** — either the random **per-boot token** (`g_ctl_token`, generated at every `timpsd` start and published to `http.token_file`, default `/run/timps.token`, mode 0640, for local privileged readers like the thingino WebUI) or the optional persistent **`http.token`** config secret (for remote automation; this one is *never* written to the token file). Sent as an `X-Timps-Token: ` header (preferred) or `?token=` query parameter — the query form exists because ``/`