Read audit runs, findings, and coverage
A run tracks one execution. Its runId is available as soon as the server accepts the request. A saved report gets a separate auditId for history and exports.
Follow a run to completion
Section titled “Follow a run to completion”- Send
POST /api/runs. HTTP202accepts the run and suppliesrunId. TheLocationheader points to/api/runs/current. - Poll
GET /api/runs/:runIdwhilestatusisrunning. Give the polling loop a deadline. - When
statusiscomplete, fetchGET /api/runs/:runId/result. Forcancelledorerror, stop polling and inspect the returned state. - If the state includes
auditId, it can be used for a durable lookup atGET /api/audits/:id.
Sonjoo runs one audit at a time. A second start request returns HTTP 409 while a run is active. DELETE /api/runs/current requests cancellation. The run status records when cancellation completes.
Read findings and URL evidence
Section titled “Read findings and URL evidence”The result response contains a result object. Under result.categoryResults[].results[], look for a rule’s ruleId, status, message, and any details available. For an example with a single missing title, see the quickstart’s expected evidence.
Crawl views aggregate results by rule and include a bounded samplePages array. Query /api/audits/:id/rules/:ruleId/pages for per-URL evidence on a saved report, including unmeasured rows. Use /api/runs/:runId/rules/:ruleId/pages for the retained result. Paginate to collect the full returned inventory.
Check result.completionState, result.coverage, and result.ruleCoverage before drawing conclusions. A complete run can contain partial measurement, warnings, or failed rules. If saving fails, the run can complete with a retained report and a save-failed status in state.error.code. The result view provides its own measurement coverage.
Retain, export, and compare
Section titled “Retain, export, and compare”API audits save by default. Use save: false for a temporary result. The current or most recent result can be retrieved for up to 15 minutes or until another run starts. Use the saved audit ID when an integration needs a durable result.
- Export with
GET /api/audits/:id/export?format=jsonfor a saved report envelope, orGET /api/runs/:runId/export?format=jsonfor the retained report itself. The retained download usesapplication/octet-streameven when its body is JSON. Both export routes default to HTML and also acceptmarkdownandllm. - Use
POST /api/runs/:runId/saveto save an available unsaved result. Capture the returnedauditId. - Use
GET /api/audits/:id/compare?against=<id>for a saved report comparison. Omitagainstto use the prior audit chosen by Sonjoo. - Use the
crawlroutes for a crawl’s URL inventory, filters, link views, and CSV output. The route reference lists both forms. DELETE /api/audits/:idremoves the saved history item. If its run is still retained, the report can remain available temporarily through that run ID.
Stream progress
Section titled “Stream progress”GET /api/events opens an authenticated server-sent event stream. It sends an initial snapshot, then state updates and periodic heartbeat events. The server allows up to eight simultaneous streams. Polling by runId works well for terminal scripts and CI.
