Skip to main content

POST budget_save

Save a single budget line — creates or updates a Budget Input document in Draft status.

Endpoint

POST /api/method/konsol.api.budget_save

Authentication: Required (Frappe session cookie)

Request Body

JSON object with the following fields:

ParameterTypeRequiredDescription
scenario_idstringYesScenario identifier (e.g., BUDGET_2025)
data_area_idstringYesEntity code (e.g., USMF)
fiscal_yearintegerYesFiscal year (e.g., 2025)
main_accountstringYesAccount code (e.g., 6100)
dim_cost_centerstringNoCost center dimension
dim_departmentstringNoDepartment dimension
periodsarrayYesPeriod amounts (see below)

Period Object

FieldTypeRequiredDescription
periodintegerYesFiscal period (112)
amountnumberYesBudget amount
layerstringNoBudget layer: base (default), challenge, management, board

Upsert Behavior

The endpoint upserts by the budget grain. If a matching Budget Input document exists, its period rows are replaced. Otherwise, a new document is created.

The budget grain is the fixed keys (scenario_id, data_area_id, fiscal_year, main_account) plus every Dimension flagged in_budget (Published) — for example, a cost center on a shared Travel account. Two writers that differ only by a budget dimension resolve to different documents instead of silently clobbering each other.

The Budget Input document name is built from the readable grain components followed by a mandatory 8-character digest suffix (a SHA-1 of the exact key tuple), so two distinct keys never collide even when their readable parts sanitise to the same string — e.g. BUD-BUDGET_2025-USMF-2025-6100-1a2b3c4d.

Example

curl -X POST http://localhost:8069/api/method/konsol.api.budget_save \
-H "Content-Type: application/json" \
-b "cookies.txt" \
-d '{
"scenario_id": "BUDGET_2025",
"data_area_id": "USMF",
"fiscal_year": 2025,
"main_account": "6100",
"dim_cost_center": "CC001",
"periods": [
{"period": 1, "amount": 10000, "layer": "base"},
{"period": 2, "amount": 12000, "layer": "base"},
{"period": 3, "amount": 11000, "layer": "base"}
]
}'

Response

{
"message": {
"name": "BUD-BUDGET_2025-USMF-2025-6100-1a2b3c4d"
}
}

Error Responses

Missing required fields

{
"exc_type": "ValidationError",
"_server_messages": "[\"Missing required fields: main_account, periods\"]"
}

Invalid periods format

{
"exc_type": "ValidationError",
"_server_messages": "[\"periods must be a non-empty array\"]"
}