{
  "openapi": "3.1.0",
  "info": {
    "title": "webcheck free check API",
    "summary": "Check whether a website does what it was asked to do. One verdict, a score out of 100, sub-scores and a fix list. One free check per site, no key.",
    "description": "webcheck opens up to 20 pages of the target site, probes links, images and forms, and answers whether the site does what its brief says. The brief is optional; without it webcheck reads the promise from the homepage. This is the free, keyless surface. The plan adds a key-authed API at /api/v1/check with 100 checks a month (https://webcheck.nanocorp.app/plan).",
    "version": "1.0.0",
    "contact": { "email": "webcheck@nanocorp.app" },
    "termsOfService": "https://webcheck.nanocorp.app/plan"
  },
  "servers": [{ "url": "https://webcheck.nanocorp.app" }],
  "paths": {
    "/api/check": {
      "post": {
        "operationId": "startCheck",
        "summary": "Start a check of one site",
        "description": "Starts a check and returns immediately. One free check per site; a site that has already used its free check answers 409 with the existing report URL. CORS is open so browser agents can call this.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url"],
                "properties": {
                  "url": { "type": "string", "description": "The site address, https://…", "example": "https://your-site.com" },
                  "brief": { "type": "string", "description": "What the site was supposed to do. Optional; without it the promise is read from the homepage.", "maxLength": 2000 }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The check is running. Poll GET /api/check/{id}.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CheckStarted" }
              }
            }
          },
          "400": { "description": "invalid_address — the address did not open or is not reachable.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "409": {
            "description": "free_check_used — this site already used its free check. The response carries report_url of the existing public report.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UsedError" } } }
          },
          "429": { "description": "rate_limited — too many checks from one address. Wait, then try again.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/check/{id}": {
      "get": {
        "operationId": "getCheck",
        "summary": "Read a check's result",
        "description": "Poll while status is running; a check usually takes under three minutes. When done, the verdict is the literal lowercase word pass or fix.",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }
        ],
        "responses": {
          "200": {
            "description": "The check. While running only id, url, status and steps_done are set.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CheckResult" } } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CheckStarted": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "status": { "type": "string", "const": "running" }
        }
      },
      "CheckResult": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "url": { "type": "string" },
          "status": { "type": "string", "enum": ["running", "done", "error"] },
          "steps_done": { "type": "array", "items": { "type": "string" } },
          "verdict": { "type": "string", "enum": ["pass", "fix"], "description": "pass if the site does what was asked with no high-severity breakage; fix otherwise." },
          "score": { "type": "integer", "minimum": 0, "maximum": 100 },
          "subscores": {
            "type": "object",
            "properties": {
              "broken": { "type": "integer" },
              "promise": { "type": "integer" },
              "seo": { "type": "integer" },
              "speed": { "type": "integer" },
              "security": { "type": "integer" }
            }
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "family": { "type": "string", "enum": ["broken", "promise", "seo", "security"] },
                "severity": { "type": "string", "enum": ["high", "medium", "low"] },
                "page": { "type": "string", "description": "Where the issue was found." },
                "problem": { "type": "string", "description": "What is wrong, in one sentence." },
                "fix": { "type": "string", "description": "How to fix it." }
              }
            }
          },
          "pages_checked": { "type": "integer" },
          "report_url": { "type": "string", "description": "The public human-readable report." }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "description": "A plain sentence, safe to show a human." },
          "code": { "type": "string", "enum": ["invalid_address", "invalid_body", "rate_limited"] }
        }
      },
      "UsedError": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "code": { "type": "string", "const": "free_check_used" },
          "report_url": { "type": "string", "description": "The existing public report for this site." }
        }
      }
    }
  }
}
