{
  "openapi": "3.1.0",
  "info": {
    "title": "ConsentCheck by RungLab — GDPR, ePrivacy, CCPA GPC & Google Consent Mode v2 Auditor",
    "version": "1.0.0",
    "description": "Deterministic 100-point privacy & consent compliance auditor covering Google Consent Mode v2 (25 pts), Pre-Consent Tracker Gating (25 pts), Pre-Consent Set-Cookie Hygiene (20 pts), CCPA /.well-known/gpc.json (10 pts), Privacy/Cookie/Opt-Out Links (10 pts), and Privacy Transport & Referrer Hygiene (10 pts), plus a $39 6-File Fix Pack.",
    "contact": {
      "name": "RungLab Support",
      "email": "support@runglab.dev",
      "url": "https://consent.runglab.dev/"
    }
  },
  "servers": [
    {
      "url": "https://consent-api.runglab.dev",
      "description": "ConsentCheck Edge Audit Worker"
    },
    {
      "url": "https://api.runglab.dev",
      "description": "RungLab Checkout, Lead & Funnel Telemetry API"
    }
  ],
  "paths": {
    "/api/audit": {
      "get": {
        "operationId": "auditConsentUrl",
        "summary": "Audit a live public webpage for Google Consent Mode v2, pre-consent trackers, Set-Cookie hygiene, /.well-known/gpc.json, policy links & referrer hygiene",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Public webpage URL or domain to audit (e.g. https://stripe.com)",
            "schema": {
              "type": "string",
              "example": "https://stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "100-point ConsentCheck audit report with beforeAfterPreview for the $39 Fix Pack",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsentAuditReport"
                }
              }
            }
          },
          "400": { "description": "Invalid target URL" },
          "422": { "description": "Blocked by SSRF policy" }
        }
      },
      "post": {
        "operationId": "auditConsentUrlPost",
        "summary": "Audit a live public webpage URL via JSON POST { url }",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url"],
                "properties": {
                  "url": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "100-point ConsentCheck audit report"
          }
        }
      }
    },
    "/api/audit-html": {
      "post": {
        "operationId": "auditOfflineConsentHtml",
        "summary": "Zero-network offline audit of pasted HTML, optional Set-Cookie headers, and optional gpc.json payload",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["html"],
                "properties": {
                  "url": { "type": "string" },
                  "html": { "type": "string" },
                  "setCookies": { "type": "array", "items": { "type": "string" } },
                  "gpcJson": { "type": "object" },
                  "rawHeaders": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Offline 100-point ConsentCheck scorecard (0 subrequests)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsentAuditReport"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getConsentCheckHealth",
        "summary": "Verify ConsentCheck worker health",
        "responses": {
          "200": {
            "description": "Healthy worker status JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "service": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ConsentAuditReport": {
        "type": "object",
        "properties": {
          "mode": { "type": "string", "enum": ["live-url", "offline-html"] },
          "domain": { "type": "string" },
          "overallScore": { "type": "integer", "minimum": 0, "maximum": 100 },
          "grade": { "type": "string" },
          "beforeAfterPreview": { "type": "object" },
          "findings": { "type": "array", "items": { "type": "object" } }
        }
      }
    }
  }
}
