Sonjoo local HTTP API features
The Sonjoo local HTTP API lets a shell script or another process on the same computer use the audit engine and dashboard history. Start it with sonjoo serve --no-open --port 7360 and use http://127.0.0.1:7360. --port 0 selects an available port. Read the actual port and the current X-Sonjoo-Token value from serve.json in the running process’s application home. Authentication · Runnable quickstart
Discover installed capabilities
Section titled “Discover installed capabilities”GET /api lists routes in the running build. GET /api/info reports the engine version, rule count, category IDs and weights, database path, uptime, and runtime capabilities such as Chromium rendering, image sizing, accessibility engine and code coverage. Use this response to check browser prerequisites before requesting a browser-dependent audit. Use the rule catalog or sonjoo explain --list to find individual rule IDs.
Submit, observe, and cancel an audit
Section titled “Submit, observe, and cancel an audit”POST /api/runs accepts an application/json body with an absolute HTTP(S) website URL, or urlList with newline-delimited text or CSV and optional listFormat. Website mode accepts a single page or a linked crawl. List mode audits the valid, distinct seeds as a bounded crawl, with at most 1,000 input rows. A CSV url header can identify the URL column; without it the first column is used. The response returns HTTP 202 and a runId for an accepted job. One dashboard server runs one audit at a time, returning HTTP 409 when another audit is active.
Start with {"url":"https://example.com/","save":false} and substitute an authorized target. Set crawl, maxPages, concurrency, timeout, maxDuration, and categories when you need narrower coverage or a time limit. The HTTP API uses default project settings plus request options. Its website crawl limits include maxPages 1–1,000 (default 10), concurrency 1–20 (default 3), timeout 1,000–120,000 milliseconds (default 30,000), and optional maxDuration 10–3,600 seconds for crawl collection. Start requests accept at most 2 MiB.
Use question for local entry-page passage matching. Request measureCwv for Chromium evidence. mobile or simulateInteraction can enable measurement when measureCwv is omitted. Their specialized profiles apply only to single-page audits. save defaults to true; set it to false for a retained result without creating a history entry. The API options reference covers all fields, including staging, refresh, and crawl-delay controls.
| Runtime operation | Route and result |
|---|---|
| Check the active run | GET /api/runs/current returns its state or {"run":null}. |
| Poll by run ID | GET /api/runs/:runId reads the current or most recent run. Inspect status for complete, error, or cancelled. |
| Stream progress | GET /api/events sends an initial snapshot, then state updates and periodic heartbeat events. The server allows eight simultaneous streams. Use polling if the client cannot consume a stream. |
| Cancel the active run | DELETE /api/runs/current requests cancellation and returns HTTP 202, or HTTP 204 when idle. |
| Read or save the retained result | GET /api/runs/:runId/result returns the report and metadata. POST /api/runs/:runId/save saves a retained unsaved result and returns its audit ID. |
A retained result is available for up to 15 minutes, until another run starts, or until the process exits. If saving fails, the completed result may still be retained and the run state can contain save-failed. Use a saved audit ID or an export when you need the result later. Runs and findings
Browse evidence, reports, and schedules
Section titled “Browse evidence, reports, and schedules”| Capability | Where to use it | What it returns |
|---|---|---|
| Saved report history | GET /api/audits, GET /api/audits/:id, DELETE /api/audits/:id |
List/filter audits, read one audit with grouped findings, or delete that audit and its stored data. |
| Per-URL evidence for one rule | GET /api/runs/:runId/rules/:ruleId/pages or GET /api/audits/:id/rules/:ruleId/pages |
Page through recorded outcomes per URL. Use status=issues for non-advisory warnings and failures. The MCP tool supports additional URL and status filters. |
| Report export | GET /api/runs/:runId/export or GET /api/audits/:id/export |
Choose format=html, markdown, json, or llm. |
| Crawl inventory | GET /api/runs/:runId/crawl or GET /api/audits/:id/crawl |
Inspect filtered crawl URLs or an individual URL, export urls or broken-inlinks CSV, and compare saved crawl inventories. Crawl data must be available in the reports. |
| Comparison and trends | GET /api/audits/:id/compare, GET /api/domains, GET /api/domains/:domain/trend |
Choose a baseline with against, summarize recent domain movement, or read a domain’s scores in chronological order. Check profile comparability before treating a change as a regression. |
| Local schedules | GET /api/schedules, POST /api/schedules, PATCH /api/schedules/:scheduleId |
List schedules and outcomes, schedule a saved website report every 24 or 168 hours, and pause, resume, or change the cadence. The server must be running for scheduled audits to start. |
Handle authentication and errors
Section titled “Handle authentication and errors”The API binds to loopback and validates the request host and browser origin. The dashboard uses a local session cookie; scripts should send the token header. Use a local process for API calls. The public documentation site cannot make cross-origin requests to the dashboard.
Read both the HTTP status and the JSON error.code. HTTP 401 indicates a token issue, 403 indicates the local request guard rejected the request, 404 can mean a run result has expired, and 409 can indicate a busy server or an existing schedule. Request IDs, pagination and option fields are validated. API routes and error codes
