Investment · Calculation
Rent then sell versus sell today
Projects sale proceeds, annual loan paydown, rental cash flow, sale and reinvested wealth, break-even year and rental IRR. Growth, selling costs, reinvestment and capital-gains tax rates are decimal fractions. Current loan rate is annual percentage points. An unavailable IRR is null.
Example result · sellNow.grossProceeds: 400000 See output
- Cost per success
- 20 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 investor-rent-vs-sell.
Keep the key on your server. A successful call uses 20 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/investor-rent-vs-sell";
const input = {
"property": {
"currentValue": 400000,
"outstandingLoan": 200000,
"monthlyRent": 2300,
"monthlyExpenses": 400,
"monthlyMortgagePITI": 1400,
"costBasis": 300000,
"capitalGainsTaxRate": 0.2,
"currentLoanRatePct": 5,
"monthlyPrincipalAndInterest": 1074
},
"assumptions": {
"years": 5,
"sellingCostsRate": 0.06,
"expenseGrowthRate": 0.025,
"rentGrowthRate": 0.03,
"appreciationRate": 0.03,
"reinvestmentRate": 0.04
}
};
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/investor-rent-vs-sell' \
--header "Authorization: Bearer $HT_PRODUCTION_KEY" \
--header 'Content-Type: application/json' \
--header "Idempotency-Key: $request_id" \
--data-binary @- <<'HT_INPUT'
{
"property": {
"currentValue": 400000,
"outstandingLoan": 200000,
"monthlyRent": 2300,
"monthlyExpenses": 400,
"monthlyMortgagePITI": 1400,
"costBasis": 300000,
"capitalGainsTaxRate": 0.2,
"currentLoanRatePct": 5,
"monthlyPrincipalAndInterest": 1074
},
"assumptions": {
"years": 5,
"sellingCostsRate": 0.06,
"expenseGrowthRate": 0.025,
"rentGrowthRate": 0.03,
"appreciationRate": 0.03,
"reinvestmentRate": 0.04
}
}
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
investor-rent-vs-sell. 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.
sellNow.grossProceeds- 400000
sellNow.sellingCostsAmount- 24000
sellNow.payoffLoan- 200000
How to interpret this result
- Projects sale proceeds, annual loan paydown, rental cash flow, sale and reinvested wealth, break-even year and rental IRR. Growth, selling costs, reinvestment and capital-gains tax rates are decimal fractions. Current loan rate is annual percentage points. An unavailable IRR is null.
Full example response (JSON)
{
"status": "available",
"result": {
"sellNow": {
"grossProceeds": 400000,
"sellingCostsAmount": 24000,
"payoffLoan": 200000,
"taxableGain": 76000,
"capitalGainsTax": 15200,
"netProceeds": 160800
},
"projection": [
{
"year": 1,
"propertyValue": 412000,
"loanBalance": 197044.89,
"annualCashFlow": 6708,
"cumulativeCashFlow": 6708,
"sellingCosts": 24720,
"capitalGainsTax": 17456,
"netSaleProceeds": 172779.11,
"wealth": 179487.11,
"sellNowReinvested": 167232
},
{
"year": 2,
"propertyValue": 424360,
"loanBalance": 193938.59,
"annualCashFlow": 7437.84,
"cumulativeCashFlow": 14145.84,
"sellingCosts": 25461.6,
"capitalGainsTax": 19779.680000000008,
"netSaleProceeds": 185180.13,
"wealth": 199325.97,
"sellNowReinvested": 173921.28000000003
},
{
"year": 3,
"propertyValue": 437090.8,
"loanBalance": 190673.37,
"annualCashFlow": 8190.190200000001,
"cumulativeCashFlow": 22336.0302,
"sellingCosts": 26225.447999999997,
"capitalGainsTax": 22173.070400000004,
"netSaleProceeds": 198018.9116,
"wealth": 220354.9418,
"sellNowReinvested": 180878.1312
},
{
"year": 4,
"propertyValue": 450203.524,
"loanBalance": 187241.08,
"annualCashFlow": 8965.741281000002,
"cumulativeCashFlow": 31301.771481000003,
"sellingCosts": 27012.21144,
"capitalGainsTax": 24638.262512,
"netSaleProceeds": 211311.97004800005,
"wealth": 242613.74152900005,
"sellNowReinvested": 188113.25644800003
},
{
"year": 5,
"propertyValue": 463709.62971999997,
"loanBalance": 183633.2,
"annualCashFlow": 9765.205028805005,
"cumulativeCashFlow": 41066.97650980501,
"sellingCosts": 27822.5777832,
"capitalGainsTax": 27177.410387359992,
"netSaleProceeds": 225076.44154943997,
"wealth": 266143.418059245,
"sellNowReinvested": 195637.78670592
}
],
"higherModeledWealth": "rent",
"reason": "Rent then sell ends $70,505 ahead of selling now at year 5, on the same clock.",
"breakEvenYear": 1,
"rentalIRR": 0.11376578748226161
},
"formulaVersion": "investor-rent-vs-sell-1.0.0",
"units": {
"amounts": "USD",
"property.currentLoanRatePct": "annual percent points",
"assumptions.*Rate": "annual decimal fractions, except sellingCostsRate which is a one-time fraction of the sale price",
"property.capitalGainsTaxRate": "fraction of taxable gain",
"rentalIRR": "annual decimal fraction"
},
"assumptions": [
"Projects sale proceeds, annual loan paydown, rental cash flow, sale and reinvested wealth, break-even year and rental IRR. Growth, selling costs, reinvestment and capital-gains tax rates are decimal fractions. Current loan rate is annual percentage points. An unavailable IRR is null."
],
"warnings": [],
"creditCost": 20
}Request contract
Accepted inputs
Fields for this example. Expand the schema for all supported combinations and limits.
FieldType, units and limits
propertyRequiredproperty.currentValueRequiredCurrent modeled property value in USD.
Min 0.01 · Max 1000000000property.outstandingLoanRequiredExisting mortgage principal outstanding in USD.
Min 0 · Max 1000000000property.monthlyRentRequiredCurrent gross rent in USD per month.
Min 0 · Max 1000000000property.monthlyExpensesRequiredOperating expenses in USD per month, excluding amounts already counted in the mortgage PITI.
Min 0 · Max 1000000000property.monthlyMortgagePITIRequiredTotal monthly mortgage payment in USD including principal, interest and escrow for tax and insurance.
Min 0 · Max 1000000000property.costBasisRequiredProperty tax basis in USD used to estimate taxable sale gain.
Min 0 · Max 1000000000property.capitalGainsTaxRateRequiredTax on positive modeled gain as a decimal fraction (0.20 means 20%).
Min 0 · Max 1property.currentLoanRatePctRequiredCurrent mortgage annual interest rate in percent (6 means 6% per year).
Min 0 · Max 100property.monthlyPrincipalAndInterestRequiredPrincipal-and-interest portion of the mortgage payment in USD per month used for loan paydown.
Min 0 · Max 1000000000assumptionsRequiredassumptions.yearsRequiredWhole years to the modeled sale of the retained rental.
Min 1 · Max 10assumptions.sellingCostsRateRequiredOne-time selling expenses as a decimal fraction of gross sale price (0.06 means 6%).
Min 0 · Max 0.15assumptions.expenseGrowthRateRequiredAnnual change in property operating expenses as a signed decimal fraction (0.025 means 2.5% growth).
Min -1 · Max 0.15assumptions.rentGrowthRateRequiredAnnual change in gross rent as a signed decimal fraction (0.03 means 3% growth).
Min -1 · Max 0.15assumptions.appreciationRateRequiredAnnual change in property value as a signed decimal fraction (0.03 means 3% growth).
Min -1 · Max 0.15assumptions.reinvestmentRateRequiredAnnual compounded return on immediate sale proceeds as a signed decimal fraction (0.04 means 4%).
Min -1 · Max 0.2Example request body (JSON)
{
"property": {
"currentValue": 400000,
"outstandingLoan": 200000,
"monthlyRent": 2300,
"monthlyExpenses": 400,
"monthlyMortgagePITI": 1400,
"costBasis": 300000,
"capitalGainsTaxRate": 0.2,
"currentLoanRatePct": 5,
"monthlyPrincipalAndInterest": 1074
},
"assumptions": {
"years": 5,
"sellingCostsRate": 0.06,
"expenseGrowthRate": 0.025,
"rentGrowthRate": 0.03,
"appreciationRate": 0.03,
"reinvestmentRate": 0.04
}
} Full JSON schema
{
"type": "object",
"properties": {
"property": {
"type": "object",
"properties": {
"currentValue": {
"type": "number",
"minimum": 0.01,
"maximum": 1000000000,
"description": "Current modeled property value in USD."
},
"outstandingLoan": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "Existing mortgage principal outstanding in USD."
},
"monthlyRent": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "Current gross rent in USD per month."
},
"monthlyExpenses": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "Operating expenses in USD per month, excluding amounts already counted in the mortgage PITI."
},
"monthlyMortgagePITI": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "Total monthly mortgage payment in USD including principal, interest and escrow for tax and insurance."
},
"costBasis": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "Property tax basis in USD used to estimate taxable sale gain."
},
"capitalGainsTaxRate": {
"type": "number",
"minimum": 0,
"maximum": 1,
"description": "Tax on positive modeled gain as a decimal fraction (0.20 means 20%)."
},
"currentLoanRatePct": {
"type": "number",
"minimum": 0,
"maximum": 100,
"description": "Current mortgage annual interest rate in percent (6 means 6% per year)."
},
"monthlyPrincipalAndInterest": {
"type": "number",
"minimum": 0,
"maximum": 1000000000,
"description": "Principal-and-interest portion of the mortgage payment in USD per month used for loan paydown."
}
},
"required": [
"currentValue",
"outstandingLoan",
"monthlyRent",
"monthlyExpenses",
"monthlyMortgagePITI",
"costBasis",
"capitalGainsTaxRate",
"currentLoanRatePct",
"monthlyPrincipalAndInterest"
],
"additionalProperties": false
},
"assumptions": {
"type": "object",
"properties": {
"years": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"description": "Whole years to the modeled sale of the retained rental."
},
"sellingCostsRate": {
"type": "number",
"minimum": 0,
"maximum": 0.15,
"description": "One-time selling expenses as a decimal fraction of gross sale price (0.06 means 6%)."
},
"expenseGrowthRate": {
"type": "number",
"minimum": -1,
"maximum": 0.15,
"description": "Annual change in property operating expenses as a signed decimal fraction (0.025 means 2.5% growth)."
},
"rentGrowthRate": {
"type": "number",
"minimum": -1,
"maximum": 0.15,
"description": "Annual change in gross rent as a signed decimal fraction (0.03 means 3% growth)."
},
"appreciationRate": {
"type": "number",
"minimum": -1,
"maximum": 0.15,
"description": "Annual change in property value as a signed decimal fraction (0.03 means 3% growth)."
},
"reinvestmentRate": {
"type": "number",
"minimum": -1,
"maximum": 0.2,
"description": "Annual compounded return on immediate sale proceeds as a signed decimal fraction (0.04 means 4%)."
}
},
"required": [
"years",
"sellingCostsRate",
"expenseGrowthRate",
"rentGrowthRate",
"appreciationRate",
"reinvestmentRate"
],
"additionalProperties": false
}
},
"required": [
"property",
"assumptions"
],
"additionalProperties": false,
"description": "Projects sale proceeds, annual loan paydown, rental cash flow, sale and reinvested wealth, break-even year and rental IRR. Growth, selling costs, reinvestment and capital-gains tax rates are decimal fractions. Current loan rate is annual percentage points. An unavailable IRR is null."
}Production endpoint: POST https://calc.hasstechapi.com/v2/calc/investor-rent-vs-sell
Formula: investor-rent-vs-sell-1.0.0