﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>{
  "openapi": "3.1.0",
  "info": {
    "title": "squirrelscan Public API",
    "version": "1.0.0",
    "summary": "Programmatic website-audit API for external clients, agents, and MCP integrations.",
    "description": "The public `/v1` REST surface of squirrelscan.\n\nThis document covers the **external-client-facing** routes only — internal\nserver-to-server callbacks (`/v1/*/internal/*`), webhook receivers\n(`/v1/webhooks`, `/v1/github`), and admin-only routes (`/v1/admin/*`,\n`/v1/stats`, `/v1/users`) are intentionally out of scope and NOT part of the\npublic contract.\n\nAll error responses use a stable typed envelope:\n`{ \"error\": { \"code\": string, \"message\": string, \"requestId\"?: string } }`.\n\nAuthentication is via a bearer token in the `Authorization` header.\nOrganization API keys with an `sq_` prefix (`sq_dev_` in development) are the\nprimary mechanism for automated clients and agents; set one as the\n`SQUIRRELSCAN_API_KEY` environment variable and the CLI and this REST API both\npick it up. CLI login tokens (`sqcli_`) and Clerk dashboard JWTs are also\naccepted. MCP clients can reach these same audit tools over the hosted MCP\nserver at https://mcp.squirrelscan.com/mcp.",
    "contact": {
      "name": "squirrelscan support",
      "url": "https://squirrelscan.com"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://api.squirrelscan.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Audits",
      "description": "Create and track cloud audit runs (`agent_runs`)."
    },
    {
      "name": "Reports",
      "description": "Publish, list, and manage audit reports."
    },
    {
      "name": "Rules",
      "description": "The audit rule catalogue, for building `enabledRulePatterns` and `disabledRulePatterns`."
    },
    {
      "name": "Credits",
      "description": "Read the active organization's credit balance and pricing."
    },
    {
      "name": "Organizations",
      "description": "Read organization details and membership."
    }
  ],
  "paths": {
    "/v1/agent-runs": {
      "post": {
        "tags": ["Audits"],
        "summary": "Create an audit run",
        "description": "Start a new cloud audit run. Send a `url` and, optionally, a `config` object (for example `{\"maxPages\":1,\"enabledRulePatterns\":[\"ax/*\",\"core/robots-meta\"],\"disabledRulePatterns\":[\"ai/page-type-match\",\"ai/site-metadata\",\"ai/llm-parsability\"],\"render\":false,\"externalLinksEnabled\":false,\"ephemeral\":true}`). With an API key the run is dispatched to the cloud crawler immediately (`trigger` defaults to `api`) and progresses asynchronously; poll `GET /v1/agent-runs/{id}` for status. Cloud features are credit-gated. If the requested page count exceeds the org's plan ceiling, the run still starts at the plan's max (clamp, never a hard error) and the response carries a `notice` field (`type: \"page_limit_clamped\"`) saying so. A request the API cannot honour as written (an unknown `config` key, a rule pattern that matches nothing, a selection that leaves no rule to run) is a 400 `VALIDATION_ERROR` and nothing is charged or started.",
        "operationId": "createAuditRun",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CreateAuditRunRequest" }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Run created (status `pending`, or `queued` with a `queue` object when the run is waiting for a container slot).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CreateAuditRunResponse" }
              }
            }
          },
          "400": {
            "description": "Request failed validation, or an unknown top-level request field (API-key callers: a typo such as `conifg` is named in `error.issues[].path` instead of being dropped, and nothing is started or charged), or a `config` the API cannot honour: invalid JSON, a non-object, an unknown key, a wrongly typed `maxPages`, `coverageMode`, `externalLinksEnabled`, `render` or `ephemeral`, a bad `enabledRulePatterns` or `disabledRulePatterns` (unknown category, a pattern that matches no rule, over the caps; `error.patterns` lists the entries at fault), a rule selection the disable list leaves empty, `auditId` sent with `config.ephemeral`, or a session caller omitting `trigger`. Also `INVALID_URL` and `NON_PUBLIC_HOST` for a URL that cannot be audited. `error.issues` lists up to 10 failed fields (`{ path, message }`); `error.truncated: true` and `error.totalIssues` give the full count.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "error": {
                    "code": "VALIDATION_ERROR",
                    "message": "Request failed validation",
                    "patterns": ["core/robots-metaa"],
                    "issues": [
                      {
                        "path": "config.enabledRulePatterns",
                        "message": "enabledRulePatterns has entries that match no rule: core/robots-metaa. A pattern is a category (ax), a category glob (ax/*) or an exact rule id (core/robots-meta), as listed by GET /v1/rules."
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": {
            "description": "Not enough credits for the audit base (`INSUFFICIENT_CREDITS`, with `error.required`, `error.balance` and, when an upgrade is on offer, `error.upgrade`), a per-audit credit cap smaller than a one-page audit (`CAP_EXCEEDED`), or a website limit reached (`WEBSITE_LIMIT`). Nothing is started.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "error": {
                    "code": "INSUFFICIENT_CREDITS",
                    "message": "Insufficient credits for the audit base",
                    "required": 52,
                    "balance": { "total": 10 }
                  }
                }
              }
            }
          },
          "403": {
            "description": "No active organization (`NO_ORG`), the organization is locked (`ORG_LOCKED`), or the credential may not run audits here (`FORBIDDEN`).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": { "code": "NO_ORG", "message": "No active organization" } }
              }
            }
          },
          "404": {
            "description": "`websiteId` names no website the caller can use (`WEBSITE_NOT_FOUND`).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": { "code": "WEBSITE_NOT_FOUND", "message": "Website not found" } }
              }
            }
          },
          "409": {
            "description": "`auditId` already names an audit on this website (`AUDIT_ID_IN_USE`).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "error": {
                    "code": "AUDIT_ID_IN_USE",
                    "message": "auditId already exists on this website. Omit it to have one generated."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (the per-key request budget: a plain `{ \"error\": \"...\" }` string body with `RateLimit-*` and `Retry-After` headers, see Rate limiting), the organization's audit queue is full (`QUEUE_FULL`, with `error.queued` and `error.maxQueued`), the target host is at its crawl limit (`HOST_RATE_LIMITED`, with `Retry-After`), or the organization already holds the maximum live one-shot websites for `config.ephemeral` (`EPHEMERAL_LIMIT`, with `error.active` and `error.limit`). Nothing is charged.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "error": {
                    "code": "EPHEMERAL_LIMIT",
                    "message": "This organization already has 5 one-shot audits in flight (the limit is 5). Wait for them to finish, or audit a website the organization tracks.",
                    "active": 5,
                    "limit": 5
                  }
                }
              }
            }
          },
          "502": {
            "description": "Failed to dispatch the cloud audit (upstream crawler/sandbox unavailable). Typed envelope with code `UPSTREAM_ERROR`; the upstream cause is carried under `error.reason`.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    { "$ref": "#/components/schemas/Error" },
                    {
                      "type": "object",
                      "properties": {
                        "error": {
                          "type": "object",
                          "properties": {
                            "reason": { "type": "string", "description": "Upstream cause (sandbox/crawler)." }
                          }
                        }
                      }
                    }
                  ]
                },
                "example": {
                  "error": {
                    "code": "UPSTREAM_ERROR",
                    "message": "Failed to start cloud audit",
                    "reason": "Sandbox worker is not configured"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": ["Audits"],
        "summary": "List audit runs",
        "description": "List the authenticated user's audit runs, newest first.",
        "operationId": "listAuditRuns",
        "parameters": [
          { "$ref": "#/components/parameters/Limit" },
          { "$ref": "#/components/parameters/Offset" },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": { "$ref": "#/components/schemas/AuditRunStatus" }
          },
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": { "$ref": "#/components/schemas/AuditRunMode" }
          },
          {
            "name": "websiteId",
            "in": "query",
            "required": false,
            "schema": { "type": "string" }
          },
          {
            "name": "includeOneOff",
            "in": "query",
            "required": false,
            "description": "One-off (`ephemeral`) runs are hidden from this list by default. Pass `true` (or `1`) to include them.",
            "schema": { "type": "string", "enum": ["true", "false", "1", "0"] }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of audit runs.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuditRunList" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/agent-runs/{id}": {
      "get": {
        "tags": ["Audits"],
        "summary": "Get an audit run",
        "description": "Fetch full detail for a single audit run owned by the authenticated user. While `status` is `queued`/`pending`/`running`, `progress` carries the latest phase/page-count event streamed by the run, when one has been recorded. `notice` carries a `page_limit_clamped` signal when the run's requested page count was clamped down to the org's plan ceiling at dispatch time (never a hard error — the run itself still completed normally). `renderFallback` carries a `render_fallback` signal, with the page count, when pages that asked for rendering were audited from their unrendered source instead.",
        "operationId": "getAuditRun",
        "parameters": [{ "$ref": "#/components/parameters/RunId" }],
        "responses": {
          "200": {
            "description": "The audit run.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuditRun" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/agent-runs/{id}/report": {
      "get": {
        "tags": ["Audits"],
        "summary": "Get an audit run's report",
        "description": "Fetch the summarized report data for a completed run.\n\n**Polling pattern:** this endpoint returns `404` both when the run/report does not exist AND while a valid run's report is not generated yet. To distinguish the two, poll `GET /v1/agent-runs/{id}` and wait for `status: \"completed\"` before fetching the report — that is the canonical way to track progress. As a convenience, the \"not ready yet\" 404 additionally carries the run's current status under `error.runStatus` (e.g. `{ \"error\": { \"code\": \"NOT_FOUND\", \"message\": \"Report not available yet\", \"runStatus\": \"running\" } }`), so a client can keep polling this endpoint alone if it prefers. **Footgun:** only keep polling while `error.runStatus` is a non-terminal state (`queued`/`pending`/`running`); a `404` with `error.runStatus: \"completed\"` (or `\"failed\"`/`\"cancelled\"`, or a `404` with NO `error.runStatus` at all) means the report is genuinely missing/unavailable — stop polling.",
        "operationId": "getAuditRunReport",
        "parameters": [{ "$ref": "#/components/parameters/RunId" }],
        "responses": {
          "200": {
            "description": "Report summary + scored issues for the run.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuditRunReport" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": {
            "description": "Run or report not found, OR the run's report is not generated yet. When not-ready, `error.runStatus` holds the run's current status (`queued`/`pending`/`running`/...); keep polling.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "examples": {
                  "notReady": {
                    "summary": "Report not generated yet (keep polling)",
                    "value": { "error": { "code": "NOT_FOUND", "message": "Report not available yet", "runStatus": "running" } }
                  },
                  "notFound": {
                    "summary": "Run or report does not exist",
                    "value": { "error": { "code": "NOT_FOUND", "message": "Run not found" } }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/websites/{websiteId}/audits/compare": {
      "get": {
        "tags": ["Audits"],
        "summary": "Compare two audits of a website, and gate a CI job on new findings",
        "description": "What changed between two completed audits of one website: findings that are `new`, `resolved`, `worsened`, `improved`, `unchanged`, `still_open`, `not_crawled` or `not_checked`. Without `head` and `base` it compares the website's latest completed audit with the one before it. A finding on a page the newer audit did not crawl (`not_crawled`) or from a rule it did not run (`not_checked`) is neither new nor resolved; `totals` counts them, and `resolutionEvidence` says what backs the `resolved` verdicts (`none` means nothing is reported as fixed). `totals` and `newBySeverity` count every finding; `findings` is clipped by `limit`.\n\n**CI gate.** Pass `fail_on` and the response carries `gate`: `status` is `fail` when the newer audit has findings at or above that severity that the previous completed audit did not have, `pass` when it has none, `no_baseline` for the first audit of a website (it passes), and `not_evaluated` when the comparison cannot say (the audit ended `failed` or `blocked`, or a report exceeded the comparison's finding cap). Resolved findings are counted in `gate.resolved` and never fail it, and `gate.notCompared` says how many older findings the newer audit could not judge. A CI job starts the audit with `POST /v1/agent-runs` (send `websiteId`), polls `GET /v1/agent-runs/{id}` until `completed`, then calls this endpoint with `head` set to that run id and exits non-zero on `gate.status: \"fail\"`. Requires the `audits:read` scope.",
        "operationId": "compareWebsiteAudits",
        "parameters": [
          {
            "name": "websiteId",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "The website id (`websiteId` on an audit run)."
          },
          {
            "name": "head",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "The newer run id. Default: the website's latest completed run with a report."
          },
          {
            "name": "base",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "The older run id. Default: the completed run immediately before `head`."
          },
          {
            "name": "fail_on",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "enum": ["error", "warning", "info"] },
            "description": "Evaluate the CI gate at this severity: `error` fails on new errors only, `warning` on new errors and warnings, `info` on any new finding. Adds `gate` to the response."
          },
          {
            "name": "include",
            "in": "query",
            "required": false,
            "schema": { "type": "string" },
            "description": "Comma-separated extra kinds to list in `findings`: `unchanged`, `still_open`, `not_crawled`, `not_checked`. New, worsened, resolved and improved are always listed."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": { "type": "integer", "minimum": 1, "maximum": 500 },
            "description": "Most rows in `findings` (default 100). `totals`, `newBySeverity` and `gate` are never clipped."
          }
        ],
        "responses": {
          "200": {
            "description": "The comparison, and the gate when `fail_on` was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["comparison"],
                  "properties": {
                    "comparison": { "$ref": "#/components/schemas/AuditComparison" },
                    "gate": { "$ref": "#/components/schemas/CompareGate" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/ValidationError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/reports": {
      "post": {
        "tags": ["Reports"],
        "summary": "Publish a report",
        "description": "Publish an audit report. The report payload is the full `AuditReport` produced by the CLI/engine. Visibility defaults to `private`. **Publishing is included in the audit's base charge**; no visibility carries a separate credit charge. `unlisted` and `private` publishes always create a new report (no idempotency). Org-scoped `public` publishes are keyed on the publisher + a content hash: republishing the identical payload is an idempotent replay, returning the original report with `200` if the prior response was cached, or `409` otherwise (still in flight / not cached). **The request body is limited to 1 MiB** (see the `413` and `422` responses); the squirrel CLI caps its own report to fit from 0.0.109.",
        "operationId": "publishReport",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PublishReportRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay of an identical org-scoped `public` publish whose original response was cached — returns the originally published report.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PublishedReport" }
              }
            }
          },
          "201": {
            "description": "Report published.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PublishedReport" }
              }
            }
          },
          "400": {
            "description": "The body failed validation (`VALIDATION_ERROR`, with `error.issues`), was not valid JSON (`INVALID_JSON`), or tripped the content security scanner (`SECURITY_VIOLATION`, with `error.threats`).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "examples": {
                  "validation": {
                    "summary": "Schema validation failed",
                    "value": { "error": { "code": "VALIDATION_ERROR", "message": "Report failed validation", "issues": [{ "path": "report.baseUrl", "message": "Invalid url" }] } }
                  },
                  "security": {
                    "summary": "Payload tripped the security scanner",
                    "value": { "error": { "code": "SECURITY_VIOLATION", "message": "Report contains potentially malicious content", "threats": ["<script>"] } }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/InsufficientCredits" },
          "409": { "$ref": "#/components/responses/DuplicateRequest" },
          "413": {
            "description": "The request body is over the 1 MiB (1,048,576 bytes) publish limit. The body is refused before it is parsed. `error.details.budgetBytes` is the limit and `error.details.bodyBytes` the declared `Content-Length` (absent when the body had no declared length).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "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 }
                  }
                }
              }
            }
          },
          "422": {
            "description": "The body is over the 1 MiB publish limit and the caller is a squirrel CLI older than 0.0.109, which does not cap its own report. The code is still `PAYLOAD_TOO_LARGE`; the status is 422 so those CLIs print the message instead of a fixed 413 text. `error.details.updateCommand` is `squirrel self update`.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "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" }
                  }
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      },
      "get": {
        "tags": ["Reports"],
        "summary": "List reports",
        "description": "List the authenticated user's published reports, newest first.",
        "operationId": "listReports",
        "parameters": [
          { "$ref": "#/components/parameters/Limit" },
          { "$ref": "#/components/parameters/Offset" }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of reports.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ReportList" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/reports/{id}": {
      "get": {
        "tags": ["Reports"],
        "summary": "Get a report",
        "description": "Fetch report metadata. Public and unlisted reports are readable without auth; private reports require a bearer token belonging to the owner (a non-owner gets 404, never revealing existence).",
        "operationId": "getReport",
        "security": [{ "bearerAuth": [] }, {}],
        "parameters": [{ "$ref": "#/components/parameters/ReportId" }],
        "responses": {
          "200": {
            "description": "Report metadata.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Report" }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      },
      "patch": {
        "tags": ["Reports"],
        "summary": "Update report visibility",
        "description": "Change a report's visibility. Owner only: a non-owner (or unauthenticated request) gets 404, never revealing the report's existence. Visibility changes carry no separate credit charge; publishing is included in the audit's base charge.",
        "operationId": "updateReportVisibility",
        "parameters": [{ "$ref": "#/components/parameters/ReportId" }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["visibility"],
                "properties": {
                  "visibility": { "$ref": "#/components/schemas/Visibility" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated visibility.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["id", "visibility", "url"],
                  "properties": {
                    "id": { "type": "string" },
                    "visibility": { "$ref": "#/components/schemas/Visibility" },
                    "url": { "type": "string", "format": "uri" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/ValidationError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "402": { "$ref": "#/components/responses/InsufficientCredits" },
          "404": {
            "description": "Report not found / not owned by the caller, OR — only when flipping to `public` — the report's stored content is missing from R2. Both use the typed envelope with code `NOT_FOUND`; branch on the 404 status.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "examples": {
                  "notFound": {
                    "summary": "Report not found or not owned",
                    "value": { "error": { "code": "NOT_FOUND", "message": "Report not found" } }
                  },
                  "contentMissing": {
                    "summary": "R2 content missing",
                    "value": { "error": { "code": "NOT_FOUND", "message": "Report content not found" } }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Reports"],
        "summary": "Delete a report",
        "description": "Soft-delete a report. Owner only.",
        "operationId": "deleteReport",
        "parameters": [{ "$ref": "#/components/parameters/ReportId" }],
        "responses": {
          "200": {
            "description": "Report deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success"],
                  "properties": { "success": { "type": "boolean", "const": true } }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/reports/{id}/entities": {
      "get": {
        "tags": ["Reports"],
        "summary": "Get the report's entity map",
        "description": "The graph of things the audited site declares in JSON-LD (Organization, Person, Product, Article, …), collapsed across every crawled page, with the references between them.\n\nFilters apply BEFORE rendering, so `?type=Organization&format=markdown` renders a markdown document of Organizations rather than filtering a rendered string. `summary` always describes the WHOLE site even when a filter is applied; compare it against `meta.counts` to see whether you are holding a subset.\n\n404 when the report predates the feature (no map was published with it), when it does not exist, or when it belongs to another organization. Available on every plan.",
        "operationId": "getReportEntities",
        "parameters": [
          { "$ref": "#/components/parameters/ReportId" },
          {
            "name": "format",
            "in": "query",
            "description": "Export format. All eight render.\n\n`json` is the canonical document and `jsonld` the merged graph for a schema validator. `html` is the interactive viewer, `markdown` the findings-first text rendering. `csv` is one row per entity for a spreadsheet, `dot` for Graphviz, `graphml` for Gephi, and `mermaid` for a diagram, capped at 150 entities by reach.\n\nEvery value in the map is declared by the audited site, so treat it as untrusted. The `html` rendering escapes it and is safe to open directly. The `markdown`, `csv`, `dot`, `graphml` and `mermaid` renderings escape only what their own syntax requires: render any of them into HTML and you must sanitize first, or use `format=json` and render the fields yourself.",
            "schema": {
              "type": "string",
              "enum": ["json", "jsonld", "html", "markdown", "csv", "dot", "graphml", "mermaid"],
              "default": "json"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Keep only entities carrying this schema.org `@type` (case-insensitive). Matched against EVERY type an entity declares, so an entity typed `[\"Organization\", \"LocalBusiness\"]` matches either.",
            "schema": { "type": "string", "maxLength": 128 }
          },
          {
            "name": "exclude_type",
            "in": "query",
            "description": "Drop entities whose PRIMARY `@type` is exactly this one. Repeat the parameter to exclude several: `?exclude_type=WebPage&exclude_type=BreadcrumbList`.\n\nTwo differences from `type` above, both deliberate. It reads the primary type, `types[0]`, the one an entity leads with, rather than every type it declares: this expresses a deny-list over the one type an entity is listed under, which is what a viewer showing one chip per entity needs. And it is CASE-SENSITIVE, where `type` is not: the distinct primary types in a map are compared as strings, so a site declaring both `Organization` and `organization` has two of them, and folding case here would drop both when the caller named one.\n\nThe length bound is the published map's own `maxStringLength`, not the 128 that `type` uses, so every type name this endpoint can serve can also be excluded.\n\nCombine freely with the other filters; they all apply before rendering.",
            "schema": {
              "type": "array",
              "maxItems": 750,
              "items": { "type": "string", "minLength": 1, "maxLength": 512 }
            },
            "style": "form",
            "explode": true
          },
          {
            "name": "page",
            "in": "query",
            "description": "Keep only entities declared on this page URL, or on a page whose URL starts with it.\n\nMatching is a plain prefix, so `https://site/about` also matches `https://site/about-us`; add a trailing slash to scope to a directory.\n\nThis filter can be INCOMPLETE. Each entity lists only its first few declaring pages (at most 5 in the published map this endpoint serves), with the rest collapsed into a `morePages` count, so an entity declared on 200 pages cannot match on one of the URLs that were not listed. When that is possible for the map being filtered, `meta.pageFilterIncomplete` is true.",
            "schema": { "type": "string", "maxLength": 2048 }
          },
          {
            "name": "problem",
            "in": "query",
            "description": "Keep only entities with this problem. `no-id`: no `@id`, so nothing ties the declarations together. `conflict`: occurrences disagree on a property. `dangling`: references an `@id` no page declares. `single-page`: declared on one page only. `split-identity`: the same thing declared under two different `@id`s.",
            "schema": {
              "type": "string",
              "enum": ["no-id", "conflict", "dangling", "single-page", "split-identity"]
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Free-text match over name, `@id`, key and types.",
            "schema": { "type": "string", "maxLength": 256 }
          },
          {
            "name": "include_page_local",
            "in": "query",
            "description": "Include per-page types (BreadcrumbList, WebPage, ListItem, Question, Answer, and unnamed ImageObject). Off by default — they crowd out the entities the map exists to show.",
            "schema": { "type": "string", "enum": ["true", "false", "1", "0"], "default": "false" }
          }
        ],
        "responses": {
          "200": {
            "description": "The entity map. `application/json` for `format=json`; otherwise the requested rendering, with a content type matching the format.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/EntityMapResponse" } },
              "application/ld+json": { "schema": { "type": "object" } },
              "text/html": { "schema": { "type": "string" } },
              "text/markdown": { "schema": { "type": "string" } },
              "text/csv": { "schema": { "type": "string" } },
              "text/vnd.graphviz": { "schema": { "type": "string" } },
              "application/xml": { "schema": { "type": "string" } },
              "text/plain": { "schema": { "type": "string" } }
            }
          },
          "400": { "$ref": "#/components/responses/ValidationError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/reports/{id}/pages": {
      "get": {
        "tags": ["Reports"],
        "summary": "List the report's pages",
        "description": "One row per page the audit crawled, failed pages included (a 404 or a 5xx keeps its `status`), with the title, description, headings, schema types, link counts and rule flags the CLI's `squirrel pages` shows. Read from the stored report: no re-crawl, no probes, no credits.\n\nThe published copy holds at most 1,000 pages, shallowest first (then by URL). When the audit crawled more, `truncated` is true and `stored` and `pagesInAudit` give the two counts. The cap is fixed and does not depend on your plan's page ceiling.\n\n`inlinks` counts the distinct crawled pages that link to a page. The `orphan` filter keeps rows with `inlinks` of 0: no incoming internal link in THIS audit's observed crawl graph. It is not proof of a site-wide orphan, because a page can be linked from somewhere the crawl did not reach (a page past the page cap, a sitemap, an external site). The local `squirrel pages --orphan` selects on the orphan rule's own threshold instead.\n\nEvery value is declared by the audited site, so treat it as untrusted text and escape it before rendering.\n\n404 when the report does not exist, belongs to another organization, or was published without a page map (older reports, and publishers that did not send one). Available on every plan.",
        "operationId": "getReportPages",
        "parameters": [
          { "$ref": "#/components/parameters/ReportId" },
          { "$ref": "#/components/parameters/Limit" },
          { "$ref": "#/components/parameters/Offset" },
          {
            "name": "section",
            "in": "query",
            "description": "Keep only pages whose URL path is this prefix or under it: `/blog` matches `/blog` and `/blog/a`, not `/blogger`.",
            "schema": { "type": "string", "maxLength": 2048 }
          },
          {
            "name": "orphan",
            "in": "query",
            "description": "Keep only pages with no incoming internal link in this audit's crawl (`inlinks` of 0).",
            "schema": { "type": "string", "enum": ["true", "false", "1", "0"], "default": "false" }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Keep only pages whose URL contains this text (case-insensitive).",
            "schema": { "type": "string", "maxLength": 256 }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of rows.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ReportPageList" } }
            }
          },
          "400": { "$ref": "#/components/responses/ValidationError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/reports/{id}/entities/{key}": {
      "get": {
        "tags": ["Reports"],
        "summary": "Get one entity from the report's entity map",
        "description": "One node with its properties, occurrences, conflicts, declaring pages, and the edges pointing out of and into it.\n\n`key` accepts the node key, the entity's `@id`, or its exact display name. An `@id` is a URL, so percent-encode it (`/` as `%2F`).",
        "operationId": "getReportEntity",
        "parameters": [
          { "$ref": "#/components/parameters/ReportId" },
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "Node key, `@id`, or exact entity name. Percent-encode a URL.",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "The entity and its edges.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/EntityNodeDetail" } }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/rules": {
      "get": {
        "tags": ["Rules"],
        "summary": "List audit rules",
        "description": "The rule catalogue, grouped by category and sorted by category priority. Use it to build `enabledRulePatterns` and `disabledRulePatterns` for `POST /v1/agent-runs`: a pattern is a category code (`ax`), a category glob (`ax/*`) or an exact rule `id` (`core/robots-meta`). Each rule says whether it `requiresCloud` (reads a cloud-backed step: slower and credit-metered) and whether it `requiresRender` (reads the render step, so it is skipped on a run with `render: false`). The catalogue is the same for every caller and changes only when a new engine version ships, so the response is cacheable (`Cache-Control: public, max-age=3600`). Opt-in rules (`gaps/*`) are not listed and cannot be selected. The hosted MCP `list_rules` and `get_rule` tools return the same fields as `requires_cloud` and `requires_render`.",
        "operationId": "listRules",
        "responses": {
          "200": {
            "description": "The rule catalogue.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RuleCatalog" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/v1/credits": {
      "get": {
        "tags": ["Credits"],
        "summary": "Get credit balance",
        "description": "Current credit balance for the active organization, plus the plan and the credit pricing table. Pass `?orgId=` to target a specific organization the caller is a member of.",
        "operationId": "getCredits",
        "parameters": [
          {
            "name": "orgId",
            "in": "query",
            "required": false,
            "description": "Target a specific organization the caller belongs to. Defaults to the active org.",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Balance, plan, and pricing.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CreditsResponse" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" }
        }
      }
    },
    "/v1/organizations/{id}": {
      "get": {
        "tags": ["Organizations"],
        "summary": "Get an organization",
        "description": "Read an organization the caller belongs to (an API key reads its own organization), with its plan limits. A signed-in member also gets the member list. An API key gets neither the member list nor the organization's billing fields, and keeps working after the member who made it leaves.",
        "operationId": "getOrganization",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Organization detail.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/OrganizationDetail" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/v1/organizations/{id}/logo": {
      "get": {
        "tags": ["Organizations"],
        "summary": "Get an organization logo",
        "description": "Public and unauthenticated — streams the organization's logo image (PNG/JPEG/WebP) with its stored content type, or 404 when no logo is set. This is the stable URL that `organizations.avatarUrl` points to.",
        "operationId": "getOrganizationLogo",
        "security": [],
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "The logo image.",
            "content": {
              "image/png": { "schema": { "type": "string", "format": "binary" } },
              "image/jpeg": { "schema": { "type": "string", "format": "binary" } },
              "image/webp": { "schema": { "type": "string", "format": "binary" } }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      },
      "post": {
        "tags": ["Organizations"],
        "summary": "Upload an organization logo",
        "description": "Owner/admin only. Multipart upload with a `file` field. Accepts PNG/JPEG/WebP validated by magic bytes (SVG and non-images are rejected regardless of declared content type), max 1MB. Stores the image and persists its public URL on `organizations.avatarUrl`.",
        "operationId": "uploadOrganizationLogo",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["file"],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "PNG, JPEG, or WebP image, max 1MB."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Logo stored; returns the served URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["avatarUrl"],
                  "properties": { "avatarUrl": { "type": "string", "format": "uri" } }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/ValidationError" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" },
          "413": { "$ref": "#/components/responses/PayloadTooLarge" },
          "415": {
            "description": "The bytes are not a PNG/JPEG/WebP image (e.g. SVG). Typed envelope with code `UNSUPPORTED_MEDIA_TYPE`.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": {
                  "error": {
                    "code": "UNSUPPORTED_MEDIA_TYPE",
                    "message": "Logo must be a PNG, JPEG, or WebP image"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Organizations"],
        "summary": "Remove an organization logo",
        "description": "Owner/admin only. Deletes the stored logo and clears `organizations.avatarUrl`.",
        "operationId": "deleteOrganizationLogo",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Logo removed; `avatarUrl` is now null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["avatarUrl"],
                  "properties": { "avatarUrl": { "type": "null" } }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token in the `Authorization` header: `Authorization: Bearer <token>`.\n\nProgrammatic API keys are prefixed `sq_` (issue #154; bearer auth lands in #156). The same scheme today also accepts CLI tokens (`sqcli_` prefix) and Clerk dashboard JWTs."
      }
    },
    "parameters": {
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Page size (1–100).",
        "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 }
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "required": false,
        "description": "Number of items to skip.",
        "schema": { "type": "integer", "minimum": 0, "default": 0 }
      },
      "RunId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Audit run id.",
        "schema": { "type": "string" }
      },
      "ReportId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Report id.",
        "schema": { "type": "string" }
      }
    },
    "headers": {
      "RateLimitLimit": {
        "description": "Request quota for the current window.",
        "schema": { "type": "integer" }
      },
      "RateLimitRemaining": {
        "description": "Requests remaining in the current window.",
        "schema": { "type": "integer" }
      },
      "RateLimitReset": {
        "description": "Seconds until the current rate-limit window resets.",
        "schema": { "type": "integer" }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying (sent on 429).",
        "schema": { "type": "integer" }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid credentials (including the shared auth middleware: no/invalid bearer token). Typed envelope with code `UNAUTHORIZED`. Branch on the `401` status, not the message.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" },
            "example": { "error": { "code": "UNAUTHORIZED", "message": "Authentication required" } }
          }
        }
      },
      "Forbidden": {
        "description": "Authenticated but not permitted (e.g. not a member of the requested organization). Typed envelope; code `FORBIDDEN`, or `NO_ORG` when no active organization is resolved on credit/org-scoped routes. Branch on the `403` status.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" },
            "examples": {
              "noOrg": {
                "summary": "No active organization resolved",
                "value": { "error": { "code": "NO_ORG", "message": "No active organization" } }
              },
              "forbidden": {
                "summary": "Not permitted (e.g. API key scoped to a different org)",
                "value": { "error": { "code": "FORBIDDEN", "message": "API key is not scoped to this organization" } }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found (or hidden from the caller).",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" },
            "example": { "error": { "code": "NOT_FOUND", "message": "Report not found" } }
          }
        }
      },
      "ValidationError": {
        "description": "Request body or query failed validation. `error.issues` lists up to 10 failed fields (`{ path, message }`); when more failed, `error.truncated: true` and `error.totalIssues` indicate the full count.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" },
            "example": {
              "error": {
                "code": "VALIDATION_ERROR",
                "message": "Request failed validation",
                "issues": [{ "path": "url", "message": "Invalid url" }]
              }
            }
          }
        }
      },
      "InsufficientCredits": {
        "description": "The organization does not have enough credits for this operation. Typed envelope with code `INSUFFICIENT_CREDITS`; `error.required` and `error.balance` carry the credit detail. Branch on the `402` status.",
        "content": {
          "application/json": {
            "schema": {
              "allOf": [
                { "$ref": "#/components/schemas/Error" },
                {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "required": { "type": "integer", "description": "Credits needed for this operation." },
                        "upgrade": {
                          "allOf": [{ "$ref": "#/components/schemas/UpgradeOffer" }],
                          "description": "The org-targeted upgrade offer. Absent for an unmetered organization and for an organization already on Pro or above (those get a top-up message instead)."
                        },
                        "balance": {
                          "type": "object",
                          "description": "The org's credit balance at the time of the failure.",
                          "properties": {
                            "monthly": { "type": "integer" },
                            "pack": { "type": "integer" },
                            "total": { "type": "integer" },
                            "periodEnd": { "type": ["string", "null"] }
                          }
                        }
                      }
                    }
                  }
                }
              ]
            },
            "example": {
              "error": {
                "code": "INSUFFICIENT_CREDITS",
                "message": "Insufficient credits",
                "required": 50,
                "balance": { "monthly": 0, "pack": 12, "total": 12, "periodEnd": "2026-07-01T00:00:00Z" },
                "upgrade": {
                  "url": "https://app.squirrelscan.com/upgrade?plan=pro&interval=month&org=org_123&src=api",
                  "plan": "pro",
                  "interval": "month",
                  "name": "Pro",
                  "priceMonthUsd": 19,
                  "priceYearUsd": 190,
                  "monthlyCredits": 3000
                }
              }
            }
          }
        }
      },
      "DuplicateRequest": {
        "description": "An identical request was already processed under the same idempotency key and is still in flight or its cached response is unavailable. Typed envelope with code `DUPLICATE_REQUEST`.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" },
            "example": { "error": { "code": "DUPLICATE_REQUEST", "message": "Duplicate request" } }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "The request body exceeds the maximum allowed size.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" },
            "example": { "error": { "code": "PAYLOAD_TOO_LARGE", "message": "Report exceeds maximum size" } }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests: the API key (or organization) exceeded its request budget for the current one-minute window. Back off for `Retry-After` seconds. The body is a plain `{ \"error\": \"...\" }` string, not the typed error envelope.",
        "headers": {
          "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
          "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
          "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" },
          "Retry-After": { "$ref": "#/components/headers/RetryAfter" }
        },
        "content": {
          "application/json": {
            "schema": { "type": "object", "required": ["error"], "properties": { "error": { "type": "string" } } },
            "example": { "error": "Rate limit exceeded. Slow down and retry shortly." }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "Stable error envelope returned by all public routes.",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable error code (SCREAMING_SNAKE_CASE). Treat unknown codes as opaque."
              },
              "message": {
                "type": "string",
                "description": "Human-readable description. May change; do not match on it."
              },
              "requestId": {
                "type": "string",
                "description": "Correlation id for support / log lookups, when available."
              }
            },
            "additionalProperties": true
          }
        }
      },
      "Visibility": {
        "type": "string",
        "enum": ["public", "unlisted", "private"]
      },
      "AuditRunStatus": {
        "type": "string",
        "enum": ["queued", "pending", "running", "completed", "failed", "cancelled"]
      },
      "AuditRunQueue": {
        "type": "object",
        "description": "Where a `queued` run stands. A queued run is waiting for a container slot and starts by itself: there is nothing to retry and nothing more is charged. Present on the create response and on `GET /v1/agent-runs/{id}` while `status` is `queued`.",
        "required": ["position", "etaMinutes", "reason", "message"],
        "properties": {
          "position": { "type": ["integer", "null"], "minimum": 1, "description": "Place in line, `1` is next. `null` when it could not be read." },
          "etaMinutes": { "type": ["integer", "null"], "description": "Estimated minutes until the run starts. `null` when there is no estimate." },
          "reason": { "type": "string", "enum": ["capacity", "org_limit"], "description": "`capacity`: the audit containers are busy. `org_limit`: the organization is already running its plan's limit of audits at once." },
          "message": { "type": "string", "description": "A sentence ready to show a person. May change; do not match on it." }
        }
      },
      "AuditRunMode": {
        "type": "string",
        "enum": ["audit", "audit-fix", "recommend"]
      },
      "CreateAuditRunRequest": {
        "type": "object",
        "description": "The top-level fields are `url`, `trigger`, `mode`, `model`, `config`, `websiteId` and `auditId`. An API-key request carrying any other top-level field is a 400 `VALIDATION_ERROR` naming it (nothing is started or charged); it is never silently dropped.",
        "required": ["url"],
        "properties": {
          "url": { "type": "string", "format": "uri", "description": "Site URL to audit." },
          "trigger": {
            "type": "string",
            "enum": ["api"],
            "default": "api",
            "description": "Run origin. Optional for an API key, which gets `api` (it dispatches the cloud crawler) whether it sends it or not. A signed-in session must send it: omitting it is a 400. (`cli`/`github`/`scheduled` are internal-origin values that skip cloud dispatch and are not accepted here.)"
          },
          "mode": { "allOf": [{ "$ref": "#/components/schemas/AuditRunMode" }], "default": "audit" },
          "model": { "type": "string" },
          "config": {
            "description": "Optional run config: an object (preferred) or the same object as a JSON-encoded string (the older form, still accepted). A string that is not valid JSON, a value that is not an object, a key outside `CreateAuditRunConfig`, or a wrongly typed or invalid value is a 400 `VALIDATION_ERROR` (nothing is started or charged); it is never silently ignored. The config a run reports back in `GET /v1/agent-runs/{id}` can be sent again: the keys the server writes into it (listed in `CreateAuditRunConfig`) are accepted and dropped, and the run's own values are used instead. A completed run's config can also hold keys written during the run (timings, billing, failure detail); those are not accepted.",
            "oneOf": [
              { "$ref": "#/components/schemas/CreateAuditRunConfig" },
              { "type": "string", "description": "The config object, JSON-encoded." }
            ],
            "example": { "maxPages": 1, "enabledRulePatterns": ["ax/*", "core/robots-meta"], "render": false, "ephemeral": true }
          },
          "websiteId": { "type": "string" },
          "auditId": { "type": "string" }
        }
      },
      "CreateAuditRunConfig": {
        "type": "object",
        "description": "The `config` of a create-run request. Unknown keys are refused. Also accepted and dropped, because the server writes them into a run's config and a caller may echo it back: `maxCredits`, `renderMode`, `maxDepth`, `respectRobots`, `pageLimitNotice`, `creditClamp`, `levelLimitNotice`, `auditLevel`, `ruleSelection`, `crawlScope`, `crawlPolicy`, `containerPlanId`, `containerClassName`, `dispatchSite`, `source`, `internal`.",
        "properties": {
          "coverageMode": { "type": "string", "enum": ["quick", "surface", "full"], "description": "Crawl depth for this run (held to what the plan may crawl)." },
          "maxPages": { "type": "integer", "minimum": 1, "description": "Pages to audit. `1` audits just the entry URL. Above the plan ceiling the run is clamped and the response carries a `notice`." },
          "disabledRulePatterns": {
            "type": "array",
            "maxItems": 50,
            "items": { "type": "string", "maxLength": 100, "pattern": "^[A-Za-z0-9_./*-]+$" },
            "description": "Rules that do NOT run, added to the website's own disable list. The same patterns, matching, limits and errors as `enabledRulePatterns` (a category, a category glob or an exact rule id; an unknown category or a pattern that matches no rule is a 400 listing it in `error.patterns`). May be empty. **Disable wins:** a rule named here does not run even when `enabledRulePatterns` selects it, as in a lint config. Caution: `ai/*` is an alias of the whole `ax` category and switches off every `ax` rule; name the three legacy `ai/` rule ids exactly (`ai/llm-parsability`, `ai/page-type-match`, `ai/site-metadata`)."
          },
          "enabledRulePatterns": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "items": { "type": "string", "maxLength": 100, "pattern": "^[A-Za-z0-9_./*-]+$" },
            "description": "Run ONLY the rules these patterns select (an include filter). A pattern is a category (`ax`), a category glob (`ax/*`) or an exact rule id (`core/robots-meta`): the same patterns, with the same meaning, as the CLI's `--rule-include` (list them with `GET /v1/rules`). At most 50 patterns of at most 100 characters; letters, digits and `-_./*` only (no commas, spaces, regular expressions or control characters). A pattern that matches no rule, an unknown category, or a selection that `disabledRulePatterns` (or the website's disable list) leaves with no rule is a 400 `VALIDATION_ERROR` whose `error.patterns` lists the offenders: it never starts an empty run. `ax` includes the three rules that kept the legacy `ai/` id prefix (`ai/llm-parsability`, `ai/page-type-match`, `ai/site-metadata`): they are the cloud-backed ones, slower and credit-metered, so a caller that wants the plain robots, llms.txt and agent-signal rules disables those three by exact id. Opt-in rules (`gaps/*`) are not selectable here. The report covers only the selected rules (`includeFilter` on `GET /v1/agent-runs/{id}/report` says so); its overall score is not comparable to a full audit's. Price is unchanged."
          },
          "externalLinksEnabled": { "type": "boolean", "description": "Check external links for this run (each distinct link the cloud verifies costs 1 credit). Overrides the website's setting; a run with no website follows the default, which is on." },
          "render": { "type": "boolean", "description": "Browser-render the pages the crawl fetches. `false` fetches every page over plain HTTP, with no per-page headless browser; `true` renders every page, held to what the plan may render. Omit it to follow the website's setting (a run with no website renders). Same meaning as `render` on the MCP `run_audit`. Price is unchanged." },
          "ephemeral": { "type": "boolean", "description": "One-shot check, with the exact semantics of `ephemeral` on the MCP `run_audit`: when the run creates the website, that website is exempt from the plan's website cap, is hidden from website listings, and is ARCHIVED automatically once the run finishes. The RUN and its report are NOT purged (a purge is planned, not shipped): `GET /v1/agent-runs/{id}` and `/report` keep working, but the run is hidden from `GET /v1/agent-runs` unless the request passes `includeOneOff=true`. A one-shot run sends no email, creates no bell row, opens no tracker issue and fires no webhook. At most 5 one-shot websites may be live per organization (429 `EPHEMERAL_LIMIT`), and the credit check happens before the hidden website is created. Ignored when the organization already tracks the domain, or `websiteId` is sent (the run goes against that website, nothing is deleted); the response then carries `ephemeral: false` and an `ephemeralIgnoredReason`. Cannot be combined with `auditId`." },
          "editorSummary": { "type": "boolean", "description": "Build the editor's summary, an LLM-written overview of the whole report that adds about 30 seconds to a run. Omit it for the default: skipped on a run with `enabledRulePatterns` (a filtered run), built on every other run. `true` builds it on a filtered run; `false` skips it on any run. A skipped summary is absent from the report (`editorSummary` is not set) and the run timeline records the step as skipped. Has no effect on price: the summary carries no credit charge, built or skipped." }
        }
      },
      "CreateAuditRunResponse": {
        "type": "object",
        "required": ["id", "status", "createdAt"],
        "properties": {
          "id": { "type": "string" },
          "status": { "type": "string", "enum": ["pending", "queued"], "description": "`pending` once dispatched; `queued` when the run is waiting for a container slot and starts by itself (the response then carries `queue`)." },
          "createdAt": { "type": "string", "format": "date-time" },
          "queue": { "$ref": "#/components/schemas/AuditRunQueue" },
          "notice": { "$ref": "#/components/schemas/PageLimitClampNotice" },
          "disabledRulePatterns": { "type": "array", "items": { "type": "string" }, "description": "The disable list this request sent, as expanded. Present only when `config.disabledRulePatterns` was sent and not empty." },
          "enabledRulePatterns": { "type": "array", "items": { "type": "string" }, "description": "The include filter the run applies, as expanded (`ax` becomes `ax/*`). Present only when `config.enabledRulePatterns` was sent." },
          "render": { "type": "boolean", "description": "Whether the run renders pages. Present only when `config.render` was sent." },
          "ephemeral": { "type": "boolean", "description": "Whether the one-shot treatment applies. Present only when `config.ephemeral` was sent." },
          "ephemeralIgnoredReason": { "type": "string", "description": "Why `ephemeral` was not honoured, when `ephemeral` is `false`." },
          "editorSummary": { "type": "boolean", "description": "Whether the run builds the editor's summary. Present only when `config.enabledRulePatterns` or `config.editorSummary` was sent." },
          "editorSummarySkippedReason": { "type": "string", "enum": ["rule-filtered run", "disabled by the run config"], "description": "Why the summary is skipped, when `editorSummary` is `false`." }
        }
      },
      "PageLimitClampNotice": {
        "type": "object",
        "description": "Present only when the run's requested page count exceeded the org's plan ceiling. The run is never rejected for this (clamp-and-notify, not a hard error) — it dispatches at `applied` pages instead of `requested`, and this field says so.",
        "required": ["type", "requested", "applied", "planId", "planCap", "upgradeHint"],
        "properties": {
          "type": { "type": "string", "const": "page_limit_clamped" },
          "requested": { "type": "integer", "description": "Pages that were actually asked for (stored crawl config or an explicit request override)." },
          "applied": { "type": "integer", "description": "Pages the run actually dispatched with — equal to `planCap`." },
          "planId": { "type": "string", "enum": ["free", "starter", "team", "team_legacy", "business", "enterprise"] },
          "planCap": { "type": "integer", "description": "The org's plan's effective max-pages-per-audit ceiling at dispatch time." },
          "upgradeHint": { "type": "string", "description": "Human-readable upgrade suggestion, always including a pricing URL." }
        }
      },
      "RenderFallbackNotice": {
        "type": "object",
        "description": "Present only when pages the run asked to render could not be rendered and were audited from their unrendered source instead. The audit still completes and publishes; content added by JavaScript was not seen on those pages. Absent when every render succeeded or the run never asked for rendering.",
        "required": ["type", "pages", "message"],
        "properties": {
          "type": { "type": "string", "const": "render_fallback" },
          "pages": { "type": "integer", "description": "Pages that fell back to plain fetch." },
          "message": { "type": "string", "description": "Human-readable explanation, suitable to show to the audit's owner." }
        }
      },
      "AuditRun": {
        "description": "Full audit run record (the single-run GET). A caller can only fetch their own runs, so the owner identifiers below are always the caller's own. Composed as `AuditRunListItem` plus the owner identifiers `userId`/`orgId` via `allOf`, so the shared fields are defined once and cannot drift between the two.",
        "allOf": [
          { "$ref": "#/components/schemas/AuditRunListItem" },
          {
            "type": "object",
            "required": ["userId"],
            "properties": {
              "userId": {
                "type": "string",
                "description": "Internal owner user id (the caller's own — runs are scoped to the authenticated user). Treat as an opaque identifier; do not log/forward outside an authenticated context."
              },
              "orgId": { "type": ["string", "null"] },
              "queue": {
                "$ref": "#/components/schemas/AuditRunQueue",
                "description": "Where the run stands while `status` is `queued`. Omitted otherwise."
              },
              "progress": {
                "type": ["object", "null"],
                "description": "Live progress while `status` is `queued`/`pending`/`running` (#692): the latest phase/page-count event streamed by the run. Null once the run is terminal, or if no progress event has been recorded yet.",
                "properties": {
                  "phase": { "type": ["string", "null"] },
                  "message": { "type": ["string", "null"] },
                  "current": { "type": ["integer", "null"] },
                  "total": { "type": ["integer", "null"] },
                  "failed": { "type": ["integer", "null"] },
                  "updatedAt": { "type": "string", "format": "date-time" }
                }
              },
              "notice": { "$ref": "#/components/schemas/PageLimitClampNotice" },
              "renderFallback": { "$ref": "#/components/schemas/RenderFallbackNotice" },
              "reportAvailability": {
                "type": "string",
                "enum": ["ready", "pending", "none"],
                "description": "Whether this run's report exists, so a client stops guessing from a missing report: `ready` (a report is stored for the run, not verified readable; a failed run that wrote a failure notice has one), `pending` (the run is still going, or it completed and its report is being finalized), `none` (the run failed or was cancelled without writing a report and none will come). Additive."
              }
            },
            "additionalProperties": true
          }
        ]
      },
      "AuditComparison": {
        "type": "object",
        "description": "What changed between two completed audits of a website. Only the fields a CI client needs are listed; others may be present.",
        "properties": {
          "base": { "type": ["object", "null"], "description": "The older run (`runId`, `reportId`, `auditedAt`, `healthScore`), or null for the first audit." },
          "head": { "type": "object", "description": "The newer run (`runId`, `reportId`, `auditedAt`, `healthScore`, `failed`, `warnings`, `passed`, `totalPages`, `status`, and `statusReasonCode` when the audit is `failed`, `blocked` or `partial`: `dns`, `tls`, `connection`, `timeout`, `http_4xx`, `http_5xx`, `redirect`, `robots`, `unknown`, `max_duration` or `crawl_timeout`)." },
          "firstRun": { "type": "boolean", "description": "True when there is no earlier completed audit: nothing is compared." },
          "changed": { "type": "boolean" },
          "totals": {
            "type": "object",
            "description": "Findings per kind, counted over every finding.",
            "additionalProperties": { "type": "integer" }
          },
          "newBySeverity": {
            "type": "object",
            "description": "Findings of kind `new` by rule severity (`error`, `warning`, `info`), counted over every finding.",
            "additionalProperties": { "type": "integer" }
          },
          "findings": {
            "type": "array",
            "description": "Rows, ordered new, worsened, resolved, improved, then the kinds asked for with `include`; clipped by `limit`.",
            "items": {
              "type": "object",
              "properties": {
                "kind": { "type": "string", "enum": ["new", "resolved", "worsened", "improved", "unchanged", "still_open", "not_crawled", "not_checked"] },
                "ruleId": { "type": "string" },
                "ruleName": { "type": "string" },
                "severity": { "type": "string", "enum": ["error", "warning", "info"] },
                "pageUrl": { "type": ["string", "null"] },
                "locator": { "type": ["string", "null"] },
                "skipReason": { "type": "string", "description": "Why a `not_checked` finding was not judged." }
              },
              "additionalProperties": true
            }
          },
          "findingsTruncated": { "type": "boolean" },
          "comparisonIncomplete": { "type": "boolean", "description": "A report exceeded the comparison's finding cap: new and resolved counts are not reliable." },
          "resolutionEvidence": { "type": "string", "enum": ["page_findings", "signal", "none"] },
          "notes": { "type": "array", "items": { "type": "string" } }
        },
        "additionalProperties": true
      },
      "CompareGate": {
        "type": "object",
        "description": "The CI gate over a comparison, evaluated at `fail_on`.",
        "required": ["failOn", "status", "newAtOrAbove", "resolved", "notCompared", "reason"],
        "properties": {
          "failOn": { "type": "string", "enum": ["error", "warning", "info"] },
          "status": {
            "type": "string",
            "enum": ["pass", "fail", "no_baseline", "not_evaluated"],
            "description": "`fail`: new findings at or above `failOn`. `pass`: none. `no_baseline`: the first audit of the website, which passes. `not_evaluated`: the audit ended `failed` or `blocked`, or the comparison hit its finding cap; neither a pass nor a fail."
          },
          "newAtOrAbove": { "type": "integer", "description": "New findings at or above `failOn`, over every finding (not only the listed rows)." },
          "resolved": { "type": "integer", "description": "Resolved findings: listed, never failing." },
          "notCompared": {
            "type": "object",
            "description": "Older findings the newer audit could not judge, neither new nor resolved.",
            "properties": {
              "notCrawled": { "type": "integer" },
              "notChecked": { "type": "integer" }
            }
          },
          "reason": { "type": "string", "description": "One line for the CI log." }
        }
      },
      "AuditRunListItem": {
        "type": "object",
        "description": "Audit run as returned by the list endpoint. Also the shared base for the single-run `AuditRun` schema, which composes this plus `userId`/`orgId` via `allOf` — so the common fields live in exactly one place. Nullable fields are unset until the run progresses.",
        "required": ["id", "url", "status", "trigger", "mode", "createdAt"],
        "properties": {
          "id": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "status": { "$ref": "#/components/schemas/AuditRunStatus" },
          "trigger": { "type": "string", "enum": ["cli", "api", "github", "scheduled"] },
          "mode": { "$ref": "#/components/schemas/AuditRunMode" },
          "model": { "type": ["string", "null"] },
          "healthScore": {
            "type": ["integer", "null"],
            "minimum": 0,
            "maximum": 100,
            "description": "Rounded score from the persisted `health_score` DB column (an integer). The unrounded float is available as `report.healthScore` on `GET /v1/agent-runs/{id}/report`. `null` while the run has no score yet, for a blocked or unreachable site, and for a `partial` run: one started with `config.enabledRulePatterns` covers only the rules it selected, so a score computed from them is not the site's score and is withheld. A run with no include filter, or with only `disabledRulePatterns`, is scored as before."
          },
          "partial": {
            "type": "boolean",
            "const": true,
            "description": "Present, and `true`, only when the run was started with `config.enabledRulePatterns`: its `healthScore` is `null` because the rules it ran are a subset of the audit. The key is absent for a run without an include filter, and for one with only `disabledRulePatterns`. The same marker, with the same meaning, is on `GET /v1/agent-runs/{id}/report`."
          },
          "issuesFound": { "type": ["integer", "null"] },
          "issuesFixed": { "type": ["integer", "null"] },
          "reportId": { "type": ["string", "null"] },
          "websiteId": { "type": ["string", "null"] },
          "auditId": { "type": ["string", "null"] },
          "config": { "type": ["object", "null"], "additionalProperties": true },
          "error": { "type": ["string", "null"] },
          "completionReason": { "type": ["string", "null"] },
          "completionMessage": { "type": ["string", "null"] },
          "costUsd": { "type": ["number", "null"] },
          "startedAt": { "type": ["string", "null"], "format": "date-time" },
          "completedAt": { "type": ["string", "null"], "format": "date-time" },
          "createdAt": { "type": "string", "format": "date-time" }
        },
        "additionalProperties": true
      },
      "AuditRunList": {
        "type": "object",
        "required": ["runs", "total", "hasMore"],
        "properties": {
          "runs": { "type": "array", "items": { "$ref": "#/components/schemas/AuditRunListItem" } },
          "total": { "type": "integer" },
          "hasMore": { "type": "boolean" }
        }
      },
      "AuditRunReport": {
        "type": "object",
        "description": "Summarized report data + top scored issues for a completed run, wrapped under `report`.",
        "required": ["report"],
        "properties": {
          "includeFilter": {
            "type": "object",
            "description": "Present only when the run was started with `config.enabledRulePatterns`: the report covers just that rule selection, so its issue counts are not comparable to a full audit's and the report is `partial` (`report.partial` is true, and the overall and category scores are null).",
            "required": ["patterns", "rulesSelected", "rulesTotal", "note"],
            "properties": {
              "patterns": { "type": "array", "items": { "type": "string" } },
              "rulesSelected": { "type": "integer", "description": "Rules the filter selects, after the disable lists." },
              "rulesTotal": { "type": "integer" },
              "note": { "type": "string" }
            }
          },
          "report": {
            "type": "object",
            "required": ["id", "url", "visibility", "baseUrl"],
            "properties": {
              "id": { "type": "string" },
              "url": { "type": "string", "format": "uri" },
              "visibility": { "$ref": "#/components/schemas/Visibility" },
              "siteKey": { "type": "string" },
              "baseUrl": { "type": "string", "format": "uri" },
              "timestamp": { "type": "string", "format": "date-time" },
              "totalPages": { "type": "integer" },
              "failed": { "type": "integer" },
              "warnings": { "type": "integer" },
              "passed": { "type": "integer" },
              "partial": {
                "type": "boolean",
                "const": true,
                "description": "Present, and `true`, only when the run was started with `config.enabledRulePatterns`: the report covers a subset of the rules, so a score computed from it would not be the site's score. `healthScore` and every `categories[].score` are `null` on a partial report (the counts still cover the rules that ran), and the top-level `includeFilter` says which rules ran. The key is absent for a run without an include filter, whose report is unchanged. A `disabledRulePatterns` list on its own does not make a report partial."
              },
              "results": {
                "type": "array",
                "description": "Present only on a `partial` report: one entry for EVERY rule the run selected (the include filter less the disable lists), sorted by `ruleId`, so a client can tell a rule that passed from one that did not run. `topIssues` stays the human summary of warnings and failures. Nothing in an entry is text from the audited site: every field is an enum, a number, a boolean or a short token the rule itself wrote (a check id, an AI crawler's user-agent token). The key is absent for a run without an include filter.",
                "items": { "$ref": "#/components/schemas/RuleResult" }
              },
              "healthScore": {
                "type": ["number", "null"],
                "description": "The precise overall score from the report (a float, e.g. 82.5), read straight from the report JSON. Intentionally a `number` here — the rounded `integer` `healthScore` on `AuditRun`/`Report` mirrors the persisted DB column, while this is the unrounded source value. `null` for a failed or empty audit and for a `partial` report."
              },
              "categories": {
                "type": "array",
                "description": "Per-category counts and score. On a `partial` report each `score` is `null`.",
                "items": { "type": "object", "properties": { "score": { "type": ["number", "null"] } }, "additionalProperties": true }
              },
              "topIssues": {
                "type": "array",
                "description": "Up to 25 failing/warning checks, fails first.",
                "items": {
                  "type": "object",
                  "properties": {
                    "ruleId": { "type": "string" },
                    "ruleName": { "type": "string" },
                    "category": { "type": "string" },
                    "subcategory": { "type": "string" },
                    "severity": { "type": "string", "enum": ["error", "warning"] },
                    "status": { "type": "string", "enum": ["fail", "warn"] },
                    "message": { "type": "string" },
                    "pageUrl": { "type": ["string", "null"] }
                  },
                  "additionalProperties": true
                }
              },
              "history": { "type": "array", "items": { "type": "object", "additionalProperties": true } }
            },
            "additionalProperties": true
          }
        }
      },
      "PublishReportRequest": {
        "type": "object",
        "required": ["report"],
        "properties": {
          "report": {
            "$ref": "#/components/schemas/AuditReport"
          },
          "visibility": {
            "allOf": [{ "$ref": "#/components/schemas/Visibility" }],
            "default": "private"
          }
        }
      },
      "AuditReport": {
        "type": "object",
        "description": "The full audit report payload produced by the squirrelscan engine. Only the high-signal top-level fields are documented here; the complete schema is validated by the hosted API. Extra top-level fields are accepted but ignored, while the documented fields below are validated and must conform.",
        "required": ["baseUrl", "timestamp", "totalPages", "passed", "warnings", "failed", "siteChecks", "summary", "ruleResults"],
        "properties": {
          "baseUrl": { "type": "string", "format": "uri" },
          "timestamp": { "type": "string", "format": "date-time" },
          "totalPages": { "type": "integer", "minimum": 0 },
          "passed": { "type": "integer", "minimum": 0 },
          "warnings": { "type": "integer", "minimum": 0 },
          "failed": { "type": "integer", "minimum": 0 },
          "siteChecks": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "pages": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "summary": { "type": "object", "additionalProperties": true },
          "ruleResults": { "type": "object", "additionalProperties": true },
          "healthScore": { "type": "object", "additionalProperties": true }
        },
        "additionalProperties": true
      },
      "PublishedReport": {
        "type": "object",
        "required": ["id", "url", "visibility", "createdAt"],
        "properties": {
          "id": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "visibility": { "$ref": "#/components/schemas/Visibility" },
          "createdAt": { "type": "string", "format": "date-time" },
          "schedule": {
            "$ref": "#/components/schemas/WebsiteScheduleSummary",
            "description": "What this website's recurring audits are doing, for the line a client prints after a publish. The key is ABSENT, never `null`, when there is nothing honest to say (no website, no org, or no readable org slug): read absence as \"say nothing\", not as \"there is no schedule\". A site with no schedule at all is present with `state: \"off\"`."
          }
        }
      },
      "WebsiteScheduleState": {
        "type": "string",
        "enum": ["off", "active", "capped", "unschedulable", "paused"],
        "description": "Why a website is, or is not, being re-audited. `off`: nothing recurring is set up and nothing is stopping one (a choice). `active`: recurring audits are running. `capped`: wanted, but the plan's scheduled-website slots are spent. `unschedulable`: wanted, but the host can never be audited from the cloud. `paused`: was running and was stopped by the system (a failure streak or credits)."
      },
      "WebsiteScheduleSummary": {
        "type": "object",
        "required": [
          "kind",
          "frequency",
          "requested",
          "state",
          "stateReason",
          "nextRunAt",
          "cadenceLabel",
          "settingsUrl",
          "pauseUrl",
          "cap",
          "upgradeUrl"
        ],
        "description": "What a website's recurring audits are doing, as one server-rendered object. String fields are ready to print: clients render them rather than recompute them.",
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["recurring", "always_on"],
            "description": "`recurring` is the cadence-driven schedule. `always_on` is reserved for continuous monitoring, has no cadence, and is not populated yet."
          },
          "frequency": {
            "type": ["string", "null"],
            "enum": ["daily", "weekly", "monthly", null],
            "description": "The cadence that actually fires. `null` for `always_on` and for a site that is not running a schedule."
          },
          "requested": {
            "type": "boolean",
            "description": "What the owner asked for, which is not always what they got. Read with `state`: `requested: true` with `state: \"capped\"` means a schedule was wanted and refused by the plan."
          },
          "state": { "$ref": "#/components/schemas/WebsiteScheduleState" },
          "stateReason": {
            "type": ["string", "null"],
            "description": "Machine-readable cause behind a non-`active` state, for example `plan_cap`, `reserved_host`, `plan_no_schedule`, `consecutive_failures` or `insufficient_credits`. `null` when `state` says everything. An open string: fall back to `state` on an unknown value."
          },
          "nextRunAt": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Next run. `null` unless the schedule is active and recurring."
          },
          "cadenceLabel": {
            "type": "string",
            "description": "The cadence as it reads in a sentence, such as \"every week\", \"off\" or \"always on\"."
          },
          "settingsUrl": {
            "type": "string",
            "format": "uri",
            "description": "This website's schedule settings page in the dashboard. Always present."
          },
          "pauseUrl": {
            "type": ["string", "null"],
            "format": "uri",
            "description": "Signed, no-login pause link. `null` unless there is something running to pause, and not minted on every surface."
          },
          "cap": {
            "type": ["object", "null"],
            "required": ["limit", "used"],
            "properties": {
              "limit": { "type": "integer", "description": "Scheduled websites the plan allows." },
              "used": { "type": "integer", "description": "Scheduled websites already spent." }
            },
            "description": "The plan's scheduled-website allowance and what has been spent of it. `null` on a plan that caps nothing."
          },
          "upgradeUrl": {
            "type": ["string", "null"],
            "format": "uri",
            "description": "Where to buy a way out of `capped` or `plan_no_schedule`. `null` otherwise."
          }
        },
        "additionalProperties": true
      },
      "Report": {
        "type": "object",
        "required": ["id", "baseUrl", "visibility", "url", "createdAt"],
        "properties": {
          "id": { "type": "string" },
          "baseUrl": { "type": "string", "format": "uri" },
          "healthScore": {
            "type": ["integer", "null"],
            "description": "Rounded overall score. `null` for a blocked or unreachable site and for a `partial` report: one whose run was started with `config.enabledRulePatterns` covers only the rules it selected, so its score is not the site's score and is withheld."
          },
          "partial": {
            "type": "boolean",
            "const": true,
            "description": "Present, and `true`, only when the report's run was started with `config.enabledRulePatterns`; `healthScore` is then `null`. The key is absent otherwise."
          },
          "pageCount": { "type": ["integer", "null"] },
          "errorCount": { "type": ["integer", "null"] },
          "warningCount": { "type": ["integer", "null"] },
          "passedCount": { "type": ["integer", "null"] },
          "visibility": { "$ref": "#/components/schemas/Visibility" },
          "viewCount": { "type": ["integer", "null"] },
          "auditedAt": { "type": ["string", "null"], "format": "date-time" },
          "createdAt": { "type": "string", "format": "date-time" },
          "url": { "type": "string", "format": "uri" }
        }
      },
      "ReportList": {
        "type": "object",
        "required": ["reports", "total", "hasMore"],
        "properties": {
          "reports": { "type": "array", "items": { "$ref": "#/components/schemas/Report" } },
          "total": { "type": "integer" },
          "hasMore": { "type": "boolean" }
        }
      },
      "ReportPageRow": {
        "type": "object",
        "description": "One crawled page. Every field is data the crawl stored.",
        "required": ["url", "finalUrl", "status", "depth", "noindex", "titleLength", "descriptionLength", "schemaTypes", "schemaIds", "inlinks", "internalOutlinks", "externalOutlinks", "externalDomains", "flags"],
        "properties": {
          "url": { "type": "string", "description": "The URL the crawl requested." },
          "finalUrl": { "type": "string", "description": "Where it was served from after redirects." },
          "status": { "type": "integer" },
          "depth": { "type": "integer", "description": "Clicks from the start URL." },
          "canonical": { "type": ["string", "null"] },
          "noindex": { "type": "boolean" },
          "title": { "type": ["string", "null"] },
          "titleLength": { "type": "integer" },
          "description": { "type": ["string", "null"] },
          "descriptionLength": { "type": "integer" },
          "h1Count": { "type": ["integer", "null"] },
          "h1": { "type": ["string", "null"] },
          "headingCount": { "type": ["integer", "null"] },
          "wordCount": { "type": ["integer", "null"] },
          "schemaTypes": { "type": "array", "items": { "type": "string" } },
          "schemaIds": { "type": "array", "items": { "type": "string" } },
          "inlinks": { "type": "integer", "description": "Distinct crawled pages linking here, self links excluded. 0 means no incoming internal link in this audit's crawl." },
          "internalOutlinks": { "type": "integer" },
          "externalOutlinks": { "type": "integer" },
          "externalDomains": { "type": "array", "items": { "type": "string" } },
          "loadTimeMs": { "type": ["integer", "null"] },
          "lastModified": { "type": ["string", "null"] },
          "flags": { "type": "array", "items": { "type": "string" }, "description": "Rule results that fired on the page, plus `no-schema` and `noindex`." }
        }
      },
      "ReportPageList": {
        "type": "object",
        "required": ["pages", "total", "limit", "offset", "hasMore", "stored", "pagesInAudit", "truncated"],
        "properties": {
          "pages": { "type": "array", "items": { "$ref": "#/components/schemas/ReportPageRow" } },
          "total": { "type": "integer", "description": "Stored rows matching the filters." },
          "limit": { "type": "integer" },
          "offset": { "type": "integer" },
          "hasMore": { "type": "boolean" },
          "stored": { "type": "integer", "description": "Rows kept in the published report, before filters." },
          "pagesInAudit": { "type": "integer", "description": "Pages the audit crawled." },
          "truncated": { "type": "boolean", "description": "True when `stored` is less than `pagesInAudit`: the report keeps the first 1,000 pages." }
        }
      },
      "EntityMapSummary": {
        "type": "object",
        "description": "Site-wide totals. Describes the WHOLE audit even when the response is filtered.",
        "required": [
          "nodeCount",
          "edgeCount",
          "danglingCount",
          "pagesTotal",
          "pagesWithoutEntities",
          "nodesWithStableId",
          "stableIdShare",
          "pageLocalCount",
          "nodesWithoutIdCount",
          "conflictCount",
          "countsByType"
        ],
        "properties": {
          "nodeCount": { "type": "integer" },
          "edgeCount": { "type": "integer" },
          "danglingCount": {
            "type": "integer",
            "description": "Edges pointing at an `@id` no crawled page declares."
          },
          "pagesTotal": { "type": "integer" },
          "pagesWithoutEntities": { "type": "integer" },
          "nodesWithStableId": {
            "type": "integer",
            "description": "Entities carrying an `@id`."
          },
          "stableIdShare": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "nodesWithStableId as a 0-1 share of nodeCount."
          },
          "pageLocalCount": {
            "type": "integer",
            "description": "Entities tagged `pageLocal` — what a graph hides by default."
          },
          "nodesWithoutIdCount": {
            "type": "integer",
            "description": "Entities with no `@id` declared on more than one page: the identity finding. An entity seen on a single page is not counted."
          },
          "conflictCount": {
            "type": "integer",
            "description": "Entities carrying at least one conflicting property. Counts entities, not properties."
          },
          "countsByType": {
            "type": "object",
            "description": "Occurrence count per schema.org `@type`.",
            "additionalProperties": { "type": "integer" }
          }
        }
      },
      "EntityMapNode": {
        "type": "object",
        "description": "One entity, collapsed across every page that declares it. Every string here comes from site-declared JSON-LD and is untrusted; escape before rendering.",
        "required": [
          "key",
          "id",
          "types",
          "name",
          "properties",
          "occurrences",
          "pages",
          "morePages",
          "conflicts",
          "danglingRefs",
          "pageLocal"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Identity the builder settled on: the resolved `@id` when the site supplied one, otherwise a synthetic type+name key."
          },
          "id": {
            "type": ["string", "null"],
            "description": "The resolved `@id`, or null when the entity declared none."
          },
          "types": { "type": "array", "items": { "type": "string" } },
          "name": { "type": ["string", "null"] },
          "properties": {
            "type": "object",
            "description": "Consistency-relevant properties, normalised to strings.",
            "properties": {
              "name": { "type": "string" },
              "url": { "type": "string" },
              "logo": { "type": "string" },
              "image": { "type": "array", "items": { "type": "string" } },
              "sameAs": { "type": "array", "items": { "type": "string" } },
              "telephone": { "type": "string" },
              "email": { "type": "string" },
              "address": { "type": "string" },
              "description": { "type": "string" }
            }
          },
          "occurrences": {
            "type": "integer",
            "description": "How many times the entity was declared across the crawl."
          },
          "pages": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Declaring pages, sorted and capped; the remainder is in morePages."
          },
          "morePages": { "type": "integer" },
          "conflicts": {
            "type": "array",
            "description": "Properties whose value differs between occurrences.",
            "items": {
              "type": "object",
              "required": ["property", "values"],
              "properties": {
                "property": { "type": "string" },
                "values": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": ["value", "pages", "morePages"],
                    "properties": {
                      "value": { "type": "string" },
                      "pages": { "type": "array", "items": { "type": "string" } },
                      "morePages": { "type": "integer" }
                    }
                  }
                }
              }
            }
          },
          "danglingRefs": {
            "type": "integer",
            "description": "Outgoing `@id` references from this node that nothing declares."
          },
          "pageLocal": {
            "type": "boolean",
            "description": "True when the entity describes one page rather than the site's subject matter: Question, Answer, BreadcrumbList, ListItem, WebPage, and an ImageObject with no name. These are hidden unless `include_page_local` is set."
          }
        }
      },
      "EntityMapEdge": {
        "type": "object",
        "description": "A typed reference from one node to another. A dangling target is deliberately absent from `nodes`.",
        "required": ["source", "predicate", "target", "dangling", "occurrences", "pages", "morePages"],
        "properties": {
          "source": { "type": "string" },
          "predicate": {
            "type": "string",
            "description": "author, publisher, mainEntity, about, isPartOf, sameAs, logo, offers, …"
          },
          "target": { "type": "string" },
          "dangling": {
            "type": "boolean",
            "description": "True when no crawled page declares the target."
          },
          "occurrences": { "type": "integer" },
          "pages": { "type": "array", "items": { "type": "string" } },
          "morePages": { "type": "integer" }
        }
      },
      "EntityMapResponse": {
        "type": "object",
        "description": "The entity-map document plus the context the endpoint adds under `meta`.",
        "required": ["format", "version", "site", "generatedAt", "summary", "nodes", "edges", "meta"],
        "properties": {
          "format": { "type": "string", "const": "squirrelscan/entity-map" },
          "version": { "type": "integer", "const": 1 },
          "site": { "type": "string", "description": "Site the audit started from." },
          "generatedAt": { "type": "string", "format": "date-time" },
          "summary": { "$ref": "#/components/schemas/EntityMapSummary" },
          "nodes": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/EntityMapNode" }
          },
          "edges": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/EntityMapEdge" }
          },
          "pages": {
            "type": "array",
            "description": "Per-page contributions. Empty on hosted maps: the published copy drops it and the summary carries what a reader needs from it.",
            "items": {
              "type": "object",
              "properties": {
                "url": { "type": "string" },
                "declares": { "type": "array", "items": { "type": "string" } },
                "references": { "type": "array", "items": { "type": "string" } },
                "entityCount": { "type": "integer" }
              }
            }
          },
          "meta": {
            "type": "object",
            "required": [
              "reportId",
              "websiteId",
              "auditedAt",
              "filtered",
              "counts",
              "pageFilterIncomplete",
              "backfilled"
            ],
            "properties": {
              "reportId": { "type": "string" },
              "websiteId": { "type": ["string", "null"] },
              "auditedAt": { "type": "string", "format": "date-time" },
              "filtered": {
                "type": "boolean",
                "description": "True when a query filter removed at least one entity."
              },
              "counts": {
                "type": "object",
                "description": "Post-filter totals. Compare against `summary` to see whether this is a subset.",
                "required": ["nodes", "edges"],
                "properties": {
                  "nodes": { "type": "integer" },
                  "edges": { "type": "integer" }
                }
              },
              "pageFilterIncomplete": {
                "type": "boolean",
                "description": "True when a `page` filter ran against a map containing an entity whose declaring-page list was capped. The result may be missing entities that really are declared on the requested page, because the omitted URLs are not in the document. Always false when no `page` filter was given."
              },
              "backfilled": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": ["pageLocalCount", "nodesWithoutIdCount", "conflictCount"]
                },
                "description": "Summary counters that were RECONSTRUCTED because this map was published before the field existed, so they are estimates rather than site totals.\n\n`summary` normally describes the whole audited site while `nodes` may be a projection capped at 750 entities. A reconstructed counter can only be computed from the stored entities, so on a large site it reads low next to its un-reconstructed siblings. Render those fields as \"at least N\", or hide them, rather than as site totals.\n\nEmpty on a map published by a current CLI. Entity-level `pageLocal` is reconstructed exactly and is never listed here."
              }
            }
          }
        }
      },
      "EntityNodeDetail": {
        "type": "object",
        "required": ["reportId", "websiteId", "auditedAt", "node", "pageCount", "outbound", "inbound"],
        "properties": {
          "reportId": { "type": "string" },
          "websiteId": { "type": ["string", "null"] },
          "auditedAt": { "type": "string", "format": "date-time" },
          "node": { "$ref": "#/components/schemas/EntityMapNode" },
          "pageCount": {
            "type": "integer",
            "description": "Total declaring pages, including any beyond the `pages` cap."
          },
          "outbound": {
            "type": "array",
            "description": "Edges from this node, including dangling references.",
            "items": { "$ref": "#/components/schemas/EntityMapEdge" }
          },
          "inbound": {
            "type": "array",
            "description": "Edges pointing at this node.",
            "items": { "$ref": "#/components/schemas/EntityMapEdge" }
          }
        }
      },
      "RuleResult": {
        "type": "object",
        "description": "What one rule a filtered run selected found, structured. Built from the stored report: a rule is `pass` only when it reported a passing check and nothing worse.",
        "required": ["ruleId", "category", "name", "severity", "status", "evidence"],
        "properties": {
          "ruleId": { "type": "string", "description": "The rule id, as listed by `GET /v1/rules`." },
          "category": { "type": "string" },
          "name": { "type": "string", "description": "The rule's title." },
          "severity": { "type": "string", "enum": ["error", "warning", "info"], "description": "The rule's default severity." },
          "status": {
            "type": "string",
            "enum": ["pass", "warn", "fail", "info", "skipped", "not_applicable"],
            "description": "The worst thing the rule reported, in the order `fail`, `warn`, `pass`, `info`. `info` is an informational finding that is neither a pass nor a problem. `skipped`: every check was skipped, or the stored report holds no result for the rule (`skipReason: not_reported`, never a pass). `not_applicable`: every skip says the rule does not apply to this site or page."
          },
          "skipReason": {
            "type": "string",
            "enum": ["not_authenticated", "insufficient_credits", "service_unavailable", "payload_too_large", "credit_cap_reached", "render_failed", "render_disabled", "not_prefetched", "not_applicable", "noindex", "page_type", "private_target", "ignored", "external_links_not_checked", "link_targets_not_fetched", "external_links_over_cap", "external_links_out_of_time", "tls_certificate_not_checked", "crawl_capped", "timed_out", "not_reported", "other"],
            "description": "Why the rule was skipped or did not apply. Present only when `status` is `skipped` or `not_applicable`. `render_disabled` is a run with `render: false`; the cloud ones (`not_authenticated` .. `not_prefetched`) are the cloud steps the catalogue marks `requiresCloud` and `requiresRender`."
          },
          "evidence": { "$ref": "#/components/schemas/RuleResultEvidence" }
        }
      },
      "RuleResultEvidence": {
        "type": "object",
        "description": "Typed evidence of one rule: counts and rule-authored tokens only, never a message, URL or label from the audited site.",
        "required": ["checks", "occurrences", "affectedPages", "checkNames"],
        "properties": {
          "checks": {
            "type": "object",
            "description": "The rule's checks by status (across pages for a page rule). On a capped report the counts are the report's tallies.",
            "required": ["pass", "warn", "fail", "info", "skipped"],
            "properties": {
              "pass": { "type": "integer" },
              "warn": { "type": "integer" },
              "fail": { "type": "integer" },
              "info": { "type": "integer" },
              "skipped": { "type": "integer" }
            }
          },
          "occurrences": { "type": "integer", "description": "Failing and warning occurrences, a folded check counted by what it stands for." },
          "affectedPages": { "type": "integer", "description": "Pages the widest failing or warning finding affects." },
          "checkNames": { "type": "array", "items": { "type": "string" }, "description": "The rule's own check ids that ran, sorted, at most 20. An id that is not a plain token is left out." },
          "bots": {
            "type": "array",
            "description": "Per-bot verdicts. Present only for `ax/ai-crawlers`.",
            "items": {
              "type": "object",
              "required": ["token", "verdict", "source"],
              "properties": {
                "token": { "type": "string", "description": "The crawler's user-agent token from the rule's fixed list, for example `GPTBot`." },
                "verdict": { "type": "string", "enum": ["allowed", "blocked"] },
                "crawlerClass": { "type": "string", "enum": ["training", "ai-search", "user-action", "archive"], "description": "What the crawler is for. Present for blocked bots the rule classed." },
                "source": { "type": "string", "enum": ["robots_txt"], "description": "Where the verdict was read from." }
              }
            }
          }
        }
      },
      "RuleCatalogEntry": {
        "type": "object",
        "description": "One audit rule.",
        "required": ["id", "name", "description", "category", "severity", "weight", "cloud", "requiresCloud", "requiresRender"],
        "properties": {
          "id": { "type": "string", "description": "The rule id (`category/slug`), also an exact pattern for `enabledRulePatterns` and `disabledRulePatterns`.", "examples": ["core/robots-meta"] },
          "name": { "type": "string", "description": "The rule's title." },
          "description": { "type": "string", "description": "What the rule checks." },
          "category": { "type": "string", "description": "The category code the rule sits in (the same as its parent category's `code`)." },
          "severity": { "type": "string", "enum": ["error", "warning", "info"], "description": "The rule's default severity." },
          "weight": { "type": "number", "description": "The rule's weight in the score." },
          "solution": { "type": "string", "description": "How to fix what the rule reports, when the rule has guidance." },
          "cloud": { "type": "boolean", "description": "The same as `requiresCloud`, kept for older clients." },
          "requiresCloud": { "type": "boolean", "description": "True when the rule reads a cloud-backed step. Such rules are slower and credit-metered." },
          "requiresRender": { "type": "boolean", "description": "True when the rule reads the render step (a headless-browser pass). It is skipped on a run with `render: false`." },
          "creditFeature": { "type": "string", "description": "The credit feature a cloud-backed rule is billed under. Present only when `requiresCloud` is true." },
          "creditCost": { "type": "number", "description": "Credits per unit for `creditFeature`. Present only when `requiresCloud` is true." },
          "creditUnit": { "type": "string", "description": "The billing unit for `creditCost` (`page`, `url`, `run`, ...). Present only when `requiresCloud` is true." }
        }
      },
      "RuleCatalogCategory": {
        "type": "object",
        "required": ["code", "name", "description", "priority", "group", "rules"],
        "properties": {
          "code": { "type": "string", "description": "The category code: a bare pattern for `enabledRulePatterns` (`ax`) or a glob with `/*` (`ax/*`)." },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "priority": { "type": "integer", "description": "Sort order: categories are listed by descending priority." },
          "group": { "type": "string", "description": "The top-level group the category rolls up into (for example `seo`)." },
          "rules": { "type": "array", "items": { "$ref": "#/components/schemas/RuleCatalogEntry" } }
        }
      },
      "RuleCatalog": {
        "type": "object",
        "required": ["totalRules", "categories"],
        "properties": {
          "totalRules": { "type": "integer", "description": "Rules in the catalogue, across all categories." },
          "categories": { "type": "array", "items": { "$ref": "#/components/schemas/RuleCatalogCategory" } }
        }
      },
      "CreditsResponse": {
        "type": "object",
        "required": ["balance", "plan", "pricing", "pricingVersion"],
        "properties": {
          "balance": {
            "type": "integer",
            "description": "Available credits for the organization."
          },
          "plan": {
            "type": "object",
            "description": "The organization's plan definition.",
            "additionalProperties": true
          },
          "pricing": {
            "type": "object",
            "description": "Credit cost table keyed by feature.",
            "additionalProperties": true
          },
          "pricingVersion": {
            "type": "integer",
            "description": "Monotonic version of the pricing table."
          },
          "upgrade": {
            "allOf": [{ "$ref": "#/components/schemas/UpgradeOffer" }],
            "description": "The org-targeted upgrade offer, present on every read so a client can render a credit wall without a 402 (the CLI preflight does). Absent for an unmetered organization and for an organization already on Pro or above."
          }
        },
        "example": {
          "balance": 0,
          "plan": { "id": "free", "name": "Free" },
          "pricing": {},
          "pricingVersion": 1,
          "upgrade": {
            "url": "https://app.squirrelscan.com/upgrade?plan=pro&interval=month&org=org_123&src=cli",
            "plan": "pro",
            "interval": "month",
            "name": "Pro",
            "priceMonthUsd": 19,
            "priceYearUsd": 190,
            "monthlyCredits": 3000
          }
        }
      },
      "UpgradeOffer": {
        "type": "object",
        "description": "The upgrade offer attached to a credit wall. The API builds it once; clients render it and never derive a price or link themselves.",
        "required": ["url", "plan", "interval", "name", "priceMonthUsd", "priceYearUsd", "monthlyCredits"],
        "properties": {
          "url": { "type": "string", "format": "uri", "description": "Deep link to checkout for the organization that hit the wall, after login." },
          "plan": { "type": "string", "enum": ["pro"], "description": "Plan slug used in the link." },
          "interval": { "type": "string", "enum": ["month"], "description": "Billing interval the link preselects." },
          "name": { "type": "string", "description": "Display name of the plan." },
          "priceMonthUsd": { "type": "number", "description": "Monthly price in USD." },
          "priceYearUsd": { "type": "number", "description": "Annual price in USD." },
          "monthlyCredits": { "type": "integer", "description": "Credits granted each month." }
        }
      },
      "OrganizationDetail": {
        "type": "object",
        "required": ["organization", "plan", "role"],
        "properties": {
          "organization": {
            "type": "object",
            "required": ["id", "name", "slug", "planId"],
            "properties": {
              "id": { "type": "string" },
              "name": { "type": "string" },
              "slug": { "type": "string" },
              "planId": { "type": "string" },
              "createdAt": { "type": ["string", "null"], "format": "date-time" },
              "updatedAt": { "type": ["string", "null"], "format": "date-time" }
            },
            "additionalProperties": true
          },
          "members": {
            "type": "array",
            "description": "Members of the organization. Returned only to a signed-in caller who is a member (others get 404). Omitted for API keys: a key acts for the organization, not as one of its people, and can outlive the member who made it.",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string" },
                "userId": { "type": "string" },
                "role": { "type": "string", "enum": ["owner", "admin", "editor", "viewer", "billing"] },
                "createdAt": { "type": "string", "format": "date-time" },
                "userName": { "type": ["string", "null"] },
                "userEmail": {
                  "type": ["string", "null"],
                  "format": "email",
                  "description": "PII — a fellow member's email address. Intentionally exposed so org members can see their teammates (the dashboard team view renders it); access is gated by the membership check above. Treat as sensitive: do not log, cache publicly, or surface outside an authenticated org-member context."
                },
                "userAvatarUrl": { "type": ["string", "null"] }
              }
            }
          },
          "plan": {
            "type": "object",
            "properties": {
              "id": { "type": "string" },
              "name": { "type": "string" },
              "maxMembers": { "type": "integer" },
              "monthlyCredits": { "type": "integer" },
              "signupGrantCredits": { "type": "integer" }
            }
          },
          "role": {
            "type": "string",
            "enum": ["owner", "admin", "editor", "viewer", "billing"],
    