{
  "openapi": "3.1.0",
  "info": {
    "title": "WebhookSLA Guard API & Webhook Security Auditor",
    "version": "1.0.0",
    "description": "Instant B2B SaaS API & Webhook Security, HMAC-SHA256 Replay Protection, Idempotency-Key & RFC RateLimit Readiness Auditor (live URL scan + zero-network offline header/config audit).",
    "contact": {
      "name": "RungLab Support",
      "email": "support@runglab.dev",
      "url": "https://webhook.runglab.dev/"
    }
  },
  "servers": [
    {
      "url": "https://webhook-api.runglab.dev",
      "description": "WebhookSLA Guard Edge Audit Worker"
    },
    {
      "url": "https://api.runglab.dev",
      "description": "RungLab Funnel & Checkout API"
    }
  ],
  "paths": {
    "/api/audit": {
      "get": {
        "operationId": "auditWebhookSlaUrl",
        "summary": "Audit a live public URL/domain for RateLimit headers, CORS, HSTS/CSP/nosniff, HMAC-SHA256 replay protection, Idempotency-Key, OpenAPI, status & security.txt",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "Public API or website URL to audit (e.g. https://stripe.com)",
            "schema": {
              "type": "string",
              "example": "https://stripe.com"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "100-point API & Webhook SLA Readiness scorecard with Before->After $29 Kit projection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAuditReport"
                }
              }
            }
          },
          "400": { "description": "Invalid target URL" },
          "422": { "description": "Blocked by SSRF policy" }
        }
      }
    },
    "/api/audit-headers": {
      "post": {
        "operationId": "auditOfflineWebhookHeaders",
        "summary": "Zero-network offline audit of pasted HTTP response headers and/or webhookConfig JSON",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": { "type": "string" },
                  "rawHeaders": { "type": "string" },
                  "headers": { "type": "object" },
                  "webhookConfig": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Offline 100-point WebhookSLA Guard scorecard (0 subrequests)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookAuditReport"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getWebhookSlaHealth",
        "summary": "Verify WebhookSLA Guard worker health",
        "responses": {
          "200": {
            "description": "Healthy worker status JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean" },
                    "service": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WebhookAuditReport": {
        "type": "object",
        "properties": {
          "mode": { "type": "string", "enum": ["live-url", "offline-headers"] },
          "domain": { "type": "string" },
          "overallScore": { "type": "integer", "minimum": 0, "maximum": 100 },
          "grade": { "type": "string" },
          "beforeAfterUplift": { "type": "object" },
          "findings": { "type": "array", "items": { "type": "object" } }
        }
      }
    }
  }
}
