Skip to content

Mortgage · Calculation

Cash-out refinance debt consolidation

Compare keeping existing mortgage and debt payments with a cash-out refinance that pays off the entered debts. Taxes, insurance, separately requested cash and upfront or financed closing costs are entered manually. The plan rounds the cash-out request to whole dollars.

Example result · debtsBalance: 107600 See output

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 cash-out-debt-consolidation.

Keep the key on your server. A successful call uses 2 calculation credits.

Production request

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/cash-out-debt-consolidation";
const input = {
  "currentBalance": 255000,
  "currentRate": 2.75,
  "currentTerm": 15,
  "propertyTax": 1800,
  "homeInsurance": 4800,
  "newRate": 4.125,
  "newTerm": 10,
  "closingCosts": 0,
  "rollClosingCosts": true,
  "extraCash": 5000,
  "debts": [
    {
      "kind": "card",
      "balance": 8800,
      "monthlyPayment": 342.2,
      "ratePercent": 0,
      "monthsLeft": 35
    },
    {
      "kind": "car",
      "balance": 26900,
      "monthlyPayment": 1024.43,
      "ratePercent": 5.38,
      "monthsLeft": 0
    },
    {
      "kind": "personal",
      "balance": 34200,
      "monthlyPayment": 962.88,
      "ratePercent": 0,
      "monthsLeft": 39
    },
    {
      "kind": "student",
      "balance": 9700,
      "monthlyPayment": 462.58,
      "ratePercent": 0.16,
      "monthsLeft": 21
    },
    {
      "kind": "car",
      "balance": 28000,
      "monthlyPayment": 531.33,
      "ratePercent": 12.85,
      "monthsLeft": 78
    }
  ]
};
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 HT_PRODUCTION_KEY on your server. Run in a POSIX shell with cURL 7.76+ and Python 3.7+ to create a request ID.

(
  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/cash-out-debt-consolidation' \
    --header "Authorization: Bearer $HT_PRODUCTION_KEY" \
    --header 'Content-Type: application/json' \
    --header "Idempotency-Key: $request_id" \
    --data-binary @- <<'HT_INPUT'
{
  "currentBalance": 255000,
  "currentRate": 2.75,
  "currentTerm": 15,
  "propertyTax": 1800,
  "homeInsurance": 4800,
  "newRate": 4.125,
  "newTerm": 10,
  "closingCosts": 0,
  "rollClosingCosts": true,
  "extraCash": 5000,
  "debts": [
    {
      "kind": "card",
      "balance": 8800,
      "monthlyPayment": 342.2,
      "ratePercent": 0,
      "monthsLeft": 35
    },
    {
      "kind": "car",
      "balance": 26900,
      "monthlyPayment": 1024.43,
      "ratePercent": 5.38,
      "monthsLeft": 0
    },
    {
      "kind": "personal",
      "balance": 34200,
      "monthlyPayment": 962.88,
      "ratePercent": 0,
      "monthsLeft": 39
    },
    {
      "kind": "student",
      "balance": 9700,
      "monthlyPayment": 462.58,
      "ratePercent": 0.16,
      "monthsLeft": 21
    },
    {
      "kind": "car",
      "balance": 28000,
      "monthlyPayment": 531.33,
      "ratePercent": 12.85,
      "monthsLeft": 78
    }
  ]
}
HT_INPUT
)
If your request fails
400 INVALID_INPUT

Read error.details when present. Node prints each issue. cURL returns the JSON body. Each path points 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.

401 or 403
Check that the server has the bearer key for the endpoint’s environment and that the key includes cash-out-debt-consolidation.
429
Read the service error code, check your allowance, and wait for the Retry-After interval when supplied before trying again.
Lost response, 409 or 503
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_ID to 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.

debtsBalance
107600
debtsMonthly
3323.42
extraCash
5000
Full example response (JSON)
{
  "status": "available",
  "result": {
    "debts": [
      {
        "id": "d0",
        "kind": "card",
        "name": "",
        "balance": 8800,
        "monthlyPayment": 342.2,
        "ratePercent": 0,
        "effectiveRate": 21.849,
        "rateSource": "months",
        "firstMonthInterest": 160.23,
        "basis": "months",
        "issue": null,
        "months": 35,
        "interest": 3177,
        "firstYear": [
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2,
          342.2
        ],
        "enteredMonthsDiffer": null
      },
      {
        "id": "d1",
        "kind": "car",
        "name": "",
        "balance": 26900,
        "monthlyPayment": 1024.43,
        "ratePercent": 5.38,
        "effectiveRate": 5.38,
        "rateSource": "entered",
        "firstMonthInterest": 120.6,
        "basis": "rate",
        "issue": null,
        "months": 28,
        "interest": 1783.9,
        "firstYear": [
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43,
          1024.43
        ],
        "enteredMonthsDiffer": null
      },
      {
        "id": "d2",
        "kind": "personal",
        "name": "",
        "balance": 34200,
        "monthlyPayment": 962.88,
        "ratePercent": 0,
        "effectiveRate": 5.71,
        "rateSource": "months",
        "firstMonthInterest": 162.74,
        "basis": "months",
        "issue": null,
        "months": 39,
        "interest": 3352.32,
        "firstYear": [
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88,
          962.88
        ],
        "enteredMonthsDiffer": null
      },
      {
        "id": "d3",
        "kind": "student",
        "name": "",
        "balance": 9700,
        "monthlyPayment": 462.58,
        "ratePercent": 0.16,
        "effectiveRate": 0.16,
        "rateSource": "entered",
        "firstMonthInterest": 1.29,
        "basis": "rate",
        "issue": null,
        "months": 22,
        "interest": 14.22,
        "firstYear": [
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58,
          462.58
        ],
        "enteredMonthsDiffer": null
      },
      {
        "id": "d4",
        "kind": "car",
        "name": "",
        "balance": 28000,
        "monthlyPayment": 531.33,
        "ratePercent": 12.85,
        "effectiveRate": 12.85,
        "rateSource": "entered",
        "firstMonthInterest": 299.83,
        "basis": "rate",
        "issue": null,
        "months": 79,
        "interest": 13444.14,
        "firstYear": [
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33,
          531.33
        ],
        "enteredMonthsDiffer": null
      }
    ],
    "debtsBalance": 107600,
    "debtsMonthly": 3323.42,
    "extraCash": 5000,
    "currentPayment": 2280.49,
    "todayMonthly": 5603.91,
    "newMonthly": 4293.65,
    "monthlyChange": 1310.26,
    "firstYearToday": 67246.86,
    "firstYearNew": 51523.8,
    "firstYearChange": 15723.06,
    "firstYearAssumed": false,
    "complete": true,
    "closingCosts": 0,
    "totals": {
      "todayInterest": 78258.91,
      "todayMonths": 180,
      "newCost": 81637.82,
      "newMonths": 120,
      "difference": -3378.91
    },
    "rateCheck": {
      "currentRate": 2.75,
      "newRate": 4.125,
      "currentBalance": 255000,
      "debtsBalance": 107600
    },
    "payNow": {
      "input": {
        "principal": 367600,
        "annualRatePercent": 4.125,
        "termMonths": 120,
        "payNowAmount": 5603.91,
        "requiredPayment": 4293.6484891188,
        "shownExtra": 0,
        "shownTotalInterest": 81637.81869425601
      },
      "loanName": "the new loan",
      "originalName": "your mortgage and debts today",
      "loanShortName": "New loan",
      "originalShortName": "Today",
      "originalRef": "today",
      "original": {
        "months": 180,
        "cost": 78258.91
      },
      "sameMoney": {
        "months": 82,
        "cost": 47295.95
      },
      "newSideCost": 0,
      "costLabel": "interest"
    },
    "interest": {
      "averageDebtRate": 8.305086,
      "combinedRate": 4.398448,
      "currentRate": 2.75,
      "newRate": 4.125,
      "newApr": 4.125,
      "thisMonth": {
        "debtsToday": 744.69,
        "debtsNew": 369.88,
        "mortgageToday": 584.38,
        "mortgageNew": 876.56,
        "otherNew": 17.19
      },
      "lifetime": {
        "debtsToday": 21771.58,
        "debtsNew": 23896.16,
        "mortgageToday": 56487.33,
        "mortgageNew": 56631.24,
        "otherNew": 1110.42,
        "closingCosts": 0
      }
    },
    "dti": null
  },
  "formulaVersion": "cash-out-debt-consolidation-htcalc-719df2c0e105",
  "units": {
    "todayMonthly": "USD/month",
    "newMonthly": "USD/month",
    "monthlyChange": "USD/month",
    "firstYearChange": "USD"
  },
  "assumptions": [],
  "warnings": [],
  "creditCost": 2
}

Request contract

Accepted inputs

Fields for this example. Expand the schema for all supported combinations and limits.

FieldType, units and limits

currentBalanceRequired
number

Current mortgage principal. In USD.

Min 1 · Max 100000000
currentRateRequired
number

Current annual mortgage note rate. In percentage points (6.5 means 6.5%).

Min 0 · Max 100
currentTermRequired
integer

Existing mortgage remaining duration. In whole years.

Min 1 · Max 50
newRateRequired
number

Proposed annual mortgage note rate. In percentage points (6.5 means 6.5%).

Min 0 · Max 100
newTermRequired
integer

Proposed mortgage duration. In whole years.

Min 1 · Max 50
propertyTaxRequired
number

Annual property taxes. In USD.

Min 0 · Max 10000000
homeInsuranceRequired
number

Annual homeowners insurance. In USD.

Min 0 · Max 10000000
closingCostsRequired
number

Total closing costs. In USD.

Min 0 · Max 10000000
rollClosingCostsRequired
boolean

True if costs are added to the proposed balance.

extraCashRequired
number

Cash requested in addition to paying off debts. In USD.

Min 0 · Max 100000000
debtsRequired
array

Debts to be paid off by the refinance.

Min items 1 · Max items 8
debts[].kindRequired
string

Debt category.

Allowed: "card", "car", "student", "personal", "other"
debts[].balanceRequired
number

Current payoff balance. In USD.

Min 1 · Max 10000000
debts[].monthlyPaymentRequired
number

Minimum scheduled payment. In USD per month.

Min 0.01 · Max 1000000
debts[].monthsLeftRequired
integer

Remaining installments, or zero when not supplied. In whole months.

Min 0 · Max 600
debts[].ratePercentRequired
number

Annual rate. Zero is interpreted as unknown by this source; use monthsLeft for a zero-interest debt. In percentage points (6.5 means 6.5%).

Min 0 · Max 100
Example request body (JSON)
{
  "currentBalance": 255000,
  "currentRate": 2.75,
  "currentTerm": 15,
  "propertyTax": 1800,
  "homeInsurance": 4800,
  "newRate": 4.125,
  "newTerm": 10,
  "closingCosts": 0,
  "rollClosingCosts": true,
  "extraCash": 5000,
  "debts": [
    {
      "kind": "card",
      "balance": 8800,
      "monthlyPayment": 342.2,
      "ratePercent": 0,
      "monthsLeft": 35
    },
    {
      "kind": "car",
      "balance": 26900,
      "monthlyPayment": 1024.43,
      "ratePercent": 5.38,
      "monthsLeft": 0
    },
    {
      "kind": "personal",
      "balance": 34200,
      "monthlyPayment": 962.88,
      "ratePercent": 0,
      "monthsLeft": 39
    },
    {
      "kind": "student",
      "balance": 9700,
      "monthlyPayment": 462.58,
      "ratePercent": 0.16,
      "monthsLeft": 21
    },
    {
      "kind": "car",
      "balance": 28000,
      "monthlyPayment": 531.33,
      "ratePercent": 12.85,
      "monthsLeft": 78
    }
  ]
}
Full JSON schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "currentBalance": {
      "type": "number",
      "minimum": 1,
      "maximum": 100000000,
      "description": "Current mortgage principal. In USD."
    },
    "currentRate": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Current annual mortgage note rate. In percentage points (6.5 means 6.5%).",
      "anyOf": [
        {
          "const": 0
        },
        {
          "minimum": 0.000001
        }
      ]
    },
    "currentTerm": {
      "type": "integer",
      "minimum": 1,
      "maximum": 50,
      "description": "Existing mortgage remaining duration. In whole years."
    },
    "newRate": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Proposed annual mortgage note rate. In percentage points (6.5 means 6.5%).",
      "anyOf": [
        {
          "const": 0
        },
        {
          "minimum": 0.000001
        }
      ]
    },
    "newTerm": {
      "type": "integer",
      "minimum": 1,
      "maximum": 50,
      "description": "Proposed mortgage duration. In whole years."
    },
    "propertyTax": {
      "type": "number",
      "minimum": 0,
      "maximum": 10000000,
      "description": "Annual property taxes. In USD."
    },
    "homeInsurance": {
      "type": "number",
      "minimum": 0,
      "maximum": 10000000,
      "description": "Annual homeowners insurance. In USD."
    },
    "closingCosts": {
      "type": "number",
      "minimum": 0,
      "maximum": 10000000,
      "description": "Total closing costs. In USD."
    },
    "rollClosingCosts": {
      "type": "boolean",
      "description": "True if costs are added to the proposed balance."
    },
    "extraCash": {
      "type": "number",
      "minimum": 0,
      "maximum": 100000000,
      "description": "Cash requested in addition to paying off debts. In USD."
    },
    "debts": {
      "type": "array",
      "minItems": 1,
      "maxItems": 8,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "card",
              "car",
              "student",
              "personal",
              "other"
            ],
            "description": "Debt category."
          },
          "balance": {
            "type": "number",
            "minimum": 1,
            "maximum": 10000000,
            "description": "Current payoff balance. In USD."
          },
          "monthlyPayment": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 1000000,
            "description": "Minimum scheduled payment. In USD per month."
          },
          "monthsLeft": {
            "type": "integer",
            "minimum": 0,
            "maximum": 600,
            "description": "Remaining installments, or zero when not supplied. In whole months."
          },
          "ratePercent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Annual rate. Zero is interpreted as unknown by this source; use monthsLeft for a zero-interest debt. In percentage points (6.5 means 6.5%).",
            "anyOf": [
              {
                "const": 0
              },
              {
                "minimum": 0.000001
              }
            ]
          }
        },
        "required": [
          "kind",
          "balance",
          "monthlyPayment",
          "monthsLeft",
          "ratePercent"
        ]
      },
      "description": "Debts to be paid off by the refinance."
    }
  },
  "required": [
    "currentBalance",
    "currentRate",
    "currentTerm",
    "newRate",
    "newTerm",
    "propertyTax",
    "homeInsurance",
    "closingCosts",
    "rollClosingCosts",
    "extraCash",
    "debts"
  ]
}

Production endpoint: POST https://calc.hasstechapi.com/v2/calc/cash-out-debt-consolidation
Formula: cash-out-debt-consolidation-htcalc-719df2c0e105