﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>URL: /api

---
title: "Public API"
description: "The stable /v1 REST surface for external clients, agents, and MCP integrations"
icon: "braces"
---

squirrelscan exposes a stable, programmatic REST API under `/v1`. It's the
surface external clients, agent workflows, and MCP integrations can depend on.

<Info>
The machine-readable contract is published as an [OpenAPI 3.1 spec](/openapi.json).
Point your client generator, Postman, or an MCP server at it.
</Info>

## Base URL

```text
https://api.squirrelscan.com
```

## Authentication

Every request authenticates with a bearer token in the `Authorization` header:

```bash
curl https://api.squirrelscan.com/v1/credits \
  -H "Authorization: Bearer <token>"
```

Programmatic **API keys** are prefixed `sq_` and are the intended public auth
mechanism (rolling out, see the API-keys epic). Today the same scheme also
accepts CLI tokens (`sqcli_` prefix, issued by `squirrel auth login`) and
dashboard session JWTs, so you can start integrating immediately.

## Public surface

These are the external-client-facing routes covered by the contract:

| Resource | Endpoints |
|----------|-----------|
| **Audits** | `POST /v1/agent-runs`, `GET /v1/agent-runs`, `GET /v1/agent-runs/{id}`, `GET /v1/agent-runs/{id}/report` |
| **Reports** | `POST /v1/reports`, `GET /v1/reports`, `GET /v1/reports/{id}`, `PATCH /v1/reports/{id}`, `DELETE /v1/reports/{id}` |
| **Credits** | `GET /v1/credits` |
| **Organizations** | `GET /v1/organizations/{id}` |

<Note>
Internal server-to-server callbacks (`/v1/*/internal/*`), webhook receivers
(`/v1/webhooks`, `/v1/github`), and admin-only routes (`/v1/admin/*`,
`/v1/stats`, `/v1/users`) are **not** part of the public contract and may
change without notice.
</Note>

<Note>
The cloud services the CLI calls during an audit (`/v1/services/*`) are not
part of the public contract either. One of them, the dead-link check
(`/v1/services/dead-links`), bills each link it checks to the audit run it
belongs to. A call that names no run is billed to your org instead: 1 credit
per distinct link it verifies, and nothing for a link it cannot verify (see
[Credits and pricing](/cloud/credits)). The one exception is a `squirrel` CLI
from before v0.0.114: its run-less calls are refused with `426 RUN_REQUIRED`
and never charged. To check a site's links, run an audit
(`POST /v1/agent-runs`) with external link checks on, or a signed-in
`squirrel audit`.
</Note>

## Start a run with a rule filter

`POST /v1/agent-runs` takes the run's settings as a `config` object. This request audits one page and runs the `ax` rules plus `core/robots-meta`, minus the three cloud-backed `ai/` rules. It skips the headless browser and external link checks, and treats the site as a one-shot check:

```bash
curl -X POST https://api.squirrelscan.com/v1/agent-runs \
  -H "Authorization: Bearer $SQUIRREL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://nutshop.squirrelscan.com",
    "config": {
      "maxPages": 1,
      "enabledRulePatterns": ["ax/*", "core/robots-meta"],
      "disabledRulePatterns": ["ai/page-type-match", "ai/site-metadata", "ai/llm-parsability"],
      "render": false,
      "externalLinksEnabled": false,
      "ephemeral": true
    }
  }'
```

The response is `201` with the run `id`. Poll `GET /v1/agent-runs/{id}` until `status` is `completed`, then read `GET /v1/agent-runs/{id}/report`. `GET /v1/agent-runs/{id}` also carries `reportAvailability`, so a client does not have to guess from a missing report: `ready` (a report is stored for the run; not verified readable), `pending` (the run is still going, or it completed and its report is being finalized) or `none` (the run failed or was cancelled without writing a report, and none will come). With an API key `trigger` defaults to `api`; a signed-in session has to send it. `config` may also be sent as a JSON-encoded string, the older form.

### Two sets, like a lint config

`enabledRulePatterns` is the include set: only the rules it selects run. `disabledRulePatterns` is the disable set: the rules it names do not run. A run's rules are the include set minus the disable set, and **disable wins**: a rule named in both does not run. Leave `enabledRulePatterns` out to start from every rule. The website's own `disable_rules` are added to the disable set.

Both lists take the same patterns, with the same matching, limits and errors as the CLI's [`--rule-include` and `--rule-exclude`](/cli/audit): a category (`ax`), a category glob (`ax/*`) or an exact rule id (`core/robots-meta`). List ids with [`GET /v1/rules`](/api/rules/list): each rule carries `requiresCloud` (reads a cloud-backed step, credit-metered) and `requiresRender` (reads the render step, skipped with `render: false`), so a client can leave those out. At most 50 patterns of at most 100 characters each, using letters, digits and `-_./*`: no commas, spaces, regular expressions or control characters. Opt-in rules (`gaps/*`) cannot be selected.

<Warning>
`ax` includes three rules that kept the older `ai/` id prefix: `ai/llm-parsability`, `ai/page-type-match` and `ai/site-metadata`. They are the cloud-backed ones (the ai-parse and site-metadata services), so they are slower and credit-metered, and `ax/*` and `--rule-include ax` select them exactly as the CLI does. To leave them out, name their three exact ids in `disabledRulePatterns`, as in the example. Do not disable `ai/*`: `ai` is an alias of the whole `ax` category, so that glob switches off every `ax` rule.
</Warning>

| `config` key | What it does |
|--------------|--------------|
| `enabledRulePatterns` | The include set, above. Never empty. |
| `disabledRulePatterns` | The disable set, above. May be empty. |
| `render` | `false` fetches every page over plain HTTP with no per-page headless browser. `true` renders every page, within what the plan allows. Leave it out to follow the website's setting. Rendering does not change the price. |
| `externalLinksEnabled` | Check external links for this run. Each distinct link the cloud verifies costs 1 credit, so a one-page check that does not need them sends `false`. |
| `editorSummary` | Build the [editor's summary](/cloud/editor-summary), an LLM-written overview of the whole report that adds about 30 seconds to a run. Leave it out for the default: skipped when `enabledRulePatterns` is set (a filtered run), built on every other run. `true` builds it on a filtered run. `false` skips it on any run. No credit effect: the summary has no credit charge, built or skipped. |
| `ephemeral` | The same one-shot check as `ephemeral` on the MCP `run_audit`. If the run creates the website, that website skips the plan's website limit, stays out of website listings and is **archived** once the run ends. The run and its report are **not purged**, until a purge ships: `GET /v1/agent-runs/{id}` and the report keep working, and the run is hidden from `GET /v1/agent-runs` unless the request passes `includeOneOff=true`. A one-off run sends no email, creates no notification bell row, opens no tracker issue and fires no webhook. An organization can hold at most 5 live one-shot websites (`429`, code `EPHEMERAL_LIMIT`). If the organization already tracks the domain, or you send `websiteId`, the run uses that website, nothing is deleted, and the response has `ephemeral: false` with an `ephemeralIgnoredReason`. Cannot be combined with `auditId`. |
| `refresh` | `true` reuses no page stored by an earlier crawl: every page is fetched from the site. Default `false`. The same as `refresh` on the MCP `run_audit`. Use it when re-auditing right after a deploy. |
| `bypassCache` | `true` requests pages with `Cache-Control: no-cache` and `Pragma: no-cache`, so a CDN in front of the site revalidates with the origin. Default `false`. The same as `bypass_cache` on the MCP `run_audit`. It takes effect once the cloud audit worker is updated, coming soon. |

A request the API cannot honour as written is a `400` with code `VALIDATION_ERROR`, and nothing is charged or started: invalid JSON, a value that is not an object, an unknown `config` key, a wrongly typed `maxPages`, `coverageMode`, `externalLinksEnabled`, `render`, `editorSummary` or `ephemeral` (the issue path is `config.editorSummary` for the summary flag), or a bad rule list. For a rule list, `error.patterns` names the entries at fault: an unknown category, a pattern that matches no rule (`core/robots-metaa`), or a list over the limits. A selection that the disable set leaves with no rule to run is refused too. The other refusals use their own codes: `402` `INSUFFICIENT_CREDITS` (checked before a one-shot website is created), `429` `QUEUE_FULL` and `EPHEMERAL_LIMIT`, `404` `WEBSITE_NOT_FOUND`, `409` `AUDIT_ID_IN_USE`.

A request from an API key with an unknown top-level field is a `400` with code `VALIDATION_ERROR` that names the field in `error.issues[].path`, and nothing is started or charged. A typo such as `conifg` therefore fails instead of running a default audit. The top-level fields are `url`, `trigger`, `mode`, `model`, `config`, `websiteId` and `auditId`; `trigger` values such as `cli` and `github` are unchanged.

The create response carries `editorSummary` (boolean) and, when it is `false`, `editorSummarySkippedReason` (`rule-filtered run` or `disabled by the run config`). Both appear only when `enabledRulePatterns` or `editorSummary` was sent.

The config a run reports in `GET /v1/agent-runs/{id}` can be sent back: the keys the server writes into it (`auditLevel`, `pageLimitNotice`, `creditClamp`, `renderMode` and the like) are accepted and dropped. The report of a run started with `enabledRulePatterns` is **partial**: it carries `partial: true`, its `healthScore` and every category `score` are `null` (a score from a subset of the rules is not the site's score), and a sibling `includeFilter` says which rules ran (the patterns and how many). The counts and `topIssues` still cover the rules that ran. The run itself says the same: `GET /v1/agent-runs/{id}` and `GET /v1/agent-runs` return `healthScore: null` and `partial: true` for such a run (the key is absent otherwise), and its row in the report's `history` has no score. A run with no `enabledRulePatterns`, or with only `disabledRulePatterns`, is unchanged.

A partial report also carries `results`: one entry for every rule the run selected, so a rule that passed is told apart from one that did not run (`topIssues` lists only warnings and failures, as text). Each entry has the `ruleId`, `category`, `name` and `severity`, a `status` (`pass`, `warn`, `fail`, `info`, `skipped` or `not_applicable`), a `skipReason` for the last two, and an `evidence` object:

```json
{
  "ruleId": "ax/ai-crawlers",
  "category": "ax",
  "name": "AI Crawler Access",
  "severity": "warning",
  "status": "info",
  "evidence": {
    "checks": { "pass": 0, "warn": 0, "fail": 0, "info": 1, "skipped": 0 },
    "occurrences": 0,
    "affectedPages": 0,
    "checkNames": ["ai-crawler-access"],
    "bots": [
      { "token": "OAI-SearchBot", "verdict": "allowed", "source": "robots_txt" },
      { "token": "GPTBot", "verdict": "blocked", "crawlerClass": "training", "source": "robots_txt" }
    ]
  }
}
```

`info` is an informational finding, neither a pass nor a problem. A rule the run selected but the stored report has no result for is `skipped` with `skipReason: "not_reported"`: it is never reported as `pass`. `skipReason` is one of a fixed set, for example `render_disabled` (a run with `render: false`), `not_authenticated` and `insufficient_credits` (a cloud step that could not run), `external_links_not_checked` and `not_applicable`. `evidence` holds counts and short tokens the rule itself wrote (check ids, and for `ax/ai-crawlers` each AI crawler's user-agent token with its verdict), and never a message, URL or label taken from the audited site, so an agent can read it without passing the site's own words through. The key is absent for a run with no `enabledRulePatterns`. A run with no `enabledRulePatterns` is unchanged: no `partial` key, scores as before. The hosted MCP `get_report` returns the same `partial` flag and null scores, and prints the score as N/A in its `llm` and `markdown` formats.

### Opt in to the editor's summary

A filtered run skips the editor's summary by default, so the one-page request above needs no flag. To get it back, send `editorSummary: true`:

```json
{
  "url": "https://nutshop.squirrelscan.com",
  "config": {
    "maxPages": 1,
    "enabledRulePatterns": ["ax/*", "core/robots-meta"],
    "render": false,
    "ephemeral": true,
    "editorSummary": true
  }
}
```

A skipped summary is absent from `GET /v1/agent-runs/{id}/report` (the `editorSummary` field is not there, not `null`). With `editorSummary: true` it is present as on any other run.

### Speed of a filtered run

A one-page filtered run skips the work no selected rule reads: the editor's summary, the external link check (when no selected rule reads link results: `links/dead-links`, `links/broken-external-links`, `reliability/broken-forms`, `integrity/known-malicious-url`) and any cloud service no selected rule reads. Skipped steps are recorded in the run timeline, below. How long a run takes still depends on the site, so treat any timing as an estimate.

### Run timeline and skipped steps

While a run is `queued`, `pending` or `running`, `GET /v1/agent-runs/{id}` returns its latest `progress` event (`phase`, a message and a page count). A step the run skips is recorded as a single `skipped` event with a reason and no duration, for example `editor_summary skipped: rule-filtered run`. The phase names a polling client may see for skipped steps are:

| Phase | Reasons |
|-------|---------|
| `editor_summary` | `rule-filtered run`, `disabled by the run config` |
| `cloud_prefetch` | `no enabled rule reads a cloud service` |
| `external_links` | `no enabled rule reads external link results` |
| `render_prefetch` | `render disabled by the run config`, `the crawl rendered every page` (filtered runs only) |

The set of phase names is not a stable enum: match on the ones you know and ignore the rest. An API key sees only the latest phase through `progress`. The full event list is a signed-in view in the [dashboard](/dashboard). Skipping a step never changes the price of the steps that ran, and nothing is charged or refunded for a skipped one.

<Note>
The hosted MCP `run_audit` takes the same two sets as `rules` and `disable_rules`, with the same validation and the same errors, plus `editor_summary` for `config.editorSummary`. See [MCP](/developers/mcp).
</Note>

## Queued runs

When the audit containers are busy, or your organization is already running its plan's limit of audits at once, `POST /v1/agent-runs` still answers `201`, with `status` `queued` instead of `pending` and a `queue` object:

```json
{
  "id": "01J...",
  "status": "queued",
  "createdAt": "2026-11-16T09:00:00.000Z",
  "queue": {
    "position": 2,
    "etaMinutes": 4,
    "reason": "capacity",
    "message": "..."
  }
}
```

A queued run starts by itself, so there is nothing to retry and nothing more to charge. Poll `GET /v1/agent-runs/{id}`: while the status is `queued` the same `queue` object says where the run stands, and it moves to `pending` and then `running` when a slot frees.

- `position`: your place in line, `1` is next. `null` when it could not be read.
- `etaMinutes`: estimated minutes until the run starts, or `null` when there is no estimate.
- `reason`: `capacity` when the containers are busy, `org_limit` when your organization is at its plan's limit of audits running at once.
- `message`: a sentence for a person. It may change, so do not match on it.

A run that waits more than 60 minutes is stopped and fully refunded; run it again. Only audits you start yourself wait in line. Scheduled audits queue behind them and are skipped, and refunded, if they wait more than 6 hours.

### Waiting limits per plan

Each plan caps how many audits run at once and how many may wait:

| Plan | Running at once | Waiting |
|------|-----------------|---------|
| Free | 1 | 3 |
| Pro | 3 | 10 |
| Team | 5 | 20 |
| Enterprise | 10 | 50 |

Enterprise figures are the default a contract starts from. Scheduled audits do not count toward the waiting limit.

### When the waiting line is full

A request made while you already have the maximum number of audits waiting is refused with `429` and code `QUEUE_FULL`, before anything is charged:

```json
{
  "error": {
    "code": "QUEUE_FULL",
    "message": "You already have 3 audits waiting to start. Nothing was charged for this one. Wait for one of them to start, or cancel one from your runs list, then try again.",
    "queued": 3,
    "maxQueued": 3
  }
}
```

`error.queued` is how many of your audits are waiting and `error.maxQueued` is the limit for your plan. Wait for a queued run to start, or cancel one, then send the request again. Unlike the per-key rate limit, this `429` uses the typed envelope and carries no `Retry-After`.

## Error envelope

All errors use one stable, typed shape:

```json
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Report not found",
    "requestId": "8a1f…"
  }
}
```

- `code`: stable, machine-readable (`SCREAMING_SNAKE_CASE`). Match on this.
  Treat unknown codes as opaque and fall back to `message`.
- `message`: human-readable; may change. Don't match on it.
- `requestId`: present when available; quote it to support for log lookups.

Common codes: `UNAUTHORIZED`, `FORBIDDEN`, `NO_ORG`, `NOT_FOUND`,
`VALIDATION_ERROR`, `INVALID_JSON`, `PAYLOAD_TOO_LARGE`, `SECURITY_VIOLATION`,
`INSUFFICIENT_CREDITS` (with `error.required` / `error.balance`),
`DUPLICATE_REQUEST`, `RUN_NOT_ACTIVE`, `UPSTREAM_ERROR` (with `error.reason`),
`QUEUE_FULL`, `EPHEMERAL_LIMIT`.

`SECURITY_VIOLATION` (`400`) is returned by `POST /v1/reports` when the report
payload trips the content security scanner; `error.threats` lists the matched
patterns.

### Publish body limit

`POST /v1/reports` accepts a request body of up to **1 MiB** (1,048,576 bytes). A body over the limit is refused before it is parsed. The squirrel CLI caps its own report to fit, from version 0.0.109. Other clients should keep the report under the limit.

Until 2026-11-12 (UTC), every client that does not cap its own report was allowed up to 2 MiB: CLIs older than 0.0.109, API-key integrations, curl, and requests with no User-Agent. That allowance has ended: every client now gets the 1 MiB limit. The version floor stays, so a CLI older than 0.0.109 that sends an oversized report gets the `422` below.

A body over the limit gets `413` with the code `PAYLOAD_TOO_LARGE`. `error.details.budgetBytes` is the limit, and `error.details.bodyBytes` is the declared `Content-Length` (absent when the body had no declared length):

```json
{
  "error": {
    "code": "PAYLOAD_TOO_LARGE",
    "message": "Report body (1.3 MB) is over the 1 MB publish limit, so it was not published.",
    "details": { "budgetBytes": 1048576, "bodyBytes": 1363149 }
  }
}
```

A squirrel CLI older than 0.0.109 gets `422` instead, with the same code, so that it prints the message. `error.details.updateCommand` is `squirrel self update`:

```json
{
  "error": {
    "code": "PAYLOAD_TOO_LARGE",
    "message": "This report (3 MB) is over the 1 MB publish limit for squirrel 0.0.108, so it was not published. Your audit is saved locally: view it with `squirrel report`. Run `squirrel self update` (newer versions fit large reports under the limit), then publish it with `squirrel report --publish`.",
    "details": { "budgetBytes": 1048576, "bodyBytes": 3145728, "updateCommand": "squirrel self update" }
  }
}
```

<Note>
The shared auth middleware, the org gate, and the credit gate (`402`
`INSUFFICIENT_CREDITS`, `409` `DUPLICATE_REQUEST`, `409` `RUN_NOT_ACTIVE`) now
emit the typed envelope like every other documented route. Branch on the HTTP
status code, then split same-status conditions on `error.code`, not the human
`message`: a `409` is either `DUPLICATE_REQUEST` (this exact payload was already
charged) or `RUN_NOT_ACTIVE` (a cloud run was reaped or failed before the charge
landed, so it was never charged).
</Note>

`5xx` responses from unhandled server errors (DB/storage failures not caught by
a handler) are **not guaranteed** to follow the envelope: handle them by status
code and retry idempotent reads with backoff.

## Rate limiting

The hosted API limits how fast a caller can send requests to the endpoints that start or publish work. The metered endpoints below are the documented ones; read endpoints are not metered by this limiter.

| Endpoint | Limited |
|----------|---------|
| `POST /v1/agent-runs` | Yes |
| `POST /v1/reports` | Yes |
| `GET /v1/agent-runs`, `GET /v1/agent-runs/{id}`, `GET /v1/agent-runs/{id}/report` | No |
| `GET /v1/reports` and the other report, rules, credits and organization reads | No |

The budget is counted per API key, in a fixed one-minute window, and it is one shared budget for every limited endpoint the key calls. The hosted MCP server counts against the same budget when you call it with the same key, and so do the other run endpoints an API key can reach in CI (`POST /v1/agent-runs/org/register` and `PATCH /v1/agent-runs/org/{id}`, which the CLI uses). A request counts once it has passed authentication and the scope check, so a request the API rejects afterwards (a `400` for a bad body, a `402` for credits) still uses one request from the window.

| Plan of the key's organization | Requests per minute per key |
|--------------------------------|-----------------------------|
| Free | 60 |
| Starter | 300 |
| Team | 300 |
| Enterprise | 300 |

Enterprise gets the same budget as Starter and Team: being unmetered for credits does not change the request limit. These are the current values and they can change, so read the headers rather than hard-coding the number.

Per API key applies to API-key auth. A caller that signs in with the CLI login, a session or OAuth is counted per organization with the same plan budgets, and an unauthenticated request is counted per IP address at 30 requests per minute.

Every response from a limited endpoint carries the window state once authentication has succeeded (a `401` or `403` has none), not only the `429`. The REST API does not expose these headers to browsers across origins, so they are for server-side clients:

| Header | Meaning |
|--------|---------|
| `RateLimit-Limit` | Request budget for the window |
| `RateLimit-Remaining` | Requests left in the window |
| `RateLimit-Reset` | Seconds until the window resets |

A request over the budget gets `429 Too Many Requests` with the same headers plus `Retry-After` (seconds to wait). The body is a plain string, not the typed error envelope above:

```json
{ "error": "Rate limit exceeded. Slow down and retry shortly." }
```

Back off for `Retry-After` seconds, then retry. The counter is approximate: it is held in memory per key and can reset early, so do not rely on it as a guarantee of when you will be throttled.

If the limiter itself fails, the request gets a `500` (a `503` on the MCP server): retry with backoff.

Other `429` responses on `POST /v1/agent-runs` are not this limit. They use the typed envelope and say why: `QUEUE_FULL`, `EPHEMERAL_LIMIT` and `HOST_RATE_LIMITED` (the audited host's own crawl limit for a website whose ownership is not confirmed, with its own `Retry-After`; see [Website ownership confirmation](/cloud/ownership-confirmation)).

## Credits

Cloud operations (publishing reports, cloud audits) are priced in
[credits](/cloud/credits). When an organization runs out, the API returns
`402` with `code: "INSUFFICIENT_CREDITS"`.

## Next

<CardGroup cols={2}>
  <Card title="Create an audit" icon="play" href="/api/audits/create">
    Kick off a cloud audit run
  </Card>
  <Card title="Get a report" icon="file-text" href="/api/reports/get">
    Read published report metadata
  </Card>
  <Card title="Credit balance" icon="coins" href="/api/credits/get"