Skip to content

Mortgage · Calculation

Discount point scenario ladder

Evaluate costs, payments and savings under an entered rate reduction per point, at multiple point increments and a specified horizon.

Example result · recommendedScenario.points: 3 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 discount-point-rate-ladder.

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/discount-point-rate-ladder";
const input = {
  "inputs": {
    "loanAmount": 300000,
    "originalRate": 0.07,
    "loanTerm": 30,
    "rateReductionPerPoint": 0.0025,
    "maxPoints": 3
  },
  "yearsInHome": 7
};
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/discount-point-rate-ladder' \
    --header "Authorization: Bearer $HT_PRODUCTION_KEY" \
    --header 'Content-Type: application/json' \
    --header "Idempotency-Key: $request_id" \
    --data-binary @- <<'HT_INPUT'
{
  "inputs": {
    "loanAmount": 300000,
    "originalRate": 0.07,
    "loanTerm": 30,
    "rateReductionPerPoint": 0.0025,
    "maxPoints": 3
  },
  "yearsInHome": 7
}
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 discount-point-rate-ladder.
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.

recommendedScenario.points
3
recommendedScenario.cost
9000
recommendedScenario.newRate
0.0625
How to interpret this result
  • The caller supplies the rate reduction per point.
Full example response (JSON)
{
  "status": "available",
  "result": {
    "scenarios": [
      {
        "points": 0,
        "cost": 0,
        "newRate": 0.07,
        "monthlyPayment": 1995.9074855375,
        "monthlySavings": 0,
        "breakevenMonths": null,
        "breakevenYears": null,
        "breakevenYearsDecimal": null,
        "breakevenStatus": "not-applicable",
        "totalInterestOriginal": 418526.6947935,
        "totalInterestNew": 418526.6947935,
        "interestSavings": 0,
        "savings5Year": 0,
        "savings10Year": 0,
        "savings15Year": 0,
        "savings30Year": 0
      },
      {
        "points": 1,
        "cost": 3000,
        "newRate": 0.0675,
        "monthlyPayment": 1945.7942897046,
        "monthlySavings": 50.11319583289992,
        "breakevenMonths": 60,
        "breakevenYears": 5,
        "breakevenYearsDecimal": 5,
        "breakevenStatus": "available",
        "totalInterestOriginal": 418526.6947935,
        "totalInterestNew": 400485.9442936559,
        "interestSavings": 18040.750499844085,
        "savings5Year": 6.791749973995138,
        "savings10Year": 3013.5834999479903,
        "savings15Year": 6020.3752499219845,
        "savings30Year": 15040.750499843969
      },
      {
        "points": 2,
        "cost": 6000,
        "newRate": 0.065,
        "monthlyPayment": 1896.2040704789,
        "monthlySavings": 99.70341505860006,
        "breakevenMonths": 61,
        "breakevenYears": 5,
        "breakevenYearsDecimal": 5.083333333333333,
        "breakevenStatus": "available",
        "totalInterestOriginal": 418526.6947935,
        "totalInterestNew": 382633.46537240397,
        "interestSavings": 35893.22942109604,
        "savings5Year": -17.79509648399653,
        "savings10Year": 5964.409807032007,
        "savings15Year": 11946.614710548012,
        "savings30Year": 29893.229421096024
      },
      {
        "points": 3,
        "cost": 9000,
        "newRate": 0.0625,
        "monthlyPayment": 1847.1516012792,
        "monthlySavings": 148.75588425830006,
        "breakevenMonths": 61,
        "breakevenYears": 5,
        "breakevenYearsDecimal": 5.083333333333333,
        "breakevenStatus": "available",
        "totalInterestOriginal": 418526.6947935,
        "totalInterestNew": 364974.576460512,
        "interestSavings": 53552.118332988,
        "savings5Year": -74.6469445019975,
        "savings10Year": 8850.706110996005,
        "savings15Year": 17776.05916649401,
        "savings30Year": 44552.11833298802
      }
    ],
    "recommendedScenario": {
      "points": 3,
      "cost": 9000,
      "newRate": 0.0625,
      "monthlyPayment": 1847.1516012792,
      "monthlySavings": 148.75588425830006,
      "breakevenMonths": 61,
      "breakevenYears": 5,
      "breakevenYearsDecimal": 5.083333333333333,
      "breakevenStatus": "available",
      "totalInterestOriginal": 418526.6947935,
      "totalInterestNew": 364974.576460512,
      "interestSavings": 53552.118332988,
      "savings5Year": -74.6469445019975,
      "savings10Year": 8850.706110996005,
      "savings15Year": 17776.05916649401,
      "savings30Year": 44552.11833298802
    },
    "inputs": {
      "loanAmount": 300000,
      "originalRate": 0.07,
      "loanTerm": 30,
      "rateReductionPerPoint": 0.0025,
      "maxPoints": 3
    }
  },
  "formulaVersion": "discount-point-rate-ladder-htcalc-719df2c0e105",
  "units": {
    "scenarios.0.cost": "USD",
    "scenarios.0.monthlyPayment": "USD/month",
    "scenarios.1.cost": "USD",
    "scenarios.1.monthlySavings": "USD/month"
  },
  "assumptions": [
    "The caller supplies the rate reduction per point."
  ],
  "warnings": [],
  "creditCost": 2
}

Request contract

Accepted inputs

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

FieldType, units and limits

inputsRequired
object
inputs.loanAmountRequired
number

US dollars

Min 0.01 · Max 1000000000
inputs.originalRateRequired
number

Annual rate as a fraction (0.05 means 5%)

Min 0 · Max 0.5
inputs.loanTermRequired
integer

Whole years

Min 1 · Max 50
inputs.rateReductionPerPointRequired
number

Annual rate as a fraction (0.05 means 5%)

Min 0 · Max 0.5
inputs.maxPointsOptional
integer

Whole discount points

Min 0 · Max 10
yearsInHomeRequired
number

Years

Min 0 · Max 50
Example request body (JSON)
{
  "inputs": {
    "loanAmount": 300000,
    "originalRate": 0.07,
    "loanTerm": 30,
    "rateReductionPerPoint": 0.0025,
    "maxPoints": 3
  },
  "yearsInHome": 7
}
Full JSON schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "inputs": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "loanAmount": {
          "type": "number",
          "minimum": 0.01,
          "maximum": 1000000000,
          "description": "US dollars"
        },
        "originalRate": {
          "type": "number",
          "minimum": 0,
          "maximum": 0.5,
          "description": "Annual rate as a fraction (0.05 means 5%)"
        },
        "loanTerm": {
          "type": "integer",
          "minimum": 1,
          "maximum": 50,
          "description": "Whole years"
        },
        "rateReductionPerPoint": {
          "type": "number",
          "minimum": 0,
          "maximum": 0.5,
          "description": "Annual rate as a fraction (0.05 means 5%)"
        },
        "maxPoints": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10,
          "description": "Whole discount points"
        }
      },
      "required": [
        "loanAmount",
        "originalRate",
        "loanTerm",
        "rateReductionPerPoint"
      ]
    },
    "yearsInHome": {
      "type": "number",
      "minimum": 0,
      "maximum": 50,
      "description": "Years"
    }
  },
  "required": [
    "inputs",
    "yearsInHome"
  ]
}

Production endpoint: POST https://calc.hasstechapi.com/v2/calc/discount-point-rate-ladder
Formula: discount-point-rate-ladder-htcalc-719df2c0e105