Personal finance · Calculation
Auto purchase financing
Calculate the vehicle balance financed, monthly payment and modeled vehicle value after applying the entered sales tax, fees and trade-in equity. loanType is fixed to AUTO and loanTerm is in months.
Example result · principalAndInterest: 605.1166878711 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 auto-purchase-financing.
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/auto-purchase-financing";
const input = {
"params": {
"loanAmount": 35000,
"interestRate": 6,
"loanTerm": 60,
"downPayment": 3000,
"tradeInValue": 5000,
"amountOwedOnTrade": 2000,
"salesTaxRate": 6,
"fees": 500,
"tradeInReducesTax": true
},
"loanType": "AUTO"
};
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/auto-purchase-financing' \
--header "Authorization: Bearer $HT_PRODUCTION_KEY" \
--header 'Content-Type: application/json' \
--header "Idempotency-Key: $request_id" \
--data-binary @- <<'HT_INPUT'
{
"params": {
"loanAmount": 35000,
"interestRate": 6,
"loanTerm": 60,
"downPayment": 3000,
"tradeInValue": 5000,
"amountOwedOnTrade": 2000,
"salesTaxRate": 6,
"fees": 500,
"tradeInReducesTax": true
},
"loanType": "AUTO"
}
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
auto-purchase-financing. 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.
principalAndInterest- 605.1166878711
monthlyTax- 0
monthlyInsurance- 0
Full example response (JSON)
{
"status": "available",
"result": {
"principalAndInterest": 605.1166878711,
"monthlyTax": 0,
"monthlyInsurance": 0,
"monthlyPMI": 0,
"monthlyPayment": 605.1166878711,
"monthlyPrincipal": 448.6166878711,
"monthlyInterest": 156.5,
"totalPayment": 36307.001272266,
"totalFinancingPayment": 36307.001272266,
"totalInterest": 5007.001272266003,
"loanAmount": 31300,
"upfrontFees": 2300,
"originationFeeAmount": 0,
"feeDeductedFromProceeds": 0,
"capitalizedInterest": 0,
"businessDscr": 0,
"depreciationSchedule": [
{
"month": 0,
"value": 35000
},
{
"month": 1,
"value": 34417
},
{
"month": 2,
"value": 33843
},
{
"month": 3,
"value": 33279
},
{
"month": 4,
"value": 32724
},
{
"month": 5,
"value": 32179
},
{
"month": 6,
"value": 31643
},
{
"month": 7,
"value": 31115
},
{
"month": 8,
"value": 30597
},
{
"month": 9,
"value": 30087
},
{
"month": 10,
"value": 29585
},
{
"month": 11,
"value": 29092
},
{
"month": 12,
"value": 28607
},
{
"month": 13,
"value": 28250
},
{
"month": 14,
"value": 27897
},
{
"month": 15,
"value": 27548
},
{
"month": 16,
"value": 27204
},
{
"month": 17,
"value": 26864
},
{
"month": 18,
"value": 26528
},
{
"month": 19,
"value": 26196
},
{
"month": 20,
"value": 25869
},
{
"month": 21,
"value": 25545
},
{
"month": 22,
"value": 25226
},
{
"month": 23,
"value": 24911
},
{
"month": 24,
"value": 24599
},
{
"month": 25,
"value": 24292
},
{
"month": 26,
"value": 23988
},
{
"month": 27,
"value": 23688
},
{
"month": 28,
"value": 23392
},
{
"month": 29,
"value": 23100
},
{
"month": 30,
"value": 22811
},
{
"month": 31,
"value": 22526
},
{
"month": 32,
"value": 22244
},
{
"month": 33,
"value": 21966
},
{
"month": 34,
"value": 21692
},
{
"month": 35,
"value": 21421
},
{
"month": 36,
"value": 21153
},
{
"month": 37,
"value": 20888
},
{
"month": 38,
"value": 20627
},
{
"month": 39,
"value": 20369
},
{
"month": 40,
"value": 20115
},
{
"month": 41,
"value": 19863
},
{
"month": 42,
"value": 19615
},
{
"month": 43,
"value": 19370
},
{
"month": 44,
"value": 19128
},
{
"month": 45,
"value": 18889
},
{
"month": 46,
"value": 18653
},
{
"month": 47,
"value": 18419
},
{
"month": 48,
"value": 18189
},
{
"month": 49,
"value": 17962
},
{
"month": 50,
"value": 17737
},
{
"month": 51,
"value": 17516
},
{
"month": 52,
"value": 17297
},
{
"month": 53,
"value": 17080
},
{
"month": 54,
"value": 16867
},
{
"month": 55,
"value": 16656
},
{
"month": 56,
"value": 16448
},
{
"month": 57,
"value": 16242
},
{
"month": 58,
"value": 16039
},
{
"month": 59,
"value": 15839
},
{
"month": 60,
"value": 15641
},
{
"month": 61,
"value": 15445
},
{
"month": 62,
"value": 15252
},
{
"month": 63,
"value": 15062
},
{
"month": 64,
"value": 14873
},
{
"month": 65,
"value": 14687
},
{
"month": 66,
"value": 14504
},
{
"month": 67,
"value": 14322
},
{
"month": 68,
"value": 14143
},
{
"month": 69,
"value": 13967
},
{
"month": 70,
"value": 13792
},
{
"month": 71,
"value": 13620
},
{
"month": 72,
"value": 13449
}
],
"amortizationSchedule": [
{
"month": 1,
"interest": 156.5,
"principal": 448.62,
"remainingBalance": 30851.38
},
{
"month": 2,
"interest": 154.26,
"principal": 450.86,
"remainingBalance": 30400.52
},
{
"month": 3,
"interest": 152,
"principal": 453.12,
"remainingBalance": 29947.4
},
{
"month": 4,
"interest": 149.74,
"principal": 455.38,
"remainingBalance": 29492.02
},
{
"month": 5,
"interest": 147.46,
"principal": 457.66,
"remainingBalance": 29034.36
},
{
"month": 6,
"interest": 145.17,
"principal": 459.95,
"remainingBalance": 28574.41
},
{
"month": 7,
"interest": 142.87,
"principal": 462.25,
"remainingBalance": 28112.16
},
{
"month": 8,
"interest": 140.56,
"principal": 464.56,
"remainingBalance": 27647.6
},
{
"month": 9,
"interest": 138.24,
"principal": 466.88,
"remainingBalance": 27180.72
},
{
"month": 10,
"interest": 135.9,
"principal": 469.22,
"remainingBalance": 26711.5
},
{
"month": 11,
"interest": 133.56,
"principal": 471.56,
"remainingBalance": 26239.94
},
{
"month": 12,
"interest": 131.2,
"principal": 473.92,
"remainingBalance": 25766.02
},
{
"month": 13,
"interest": 128.83,
"principal": 476.29,
"remainingBalance": 25289.73
},
{
"month": 14,
"interest": 126.45,
"principal": 478.67,
"remainingBalance": 24811.06
},
{
"month": 15,
"interest": 124.06,
"principal": 481.06,
"remainingBalance": 24330
},
{
"month": 16,
"interest": 121.65,
"principal": 483.47,
"remainingBalance": 23846.53
},
{
"month": 17,
"interest": 119.23,
"principal": 485.89,
"remainingBalance": 23360.64
},
{
"month": 18,
"interest": 116.8,
"principal": 488.32,
"remainingBalance": 22872.32
},
{
"month": 19,
"interest": 114.36,
"principal": 490.76,
"remainingBalance": 22381.56
},
{
"month": 20,
"interest": 111.91,
"principal": 493.21,
"remainingBalance": 21888.35
},
{
"month": 21,
"interest": 109.44,
"principal": 495.68,
"remainingBalance": 21392.67
},
{
"month": 22,
"interest": 106.96,
"principal": 498.16,
"remainingBalance": 20894.51
},
{
"month": 23,
"interest": 104.47,
"principal": 500.65,
"remainingBalance": 20393.86
},
{
"month": 24,
"interest": 101.97,
"principal": 503.15,
"remainingBalance": 19890.71
},
{
"month": 25,
"interest": 99.45,
"principal": 505.67,
"remainingBalance": 19385.04
},
{
"month": 26,
"interest": 96.93,
"principal": 508.19,
"remainingBalance": 18876.85
},
{
"month": 27,
"interest": 94.38,
"principal": 510.74,
"remainingBalance": 18366.11
},
{
"month": 28,
"interest": 91.83,
"principal": 513.29,
"remainingBalance": 17852.82
},
{
"month": 29,
"interest": 89.26,
"principal": 515.86,
"remainingBalance": 17336.96
},
{
"month": 30,
"interest": 86.68,
"principal": 518.44,
"remainingBalance": 16818.52
},
{
"month": 31,
"interest": 84.09,
"principal": 521.03,
"remainingBalance": 16297.49
},
{
"month": 32,
"interest": 81.49,
"principal": 523.63,
"remainingBalance": 15773.86
},
{
"month": 33,
"interest": 78.87,
"principal": 526.25,
"remainingBalance": 15247.61
},
{
"month": 34,
"interest": 76.24,
"principal": 528.88,
"remainingBalance": 14718.73
},
{
"month": 35,
"interest": 73.59,
"principal": 531.53,
"remainingBalance": 14187.2
},
{
"month": 36,
"interest": 70.94,
"principal": 534.18,
"remainingBalance": 13653.02
},
{
"month": 37,
"interest": 68.27,
"principal": 536.85,
"remainingBalance": 13116.17
},
{
"month": 38,
"interest": 65.58,
"principal": 539.54,
"remainingBalance": 12576.63
},
{
"month": 39,
"interest": 62.88,
"principal": 542.24,
"remainingBalance": 12034.39
},
{
"month": 40,
"interest": 60.17,
"principal": 544.95,
"remainingBalance": 11489.44
},
{
"month": 41,
"interest": 57.45,
"principal": 547.67,
"remainingBalance": 10941.77
},
{
"month": 42,
"interest": 54.71,
"principal": 550.41,
"remainingBalance": 10391.36
},
{
"month": 43,
"interest": 51.96,
"principal": 553.16,
"remainingBalance": 9838.2
},
{
"month": 44,
"interest": 49.19,
"principal": 555.93,
"remainingBalance": 9282.27
},
{
"month": 45,
"interest": 46.41,
"principal": 558.71,
"remainingBalance": 8723.56
},
{
"month": 46,
"interest": 43.62,
"principal": 561.5,
"remainingBalance": 8162.06
},
{
"month": 47,
"interest": 40.81,
"principal": 564.31,
"remainingBalance": 7597.75
},
{
"month": 48,
"interest": 37.99,
"principal": 567.13,
"remainingBalance": 7030.62
},
{
"month": 49,
"interest": 35.15,
"principal": 569.97,
"remainingBalance": 6460.65
},
{
"month": 50,
"interest": 32.3,
"principal": 572.82,
"remainingBalance": 5887.83
},
{
"month": 51,
"interest": 29.44,
"principal": 575.68,
"remainingBalance": 5312.15
},
{
"month": 52,
"interest": 26.56,
"principal": 578.56,
"remainingBalance": 4733.59
},
{
"month": 53,
"interest": 23.67,
"principal": 581.45,
"remainingBalance": 4152.14
},
{
"month": 54,
"interest": 20.76,
"principal": 584.36,
"remainingBalance": 3567.78
},
{
"month": 55,
"interest": 17.84,
"principal": 587.28,
"remainingBalance": 2980.5
},
{
"month": 56,
"interest": 14.9,
"principal": 590.22,
"remainingBalance": 2390.28
},
{
"month": 57,
"interest": 11.95,
"principal": 593.17,
"remainingBalance": 1797.11
},
{
"month": 58,
"interest": 8.99,
"principal": 596.13,
"remainingBalance": 1200.98
},
{
"month": 59,
"interest": 6,
"principal": 599.12,
"remainingBalance": 601.86
},
{
"month": 60,
"interest": 3.01,
"principal": 601.86,
"remainingBalance": 0
}
]
},
"formulaVersion": "auto-purchase-financing-htcalc-719df2c0e105",
"units": {
"monthlyPayment": "USD/month",
"loanAmount": "USD",
"totalInterest": "USD",
"upfrontFees": "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
loanTypeRequiredFixed calculation branch.
Must equal "AUTO"paramsRequiredparams.amountOwedOnTradeOptionalOutstanding balance on the trade-in. In USD.
Min 0 · Max 250000 · Default: 0params.downPaymentOptionalCash down payment. In USD.
Min 0 · Max 250000 · Default: 0params.feesOptionalTitle, registration and other financed fees. In USD.
Min 0 · Max 250000 · Default: 0params.interestRateRequiredAnnual note rate. In percentage points (6.5 means 6.5%).
Min 0 · Max 100params.loanAmountRequiredPurchase price before trade-in, taxes and fees. In USD.
Min 1 · Max 250000params.loanTermRequiredRepayment term. In whole months.
Min 1 · Max 120params.salesTaxRateOptionalEntered sales tax rate. In percentage points (6.5 means 6.5%).
Min 0 · Max 20 · Default: 0params.tradeInReducesTaxOptionalWhether the trade-in allowance reduces taxable price.
Default: trueparams.tradeInValueOptionalAllowance for a trade-in vehicle. In USD.
Min 0 · Max 250000 · Default: 0Example request body (JSON)
{
"params": {
"loanAmount": 35000,
"interestRate": 6,
"loanTerm": 60,
"downPayment": 3000,
"tradeInValue": 5000,
"amountOwedOnTrade": 2000,
"salesTaxRate": 6,
"fees": 500,
"tradeInReducesTax": true
},
"loanType": "AUTO"
} Full JSON schema
{
"additionalProperties": false,
"properties": {
"loanType": {
"const": "AUTO",
"description": "Fixed calculation branch.",
"type": "string"
},
"params": {
"additionalProperties": false,
"properties": {
"amountOwedOnTrade": {
"default": 0,
"description": "Outstanding balance on the trade-in. In USD.",
"maximum": 250000,
"minimum": 0,
"type": "number"
},
"downPayment": {
"default": 0,
"description": "Cash down payment. In USD.",
"maximum": 250000,
"minimum": 0,
"type": "number"
},
"fees": {
"default": 0,
"description": "Title, registration and other financed fees. In USD.",
"maximum": 250000,
"minimum": 0,
"type": "number"
},
"interestRate": {
"anyOf": [
{
"const": 0
},
{
"minimum": 0.000001
}
],
"description": "Annual note rate. In percentage points (6.5 means 6.5%).",
"maximum": 100,
"minimum": 0,
"type": "number"
},
"loanAmount": {
"description": "Purchase price before trade-in, taxes and fees. In USD.",
"maximum": 250000,
"minimum": 1,
"type": "number"
},
"loanTerm": {
"description": "Repayment term. In whole months.",
"maximum": 120,
"minimum": 1,
"type": "integer"
},
"salesTaxRate": {
"default": 0,
"description": "Entered sales tax rate. In percentage points (6.5 means 6.5%).",
"maximum": 20,
"minimum": 0,
"type": "number"
},
"tradeInReducesTax": {
"default": true,
"description": "Whether the trade-in allowance reduces taxable price.",
"type": "boolean"
},
"tradeInValue": {
"default": 0,
"description": "Allowance for a trade-in vehicle. In USD.",
"maximum": 250000,
"minimum": 0,
"type": "number"
}
},
"required": [
"loanAmount",
"interestRate",
"loanTerm"
],
"type": "object"
}
},
"required": [
"loanType",
"params"
],
"type": "object"
}Production endpoint: POST https://calc.hasstechapi.com/v2/calc/auto-purchase-financing
Formula: auto-purchase-financing-htcalc-719df2c0e105