Personal finance · Calculation
Monthly budget guide and spending changes
Compare category amounts with the printed 50/30/20 guide, test the planner’s one-month spending changes and see whether unallocated pay covers the savings gap.
Example result · shown.income: 5000 See output
- Cost per success
- 1 calculation credit
- Production plans
- Standard, Business, Scale, Enterprise
Plan allowances - Free sandbox
- Not available
Integration example
Make a request
Use a production key scoped to monthly-budget-guide-scenarios.
Keep the key on your server. A successful call uses 1 calculation credit.
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/monthly-budget-guide-scenarios";
const input = {
"monthlyIncome": 5000,
"items": [
{
"name": "Essentials",
"category": "needs",
"amount": 2600
},
{
"name": "Flexible spending",
"category": "wants",
"amount": 500
},
{
"name": "Savings and debt",
"category": "savings",
"amount": 700
}
]
};
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/monthly-budget-guide-scenarios' \
--header "Authorization: Bearer $HT_PRODUCTION_KEY" \
--header 'Content-Type: application/json' \
--header "Idempotency-Key: $request_id" \
--data-binary @- <<'HT_INPUT'
{
"monthlyIncome": 5000,
"items": [
{
"name": "Essentials",
"category": "needs",
"amount": 2600
},
{
"name": "Flexible spending",
"category": "wants",
"amount": 500
},
{
"name": "Savings and debt",
"category": "savings",
"amount": 700
}
]
}
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
monthly-budget-guide-scenarios. 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.
shown.income- 5000
shown.needs- 2600
shown.wants- 500
How to interpret this result
- Needs and wants targets are ceilings for the score; the savings target is a floor. Whole-dollar guide amounts use largest-remainder allocation so they add up to printed income.
- Scenarios change one month with income held fixed. A cut requires at least $100 in its category. The wants-to-savings shift uses up to $100.
Full example response (JSON)
{
"status": "available",
"result": {
"shown": {
"income": 5000,
"needs": 2600,
"wants": 500,
"savings": 700,
"planned": 3800,
"remaining": 1200,
"shortfall": false
},
"score": 85,
"recommendation": "nearly-there",
"deviation": "undersaving",
"categories": [
{
"category": "needs",
"amount": 2600,
"printedAmount": 2600,
"sharePct": 52,
"guidePct": 50,
"printedGuide": 2500,
"printedGap": 100,
"standing": "close"
},
{
"category": "wants",
"amount": 500,
"printedAmount": 500,
"sharePct": 10,
"guidePct": 30,
"printedGuide": 1500,
"printedGap": -1000,
"standing": "under"
},
{
"category": "savings",
"amount": 700,
"printedAmount": 700,
"sharePct": 14.000000000000002,
"guidePct": 20,
"printedGuide": 1000,
"printedGap": -300,
"standing": "under"
}
],
"comparison": {
"exactGuide": {
"needs": 2500,
"wants": 1500,
"savings": 1000
},
"printedGuide": {
"needs": 2500,
"wants": 1500,
"savings": 1000
},
"monthlyUnallocated": 0,
"score": 100,
"savingsChangeToGuide": 300
},
"scenarios": [
{
"change": "reduce-wants",
"lineChanges": {
"needs": 0,
"wants": -100,
"savings": 0
},
"remaining": 1300,
"remainingChange": 100,
"score": 85,
"scoreChange": 0,
"recommendation": "nearly-there"
},
{
"change": "increase-savings",
"lineChanges": {
"needs": 0,
"wants": 0,
"savings": 100
},
"remaining": 1100,
"remainingChange": -100,
"score": 89,
"scoreChange": 4,
"recommendation": "nearly-there"
},
{
"change": "reduce-needs",
"lineChanges": {
"needs": -100,
"wants": 0,
"savings": 0
},
"remaining": 1300,
"remainingChange": 100,
"score": 88,
"scoreChange": 3,
"recommendation": "nearly-there"
},
{
"change": "shift-wants-to-savings",
"lineChanges": {
"needs": 0,
"wants": -100,
"savings": 100
},
"remaining": 1200,
"remainingChange": 0,
"score": 89,
"scoreChange": 4,
"recommendation": "nearly-there"
}
],
"reportFunding": {
"savingsGap": 300,
"fromRemaining": 300,
"remainingAfter": 900
}
},
"formulaVersion": "monthly-budget-guide-htcalc-749139391f46-v1",
"units": {
"money": "USD/month",
"sharePct": "percent of take-home pay",
"guidePct": "percent of take-home pay",
"score": "points out of 100",
"scoreChange": "points"
},
"assumptions": [
"Needs and wants targets are ceilings for the score; the savings target is a floor. Whole-dollar guide amounts use largest-remainder allocation so they add up to printed income.",
"Scenarios change one month with income held fixed. A cut requires at least $100 in its category. The wants-to-savings shift uses up to $100."
],
"warnings": [],
"creditCost": 1
}Request contract
Accepted inputs
Fields for this example. Expand the schema for all supported combinations and limits.
FieldType, units and limits
monthlyIncomeRequiredMonthly take-home pay in USD. Zero supports the amounts-only view. Positive income begins at one cent.
itemsRequiredMonthly budget lines. The optional label is available to companion reports.
Min items 0 · Max items 100items[].nameOptionalCaller-supplied display label.
Max length 160items[].categoryRequiredSavings includes planned debt repayment.
Allowed: "needs", "wants", "savings"items[].amountRequiredPlanned monthly USD amount.
Min 0 · Max 10000000Example request body (JSON)
{
"monthlyIncome": 5000,
"items": [
{
"name": "Essentials",
"category": "needs",
"amount": 2600
},
{
"name": "Flexible spending",
"category": "wants",
"amount": 500
},
{
"name": "Savings and debt",
"category": "savings",
"amount": 700
}
]
} Full JSON schema
{
"type": "object",
"properties": {
"monthlyIncome": {
"description": "Monthly take-home pay in USD. Zero supports the amounts-only view. Positive income begins at one cent.",
"anyOf": [
{
"type": "number",
"const": 0
},
{
"type": "number",
"minimum": 0.01,
"maximum": 10000000
}
]
},
"items": {
"type": "array",
"minItems": 0,
"maxItems": 100,
"description": "Monthly budget lines. The optional label is available to companion reports.",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"maxLength": 160,
"description": "Caller-supplied display label."
},
"category": {
"type": "string",
"enum": [
"needs",
"wants",
"savings"
],
"description": "Savings includes planned debt repayment."
},
"amount": {
"type": "number",
"minimum": 0,
"maximum": 10000000,
"description": "Planned monthly USD amount."
}
},
"required": [
"category",
"amount"
],
"additionalProperties": false
}
}
},
"required": [
"monthlyIncome",
"items"
],
"additionalProperties": false
}Production endpoint: POST https://calc.hasstechapi.com/v2/calc/monthly-budget-guide-scenarios
Formula: monthly-budget-guide-htcalc-749139391f46-v1