{
  "openapi": "3.1.0",
  "info": {
    "title": "Debt Snowball Tool Public API",
    "version": "1.0.0",
    "description": "Read-only debt payoff projection. Compares the snowball and avalanche methods on caller-supplied debts. No authentication, no storage."
  },
  "servers": [
    {
      "url": "https://debtsnowballtool.com"
    }
  ],
  "security": [],
  "paths": {
    "/api/payoff": {
      "post": {
        "operationId": "comparePayoffMethods",
        "summary": "Compare snowball vs avalanche for a list of debts",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PayoffRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Projection for both methods",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayoffResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "health",
        "summary": "Service health",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Debt": {
        "type": "object",
        "required": [
          "name",
          "balance"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Label for the debt, e.g. \"Card A\""
          },
          "balance": {
            "type": "number",
            "minimum": 0,
            "description": "Outstanding balance in USD"
          },
          "apr": {
            "type": "number",
            "minimum": 0,
            "description": "Yearly APR as a percentage, e.g. 21.9"
          },
          "minPayment": {
            "type": "number",
            "minimum": 0,
            "description": "Minimum monthly payment in USD"
          }
        }
      },
      "PayoffRequest": {
        "type": "object",
        "required": [
          "debts"
        ],
        "properties": {
          "debts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/Debt"
            }
          },
          "extra": {
            "type": "number",
            "minimum": 0,
            "default": 0,
            "description": "Monthly amount paid above all minimums, USD"
          }
        }
      },
      "PayoffResult": {
        "type": "object",
        "description": "snowball, avalanche, interestDifference, cheaper, faster. Each method object carries months, totalInterest, payoffOrder, paidOff, timeline and perDebt (interest, principal and clearedMonth for each debt; the perDebt interest values sum to totalInterest)."
      }
    }
  }
}