{
  "openapi": "3.1.0",
  "info": {
    "title": "InstructLint API",
    "version": "1.0.0",
    "description": "Deterministic drift audits for public GitHub coding-agent instructions. Preview is free; the full report uses an x402 v2 payment challenge.",
    "x-guidance": "POST a canonical public GitHub repository URL as repoUrl. Use /api/preview for the free bounded result or /api/report for the $1 USDC evidence and suggested-patch report.",
    "contact": {
      "name": "InstructLint support",
      "url": "https://github.com/BahirHakimy/instructlint/issues"
    }
  },
  "servers": [
    {
      "url": "https://instructlint.vercel.app"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getServiceHealth",
        "summary": "Check service and payment readiness",
        "security": [],
        "responses": {
          "200": {
            "description": "Current service readiness"
          }
        }
      }
    },
    "/api/preview": {
      "post": {
        "operationId": "previewRepositoryAudit",
        "summary": "Preview instruction drift for a public GitHub repository",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RepositoryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Redacted audit preview without evidence or patch suggestions"
          },
          "400": {
            "description": "Invalid request or repository URL"
          },
          "404": {
            "description": "Public repository not found"
          },
          "429": {
            "description": "Preview rate limit reached"
          }
        }
      }
    },
    "/api/report": {
      "post": {
        "operationId": "purchaseRepositoryAudit",
        "summary": "Purchase the evidence-linked audit and suggested patch",
        "description": "An unpaid request receives an x402 v2 PAYMENT-REQUIRED challenge. A compatible client authorizes $1 USDC on Base and retries with its payment signature. Payment settles only after the full report handler returns a successful response; application errors are not settled.",
        "x-x402": {
          "version": 2,
          "network": "eip155:8453",
          "price": "$1.00",
          "settlement": "after-successful-handler-response"
        },
        "x-payment-info": {
          "protocols": [
            {
              "x402": {}
            }
          ],
          "price": {
            "mode": "fixed",
            "currency": "USD",
            "amount": "1.00"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RepositoryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Full audit with evidence and suggested instruction patches"
          },
          "402": {
            "description": "Payment required; challenge is returned in PAYMENT-REQUIRED"
          },
          "400": {
            "description": "Invalid JSON, request shape, or repository URL; payment is not settled"
          },
          "403": {
            "description": "Private repositories are unsupported; payment is not settled"
          },
          "404": {
            "description": "Public repository not found; payment is not settled"
          },
          "413": {
            "description": "Request or bounded repository snapshot exceeds service limits; payment is not settled"
          },
          "429": {
            "description": "GitHub upstream rate limit reached; payment is not settled"
          },
          "500": {
            "description": "Unexpected audit failure; payment is not settled"
          },
          "502": {
            "description": "GitHub returned an unavailable or invalid response; payment is not settled"
          },
          "504": {
            "description": "GitHub retrieval timed out; payment is not settled"
          },
          "503": {
            "description": "Paid reports are not currently configured"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "RepositoryRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "repoUrl"
        ],
        "properties": {
          "repoUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://github\\.com/[^/]+/[^/]+/?$",
            "examples": [
              "https://github.com/owner/repository"
            ]
          }
        }
      }
    }
  }
}
