Mortgage · Calculation
Compare entered refinance alternatives
Model ten distinct refinance scenarios using a final note rate and quoted closing costs supplied for each alternative. The supported quotes cover a lower rate, shorter term, paying the same amount, PMI removal, FHA to conventional, ARM to fixed, cash out, debt consolidation, VA IRRRL and FHA streamline. Filter by a goal or rank the entered quotes by monthly savings, lifetime savings, break-even or cash received.
This HT Calc screen includes a Pro sample for visitors.
- Cost per success
- 2 calculation credits
- Production plans
- Standard, Business, Scale, Enterprise
Plan allowances - Free sandbox
- Not available
Integration example
Make a request
Use a production key scoped to quoted-refinance-alternatives.
Keep the key on your server. A successful call uses 2 calculation credits.
Set HT_PRODUCTION_KEY on your server. Save as example.mjs and run node example.mjs with Node.js 18 or later.
import { randomUUID } from "node:crypto";
const key = process.env.HT_PRODUCTION_KEY;
if (!key) throw new Error("Set HT_PRODUCTION_KEY on your server.");
const endpoint = "https://calc.hasstechapi.com/v2/calc/quoted-refinance-alternatives";
const input = {
"profile": {
"current": {
"balance": 300000,
"rate": 7.25,
"monthlyPI": 2229,
"monthsRemaining": 288,
"loanType": "conventional",
"hasMI": true
},
"property": {
"estimatedValue": 400000,
"originalValue": 380000,
"type": "single-family",
"occupancy": "primary"
},
"borrower": {
"creditTier": "excellent",
"isVeteran": false,
"seasonedSixMonths": true,
"expectedYearsToStay": 7
},
"goals": [
"lower-payment"
]
},
"quotes": [
{
"mode": "lower-rate",
"noteRate": 6,
"closingCosts": 3500
},
{
"mode": "cash-out",
"noteRate": 6.5,
"closingCosts": 5000
}
]
};
const requestId = process.env.HT_REQUEST_ID || Date.now() + "." + randomUUID();
// Keep this ID to look up usage if the connection is interrupted.
console.error("Usage lookup ID:", requestId);
const response = await fetch(endpoint, {
method: "POST",
redirect: "error",
headers: {
"Authorization": "Bearer " + key,
"Content-Type": "application/json",
"Idempotency-Key": requestId
},
body: JSON.stringify(input)
});
if (!response.ok) {
const problem = await response.json().catch(() => null);
const code = problem?.error?.code || response.statusText;
const delay = response.headers.get("retry-after");
if (delay) console.error("Retry-After (seconds):", delay);
console.error("HTTP " + response.status + " " + code + ". Usage lookup ID: " + requestId);
if (Array.isArray(problem?.error?.details)) {
for (const issue of problem.error.details) console.error("Input issue:", JSON.stringify(issue));
}
process.exitCode = 1;
} else {
console.log(JSON.stringify(await response.json(), null, 2));
} cURL (shell)
(
set -eu
: "${HT_PRODUCTION_KEY:?Set HT_PRODUCTION_KEY on your server}"
request_id="${HT_REQUEST_ID:-}"
if [ -z "$request_id" ]; then
request_id=$(python3 -c 'import time, uuid; print(str(time.time_ns() // 1000000) + "." + str(uuid.uuid4()))')
fi
printf 'Usage lookup ID: %s\n' "$request_id" >&2
# On INVALID_INPUT, read error.details in the JSON response body.
curl --disable --silent --show-error --fail-with-body --include \
--request POST 'https://calc.hasstechapi.com/v2/calc/quoted-refinance-alternatives' \
--header "Authorization: Bearer $HT_PRODUCTION_KEY" \
--header 'Content-Type: application/json' \
--header "Idempotency-Key: $request_id" \
--data-binary @- <<'HT_INPUT'
{
"profile": {
"current": {
"balance": 300000,
"rate": 7.25,
"monthlyPI": 2229,
"monthsRemaining": 288,
"loanType": "conventional",
"hasMI": true
},
"property": {
"estimatedValue": 400000,
"originalValue": 380000,
"type": "single-family",
"occupancy": "primary"
},
"borrower": {
"creditTier": "excellent",
"isVeteran": false,
"seasonedSixMonths": true,
"expectedYearsToStay": 7
},
"goals": [
"lower-payment"
]
},
"quotes": [
{
"mode": "lower-rate",
"noteRate": 6,
"closingCosts": 3500
},
{
"mode": "cash-out",
"noteRate": 6.5,
"closingCosts": 5000
}
]
}
HT_INPUT
) If your request fails
400 INVALID_INPUT-
Read
error.detailswhen present. Node prints each issue. cURL returns the JSON body. Eachpathpoints into your request. An empty path refers to the whole body.Check the accepted inputs for required fields, units and ranges. Send the corrected JSON as a new request.
401or403- Check that the server has the bearer key for the endpoint’s environment and that the key includes
quoted-refinance-alternatives. 429- Read the service error code, check your allowance, and wait for the
Retry-Afterinterval when supplied before trying again. - Lost response,
409or503 - Open Request lookup, select the same environment and enter the printed usage lookup ID. A settled ID has already consumed credits. To retry the same calculation, set
HT_REQUEST_IDto the original ID and reuse the same inputs. A settled request does not return its result again. Unset the variable for a new request, which can consume credits.
The usage lookup ID is the Idempotency-Key your server sends. The response’s x-request-id identifies the HTTP exchange for support.
Output
Example result
These values come from running this operation on the example inputs.
How to interpret this result
- All quotes, including loan-specific price adjustments, come from the caller. The app’s November 2026 scenario rules determine whether the requested alternative applies. No credit decision or rate lookup is provided. The caller supplies costs in dollars. Program mortgage insurance, other than quoted costs, uses the pinned app assumptions.
- The original strategy worksheet rounds its displayed payment estimates to whole US dollars.
- Ranking follows the app’s model criteria. Recasting is informational until the servicer supplies terms.
{
"status": "available",
"result": {
"scenarios": [
{
"mode": "lower-rate",
"status": "available",
"newRate": 6,
"newTermYears": 24,
"newLoanAmount": 300000,
"newMonthlyPI": 1968,
"newPmiMonthly": 0,
"monthlySavings": 261,
"lifetimeInterestSavings": 75187,
"cashReceived": null,
"cashToClose": 3500,
"closingCostsEstimate": 3500,
"breakEvenMonths": 14,
"fiveYearNetSavings": 12160,
"withinHorizon": true,
"taxAdjustedSavings": null,
"equityBefore": 100000,
"equityAfter": 100000,
"equityRecoveryMonths": 0,
"pmiNaturalDropMonth": 10,
"yearsShavedOff": null,
"worstCaseMonthlyPI": null,
"interestAgainstKeeping": null
},
{
"mode": "cash-out",
"status": "available",
"newRate": 6.5,
"newTermYears": 30,
"newLoanAmount": 320000,
"newMonthlyPI": 2023,
"newPmiMonthly": 0,
"monthlySavings": 206,
"lifetimeInterestSavings": -25509,
"cashReceived": 20000,
"cashToClose": 0,
"closingCostsEstimate": 5000,
"breakEvenMonths": null,
"fiveYearNetSavings": null,
"withinHorizon": null,
"taxAdjustedSavings": null,
"equityBefore": 100000,
"equityAfter": 80000,
"equityRecoveryMonths": 59,
"pmiNaturalDropMonth": 10,
"yearsShavedOff": null,
"worstCaseMonthlyPI": null,
"interestAgainstKeeping": -66190
}
]
},
"formulaVersion": "quoted-refinance-alternatives-htcalc-719df2c0e105",
"units": {
"newMonthlyPI": "USD/month",
"newPmiMonthly": "USD/month",
"monthlySavings": "USD/month",
"newRate": "annual percent",
"breakEvenMonths": "months",
"newTermYears": "years",
"closingCostsEstimate": "USD"
},
"assumptions": [
"All quotes, including loan-specific price adjustments, come from the caller. The app’s November 2026 scenario rules determine whether the requested alternative applies. No credit decision or rate lookup is provided. The caller supplies costs in dollars. Program mortgage insurance, other than quoted costs, uses the pinned app assumptions.",
"The original strategy worksheet rounds its displayed payment estimates to whole US dollars.",
"Ranking follows the app’s model criteria. Recasting is informational until the servicer supplies terms."
],
"warnings": [],
"creditCost": 2
} Request contract
Accepted inputs
Fields for this example. Expand the schema for all supported combinations and limits.
FieldType, units and limits
profileRequiredprofile.currentRequiredprofile.current.balanceRequiredUSD
Min 0.01 · Max 1000000000profile.current.rateRequiredPercent
Min 0 · Max 50profile.current.monthlyPIRequiredUSD per month
Min 0 · Max 1000000000profile.current.monthsRemainingRequiredWhole months
Min 1 · Max 600profile.current.originalAmountOptionalUSD
Min 0.01 · Max 1000000000profile.current.loanTypeRequiredprofile.current.hasMIRequiredprofile.propertyRequiredprofile.property.estimatedValueRequiredUSD
Min 0.01 · Max 1000000000profile.property.originalValueOptionalUSD
Min 0.01 · Max 1000000000profile.property.typeRequiredprofile.property.occupancyRequiredprofile.borrowerRequiredprofile.borrower.creditTierRequiredprofile.borrower.isVeteranRequiredprofile.borrower.seasonedSixMonthsRequiredprofile.borrower.expectedYearsToStayOptionalYears
Min 0 · Max 50profile.borrower.marginalTaxRateOptionalFraction
Min 0 · Max 1profile.goalsRequiredprofile.debtsToConsolidateOptionalprofile.debtsToConsolidate[].descriptionRequiredprofile.debtsToConsolidate[].balanceRequiredUSD
Min 0.01 · Max 1000000000profile.debtsToConsolidate[].aprRequiredPercent
Min 0 · Max 50profile.debtsToConsolidate[].monthlyPaymentRequiredUSD per month
Min 0 · Max 1000000000profile.cashOutAmountOptionalUSD
Min 0 · Max 1000000000profile.extraPrincipalPerMonthOptionalAdditional principal per month on the current loan in USD.
Min 0 · Max 10000000quotesRequiredquotes[].modeRequiredquotes[].noteRateRequiredPercent
Min 0 · Max 50quotes[].closingCostsRequiredUSD
Min 0 · Max 1000000000includeCurrentAlternativesOptionalInclude the current loan and informational recast. Include extra principal when supplied.
matchGoalsOptionalApply the original mortgage goal filter.
sortByOptionalUse the original strategy ordering by the stated criterion.
Allowed: "biggest-monthly-savings", "biggest-lifetime-savings", "fastest-break-even", "most-cash-received"Example request body (JSON)
{
"profile": {
"current": {
"balance": 300000,
"rate": 7.25,
"monthlyPI": 2229,
"monthsRemaining": 288,
"loanType": "conventional",
"hasMI": true
},
"property": {
"estimatedValue": 400000,
"originalValue": 380000,
"type": "single-family",
"occupancy": "primary"
},
"borrower": {
"creditTier": "excellent",
"isVeteran": false,
"seasonedSixMonths": true,
"expectedYearsToStay": 7
},
"goals": [
"lower-payment"
]
},
"quotes": [
{
"mode": "lower-rate",
"noteRate": 6,
"closingCosts": 3500
},
{
"mode": "cash-out",
"noteRate": 6.5,
"closingCosts": 5000
}
]
} Full JSON schema
{
"type": "object",
"properties": {
"profile": {
"type": "object",
"properties": {
"current": {
"type": "object",
"properties": {
"balance": {
"type": "number",
"minimum": 0.01,
"maximum": 1000000000,
"description": "USD"
},
"rate": {
"type": "number",
"minimum": 0,
"maximum": 50,
"description": "Percent"
},
"monthlyPI": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "USD per month"
},
"monthsRemaining": {
"type": "integer",
"minimum": 1,
"maximum": 600,
"description": "Whole months"
},
"originalAmount": {
"type": "number",
"minimum": 0.01,
"maximum": 1000000000,
"description": "USD"
},
"loanType": {
"type": "string",
"enum": [
"conventional",
"fha",
"va",
"usda",
"arm"
]
},
"hasMI": {
"type": "boolean"
}
},
"required": [
"balance",
"rate",
"monthlyPI",
"monthsRemaining",
"loanType",
"hasMI"
],
"additionalProperties": false
},
"property": {
"type": "object",
"properties": {
"estimatedValue": {
"type": "number",
"minimum": 0.01,
"maximum": 1000000000,
"description": "USD"
},
"originalValue": {
"type": "number",
"minimum": 0.01,
"maximum": 1000000000,
"description": "USD"
},
"type": {
"type": "string",
"enum": [
"single-family",
"condo",
"multi-unit"
]
},
"occupancy": {
"type": "string",
"enum": [
"primary",
"second-home",
"investment"
]
}
},
"required": [
"estimatedValue",
"type",
"occupancy"
],
"additionalProperties": false
},
"borrower": {
"type": "object",
"properties": {
"creditTier": {
"type": "string",
"enum": [
"excellent",
"good",
"fair",
"below"
]
},
"isVeteran": {
"type": "boolean"
},
"seasonedSixMonths": {
"type": "boolean"
},
"expectedYearsToStay": {
"type": "number",
"minimum": 0,
"maximum": 50,
"description": "Years"
},
"marginalTaxRate": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Fraction"
}
},
"required": [
"creditTier",
"isVeteran",
"seasonedSixMonths"
],
"additionalProperties": false
},
"goals": {
"type": "array",
"items": {
"type": "string",
"enum": [
"lower-payment",
"pay-off-faster",
"cash-out",
"drop-mi",
"arm-to-fixed",
"consolidate-debts"
]
},
"minItems": 0,
"maxItems": 6
},
"debtsToConsolidate": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {
"type": "string",
"maxLength": 64
},
"balance": {
"type": "number",
"minimum": 0.01,
"maximum": 1000000000,
"description": "USD"
},
"apr": {
"type": "number",
"minimum": 0,
"maximum": 50,
"description": "Percent"
},
"monthlyPayment": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "USD per month"
}
},
"required": [
"description",
"balance",
"apr",
"monthlyPayment"
],
"additionalProperties": false
},
"minItems": 0,
"maxItems": 20
},
"cashOutAmount": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "USD"
},
"extraPrincipalPerMonth": {
"type": "number",
"minimum": 0,
"maximum": 10000000,
"description": "Additional principal per month on the current loan in USD."
}
},
"required": [
"current",
"property",
"borrower",
"goals"
],
"additionalProperties": false
},
"quotes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"lower-rate",
"shorter-term",
"pay-same-save-more",
"drop-pmi",
"fha-to-conv",
"arm-to-fixed",
"cash-out",
"cash-out-consolidate",
"va-irrrl",
"fha-streamline"
]
},
"noteRate": {
"type": "number",
"minimum": 0,
"maximum": 50,
"description": "Percent"
},
"closingCosts": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "USD"
}
},
"required": [
"mode",
"noteRate",
"closingCosts"
],
"additionalProperties": false
},
"minItems": 1,
"maxItems": 10
},
"includeCurrentAlternatives": {
"type": "boolean",
"description": "Include the current loan and informational recast. Include extra principal when supplied."
},
"matchGoals": {
"type": "boolean",
"description": "Apply the original mortgage goal filter."
},
"sortBy": {
"type": "string",
"enum": [
"biggest-monthly-savings",
"biggest-lifetime-savings",
"fastest-break-even",
"most-cash-received"
],
"description": "Use the original strategy ordering by the stated criterion."
}
},
"required": [
"profile",
"quotes"
],
"additionalProperties": false
}Production endpoint: POST https://calc.hasstechapi.com/v2/calc/quoted-refinance-alternatives
Formula: quoted-refinance-alternatives-htcalc-719df2c0e105