{
  "openapi": "3.1.1",
  "info": {
    "title": "Hidden Fee Finder API",
    "version": "1.0.0",
    "summary": "Paste a quote, contract or invoice and see every fee, tax, penalty and add-on.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://hiddenfeefinder.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Paste a quote, contract or invoice and see every fee, tax, penalty and add-on.",
        "description": "Paste the lines of a quote, rental contract, booking or invoice (English or German). Hidden Fee Finder extracts the amounts, classifies each line with transparent keyword rules (base price, fee, tax, surcharge, penalty, deposit, discount, insurance/add-on, recurring), flags conditional penalties and optional add-ons, and shows how much of the total is not the base price.\n\nMethodology:\n- Each non-empty line is scanned for amounts. A number counts as money if it has a currency marker (€, $, £, EUR, USD, GBP, CHF…), exactly two decimals, or ends the line; the last such amount on a line is used. A number followed by % is a percentage.\n- Number formats: with both separators the last one is the decimal mark; \"1,234\" (comma + 3 digits) is read as a thousands separator in auto mode, \"12,50\" as a decimal; choose a fixed format to override.\n- Categories are assigned by ordered keyword rules (total → penalty → deposit → discount → tax → insurance/add-on → surcharge → fee → recurring → base). The first matching keyword is shown. Lines without any keyword default to base price.\n- Flags: conditional (late, cancellation, early termination, if, per day, wenn, falls, Verzug, pro Tag…), recurring (monthly, per year, subscription, monatlich…), optional/hidden (optional, pre-selected, recommended, auto-renew, empfohlen, voreingestellt…), included tax (incl./inkl./included).\n- Payable total = base + fees + taxes + surcharges + insurance/add-ons + recurring + discounts. Excluded: deposits (refundable), conditional lines (only if triggered), total lines, and taxes marked as included.\n- Percent-only lines: taxes are applied to the sum of all other included lines; other percentages are applied to the base total.\n- Non-base share = (payable total − base − discounts) ÷ payable total.",
        "tags": [
          "money"
        ],
        "x-mcp-tool": "hidden_fee_finder",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HiddenFeeFinderInput"
              },
              "examples": {
                "example1": {
                  "summary": "Hotel booking with resort fee and conditional charges",
                  "value": {
                    "currency": "USD",
                    "text": "Room rate, 3 nights: $420.00\nResort fee (mandatory): $105.00\nCity tax: 6%\nTravel insurance (pre-selected, optional): $29.99\nLate checkout fee if after 12:00: $50.00\nSecurity deposit (refundable): $200.00\nMember discount: -$21.00\nTotal: $566.03"
                  }
                },
                "example2": {
                  "summary": "German rental quote",
                  "value": {
                    "currency": "EUR",
                    "numberFormat": "de",
                    "text": "Grundpreis Miete Transporter 1 Tag 89,00 €\nBearbeitungsgebühr 15,00 €\nWochenendzuschlag 20,00 €\nVollkaskoversicherung optional 24,90 €\nKaution 300,00 €\nVertragsstrafe bei verspäteter Rückgabe pro Tag 75,00 €\nGesamtbetrag inkl. 19% MwSt. 148,90 €"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HiddenFeeFinderResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "HiddenFeeFinderInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "Quote / contract / invoice lines",
            "description": "One cost per line. Supported amount formats: 1,234.56 / 1.234,56 / €12 / 12 EUR / 12,50 € and percentages like 19% or 2.5 %.",
            "type": "string",
            "maxLength": 50000
          },
          "items": {
            "title": "Or: line items",
            "description": "Optional alternative to pasting text. Rows are appended after the pasted lines.",
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "description": {
                  "title": "Description",
                  "type": "string"
                },
                "amount": {
                  "title": "Amount",
                  "type": "number"
                }
              },
              "required": [
                "description",
                "amount"
              ]
            }
          },
          "currency": {
            "title": "Currency",
            "type": "string",
            "maxLength": 8,
            "default": "EUR"
          },
          "numberFormat": {
            "title": "Number format",
            "type": "string",
            "enum": [
              "auto",
              "en",
              "de"
            ],
            "default": "auto"
          }
        },
        "required": []
      },
      "HiddenFeeFinderResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "currency",
              "lines",
              "totals",
              "statedTotal",
              "statedTotalDifference",
              "hiddenOrOptional",
              "conditionalCharges"
            ],
            "properties": {
              "currency": {
                "type": "string"
              },
              "statedTotal": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Amount on the last line recognised as a total, if any."
              },
              "statedTotalDifference": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Stated total − computed payable total."
              },
              "totals": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "base",
                  "fees",
                  "taxes",
                  "surcharges",
                  "insuranceAddons",
                  "recurring",
                  "discounts",
                  "payableTotal",
                  "nonBaseCosts",
                  "nonBaseSharePercent",
                  "deposits",
                  "conditionalPotential",
                  "upfrontCashInclDeposits"
                ],
                "properties": {
                  "base": {
                    "type": "number"
                  },
                  "fees": {
                    "type": "number"
                  },
                  "taxes": {
                    "type": "number"
                  },
                  "surcharges": {
                    "type": "number"
                  },
                  "insuranceAddons": {
                    "type": "number"
                  },
                  "recurring": {
                    "type": "number"
                  },
                  "discounts": {
                    "type": "number",
                    "description": "Negative number."
                  },
                  "payableTotal": {
                    "type": "number",
                    "description": "Sum of all lines included in the total (excludes deposits, conditional charges, totals and taxes stated as included)."
                  },
                  "nonBaseCosts": {
                    "type": "number",
                    "description": "fees + taxes + surcharges + insurance/add-ons + recurring (non-base lines)."
                  },
                  "nonBaseSharePercent": {
                    "type": "number",
                    "description": "nonBaseCosts ÷ payableTotal × 100."
                  },
                  "deposits": {
                    "type": "number"
                  },
                  "conditionalPotential": {
                    "type": "number",
                    "description": "Sum of conditional charges (only due if triggered)."
                  },
                  "upfrontCashInclDeposits": {
                    "type": "number"
                  }
                }
              },
              "lines": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "lineNumber",
                    "text",
                    "amount",
                    "percent",
                    "amountSource",
                    "category",
                    "matchedKeyword",
                    "recurring",
                    "recurringKeyword",
                    "conditional",
                    "conditionalKeyword",
                    "optional",
                    "optionalKeyword",
                    "includedTax",
                    "includedInTotal"
                  ],
                  "properties": {
                    "lineNumber": {
                      "type": "integer"
                    },
                    "text": {
                      "type": "string"
                    },
                    "amount": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "percent": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "amountSource": {
                      "type": "string",
                      "enum": [
                        "stated",
                        "derived-from-percent",
                        "none"
                      ]
                    },
                    "category": {
                      "type": "string",
                      "enum": [
                        "base",
                        "fee",
                        "tax",
                        "surcharge",
                        "penalty",
                        "deposit",
                        "discount",
                        "insurance-addon",
                        "recurring",
                        "total",
                        "info"
                      ]
                    },
                    "matchedKeyword": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Keyword that triggered the category (null = default base price)."
                    },
                    "recurring": {
                      "type": "boolean"
                    },
                    "recurringKeyword": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "conditional": {
                      "type": "boolean"
                    },
                    "conditionalKeyword": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "optional": {
                      "type": "boolean"
                    },
                    "optionalKeyword": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "includedTax": {
                      "type": "boolean",
                      "description": "Tax stated as already included (e.g. \"incl. VAT\"); not added again."
                    },
                    "includedInTotal": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "hiddenOrOptional": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "conditionalCharges": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}