{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pageaudit/json-schema/pageaudit-workspace-schema.json",
  "title": "Workspace",
  "description": "The owner's whole workspace, with the active tab's result already rehydrated — one call to draw the screen.",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pageaudit-tabs-api-openapi.yml#/components/schemas/Workspace",
  "type": "object",
  "properties": {
    "tabs": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Aba"
      },
      "description": "Every tab of the owner."
    },
    "active_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Which tab is in focus."
    },
    "active_result": {
      "allOf": [
        {
          "$ref": "#/$defs/AuditGravado"
        }
      ],
      "description": "The last result of the active tab, so a second call is not needed.",
      "nullable": true
    },
    "limit": {
      "type": "integer",
      "description": "How many tabs fit before paying."
    },
    "owner": {
      "type": "string",
      "description": "Identifier of this workspace's owner."
    },
    "gate": {
      "allOf": [
        {
          "$ref": "#/$defs/Gate"
        }
      ],
      "description": "How much of the IP's free allowance remains."
    },
    "billing": {
      "type": "object",
      "description": "Prices and usage, the same `GET /api/billing` returns."
    }
  },
  "required": [
    "tabs",
    "active_id",
    "active_result",
    "limit",
    "owner",
    "gate",
    "billing"
  ],
  "$defs": {
    "Aba": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "ID of the tab."
        },
        "url": {
          "type": "string",
          "description": "URL the tab follows."
        },
        "alias": {
          "type": [
            "string",
            "null"
          ],
          "description": "Label the person gave the tab."
        },
        "active": {
          "type": "boolean",
          "description": "Whether it is the focused tab in the workspace."
        },
        "audit_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Audit of this tab's last run."
        },
        "score": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Score of the last run."
        },
        "created_at": {
          "type": "string",
          "description": "When the tab was opened (UTC)."
        }
      },
      "required": [
        "id",
        "url",
        "alias",
        "active",
        "audit_id",
        "score",
        "created_at"
      ],
      "description": "A workspace tab: one followed URL, with the last result kept."
    },
    "Achado": {
      "type": "object",
      "properties": {
        "severity": {
          "type": "string",
          "description": "Severity of the finding."
        },
        "code": {
          "type": "string",
          "description": "Stable check code, e.g. `title_missing`. It is what you filter by."
        },
        "message": {
          "type": "string",
          "description": "The finding in one sentence, ready to show a person."
        }
      },
      "required": [
        "severity",
        "code",
        "message"
      ],
      "description": "A problem (or a pass) found on the page."
    },
    "AuditGravado": {
      "type": "object",
      "properties": {
        "audit_id": {
          "type": "string",
          "description": "ID of the audit."
        },
        "url": {
          "type": "string",
          "description": "Final audited URL, after following the redirects."
        },
        "score": {
          "type": "integer",
          "description": "Score from 0 to 100."
        },
        "summary": {
          "allOf": [
            {
              "$ref": "#/$defs/ResumoPagina"
            }
          ],
          "description": "What the page declared at the time of the run.",
          "nullable": true
        },
        "counts": {
          "allOf": [
            {
              "$ref": "#/$defs/ContagemAchados"
            }
          ],
          "description": "How many findings of each severity."
        },
        "issues": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Achado"
          },
          "description": "Everything found in that run."
        },
        "fixes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Correcao"
          },
          "description": "The ready fix of each finding; an audit stored before this existed gets the computation on read."
        },
        "jsonLd": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "The raw JSON-LD blocks stored."
        },
        "headers": {
          "type": "object",
          "description": "Headers of the target's response, as they were in the run."
        },
        "truncated": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "What was cut by size when storing."
        },
        "share_slug": {
          "type": [
            "string",
            "null"
          ],
          "description": "Public slug, if this audit was shared."
        },
        "created_at": {
          "type": "string",
          "description": "When the run happened (UTC)."
        }
      },
      "required": [
        "audit_id",
        "url",
        "score",
        "summary",
        "counts",
        "issues",
        "fixes",
        "jsonLd",
        "headers",
        "truncated",
        "share_slug",
        "created_at"
      ],
      "description": "The same report re-read from the database. It has no `quota` and no `_links` (it is a read, not a run) and gains the date and the share slug."
    },
    "ContagemAchados": {
      "type": "object",
      "properties": {
        "errors": {
          "type": "integer",
          "description": "Serious findings."
        },
        "warnings": {
          "type": "integer",
          "description": "Findings that deserve attention."
        },
        "info": {
          "type": "integer",
          "description": "Observations without severity."
        }
      },
      "required": [
        "errors",
        "warnings",
        "info"
      ],
      "description": "How many findings of each severity — the summary that fits in a badge."
    },
    "Correcao": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "The same `code` as the finding (`Achado.code`)."
        },
        "severity": {
          "type": "string",
          "description": "Severity of the source finding."
        },
        "classe": {
          "type": "string",
          "description": "`deterministico` comes whole from the page; `molde` has a `{{…}}` placeholder; `sem_patch` is an instruction."
        },
        "alvo": {
          "type": "string",
          "description": "Where to apply: `head`, `corpo`, `img`, `arquivo` or `pagina` (instruction)."
        },
        "snippet": {
          "type": [
            "string",
            "null"
          ],
          "description": "The ready tag (or with a placeholder). `null` for files and for `sem_patch`."
        },
        "arquivo": {
          "type": [
            "object",
            "null"
          ],
          "description": "`path` and `conteudo` when the fix is a file at the host root."
        },
        "fonte": {
          "type": [
            "string",
            "null"
          ],
          "description": "Where the value came from, or what the page already had (for the template or to check the cut)."
        },
        "nota": {
          "type": [
            "string",
            "null"
          ],
          "description": "How to apply, or what to decide."
        }
      },
      "required": [
        "code",
        "severity",
        "classe",
        "alvo",
        "snippet",
        "arquivo",
        "fonte",
        "nota"
      ],
      "description": "The ready fix of one finding. `classe` says whether it is to paste, to fill in or to decide."
    },
    "Gate": {
      "type": "object",
      "properties": {
        "ip": {
          "type": "string",
          "description": "IP seen by the edge, already masked."
        },
        "now": {
          "type": "integer",
          "description": "Time of the query, in epoch."
        },
        "configured": {
          "type": "boolean",
          "description": "Whether Turnstile is configured in this environment."
        },
        "free_allowance": {
          "type": "integer",
          "description": "Free audits per day."
        },
        "free_remaining": {
          "type": "integer",
          "description": "How many remain today for this IP."
        },
        "verified_until": {
          "type": [
            "integer",
            "null"
          ],
          "description": "Until when the verification already done is valid."
        },
        "needs_verification": {
          "type": "boolean",
          "description": "`true` when the next call will ask for Turnstile (human) or 402 (agent)."
        },
        "sitekey": {
          "type": [
            "string",
            "null"
          ],
          "description": "Turnstile sitekey, for the browser to build the challenge."
        }
      },
      "required": [
        "ip",
        "now",
        "configured",
        "free_allowance",
        "free_remaining",
        "verified_until",
        "needs_verification",
        "sitekey"
      ],
      "description": "How much of the daily allowance still exists for this IP, and whether Turnstile is already required."
    },
    "ResumoPagina": {
      "type": "object",
      "properties": {
        "finalUrl": {
          "type": "string",
          "description": "URL after following every redirect."
        },
        "status": {
          "type": "integer",
          "description": "Final HTTP status of the target."
        },
        "contentType": {
          "type": [
            "string",
            "null"
          ],
          "description": "Content-Type of the final response."
        },
        "title": {
          "type": [
            "string",
            "null"
          ],
          "description": "Content of `<title>`."
        },
        "metaDescription": {
          "type": [
            "string",
            "null"
          ],
          "description": "Content of `<meta name=description>`."
        },
        "canonical": {
          "type": [
            "string",
            "null"
          ],
          "description": "Canonical URL declared by the page."
        },
        "robots": {
          "type": [
            "string",
            "null"
          ],
          "description": "Content of `<meta name=robots>`."
        },
        "viewport": {
          "type": [
            "string",
            "null"
          ],
          "description": "Content of `<meta name=viewport>`."
        },
        "charset": {
          "type": [
            "string",
            "null"
          ],
          "description": "Declared encoding."
        },
        "lang": {
          "type": [
            "string",
            "null"
          ],
          "description": "Language declared in `<html lang>`."
        },
        "favicon": {
          "type": [
            "string",
            "null"
          ],
          "description": "URL of the favicon found."
        },
        "faviconSource": {
          "type": [
            "string",
            "null"
          ],
          "description": "How the favicon was found: declared or by the default path."
        },
        "h1s": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Every `<h1>` on the page, in order."
        },
        "openGraph": {
          "type": "object",
          "description": "The `og:*` tags found, key by key."
        },
        "twitter": {
          "type": "object",
          "description": "The `twitter:*` tags found."
        },
        "jsonLdCount": {
          "type": "integer",
          "description": "How many JSON-LD nodes the page had."
        },
        "jsonLdBlocks": {
          "type": "integer",
          "description": "How many `<script type=application/ld+json>` blocks existed."
        },
        "jsonLdDropped": {
          "type": "boolean",
          "description": "`true` when nodes were dropped for passing the cap."
        },
        "jsonLdTypes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The `@type`s found, e.g. `Organization`, `WebSite`."
        },
        "images": {
          "type": "object",
          "description": "Image count and how many have no `alt`."
        },
        "links": {
          "type": "object",
          "description": "Count of internal, external and text-less links."
        },
        "words": {
          "type": "integer",
          "description": "Words in the visible content."
        },
        "hreflang": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "The declared language alternates."
        },
        "legacy": {
          "type": "object",
          "description": "Old markup still present (e.g. `<font>`, layout tables)."
        },
        "redirects": {
          "type": "array",
          "items": {
            "type": "object"
          },
          "description": "The redirect chain followed to the final URL."
        },
        "robotsTxt": {
          "type": "object",
          "description": "What the origin's `robots.txt` says about this URL."
        },
        "sitemap": {
          "type": "object",
          "description": "Whether the URL appears in the sitemap the origin declares."
        }
      },
      "required": [
        "finalUrl",
        "status",
        "contentType",
        "title",
        "metaDescription",
        "canonical",
        "robots",
        "viewport",
        "charset",
        "lang",
        "favicon",
        "faviconSource",
        "h1s",
        "openGraph",
        "twitter",
        "jsonLdCount",
        "jsonLdBlocks",
        "jsonLdDropped",
        "jsonLdTypes",
        "images",
        "links",
        "words",
        "hreflang",
        "legacy",
        "redirects",
        "robotsTxt",
        "sitemap"
      ],
      "description": "Everything the page declares about itself. It is the most consulted object of the API."
    }
  }
}