Skip to main content

=K.EPM() Client Protocol

The K. worksheet functions are implemented by the konsol Office add-in (konsol/public/excel-addin/ in the konsol repository: functions.json, functions.js, manifest.xml), which talks to the Frappe API described here. This page is the wire contract; any other client must conform to it. The add-in is the only client today: the VBA client was retired on 12 Sep 2026 (konsolidat c3c581c, #163), and the konsol CLI does not call these endpoints.

Verified against konsol/api.py and konsol/public/excel-addin/functions.js at konsol 3e220ba8 (2026-11-05). For per-endpoint detail see the API reference.

Endpoints​

PurposeMethodPathUsed by
Batch value readPOST/api/method/konsol.api.epm_batchK.EPM, K.EPM_BUDGET, K.EPM_VARIANCE, K.EPM_DEBIT, K.EPM_CREDIT, K.CF (all reads are queued and sent in batches)
Single value readGET/POST/api/method/konsol.api.epm_valueother clients; the add-in does not call it
Budget write-back, one cellPOST/api/method/konsol.api.budget_cell_saveK.EPMSAVE
Budget write-back, many linesPOST/api/method/konsol.api.budget_save_batchother clients (a JSON array of lines)
HealthGET/api/method/konsol.api.healthmonitoring; guest-accessible

Authentication: the Frappe session cookie, or the token from konsol.api.excel_addin_auth sent as X-Konsolidat-Token (see API overview).

epm_batch request​

The request body is a bare JSON array (not an object wrapper); the server refuses anything else with "Expected a JSON array". Each element:

{
"entity": "USMF",
"year": 2024,
"period": 1,
"account": "110100",
"measure": "period_net_amount",
"scenario": "actuals",
"scenario_id": "",
"dimensions": { "dim_region": "EU" },
"hierarchy": "",
"hierarchy_node": "",
"layer": ""
}

Canonical keys: entity, year, period, account (always sent), measure, scenario (optional), plus optional scenario_id, fact, dimensions, hierarchy, hierarchy_node, layer (the server also accepts hierarchy_name and node). Dimensions go only in dimensions, an object of declared dimension name to value. Any other key is refused for that row with "Unknown request key" (konsol#287); before, the add-in sent two dimensions as top-level cost_center / department keys. The add-in's makeReq in functions.js sends only these names, each optional one only when it is not blank; K.CF sends the group as entity, the cash-flow line as account, measure: "cash_flow_amount" and fact: "cashflow" (a fact names the Dataset and wins over scenario).

  • year must be a positive integer; a blank Excel cell (JSON null) fails only that row with Invalid year, not the batch.
  • period accepts 1–12 or a period code such as P07, OPN (0), CLS (13), or a range token Q1–Q4, H1/H2, FY. Tokens are resolved against the year's declared calendar (the EPM Fiscal Year's period rows, konsol#251), not a fixed table, so a 13-period or 4-4-5 year works; an undeclared period is a ValidationError naming the declared set.
  • A blank measure takes the Dataset's default_measure; a Dataset without one is refused with a message naming its measures.
  • Do not use fiscal_year / fiscal_period for epm_batch — those are the doctype field names, not the API keys.
  • Maximum 2000 items per request (MAX_BATCH_SIZE in konsol/api.py). The add-in chunks at MAX_BATCH in functions.js; any other client must chunk too.
  • Entity access is checked per item (entity_read_scope); an entity outside the caller's scope yields a per-row error, not a 403 for the batch.
  • entity may be ALL with hierarchy + hierarchy_node for a cross-entity rollup; hierarchy may be blank only when the node is in exactly one published hierarchy.

epm_batch response​

{ "values": [123.45, 0, null, null], "errors": [null, null, "...", "No trial balance for USMF 2024 P5"], "error_codes": [null, null, null, "no_data"] }
  • values is an array of numbers (or null), positionally matching the request array.
  • errors is present only if at least one row failed; same positional indexing.
  • error_codes is present only if at least one row has a code; it runs parallel to errors. "no_data" marks an actuals row whose period has no trial balance (konsol#401); any other error has no code.
  • Over Frappe, the whole object is wrapped under message, so clients read response.message.values (the add-in: payload = data.message).
  • The add-in resolves null/undefined to 0 in the cell. It turns a row error with code no_data into #N/A (CustomFunctions.ErrorCode.notAvailable) and any other row error into #VALUE! (invalidValue); a transport failure becomes #N/A.

budget_cell_save request (K.EPMSAVE)​

POST with a JSON object. Unlike epm_batch, the write path uses the doctype field names; the add-in's epmSave sends scenario_id, data_area_id, fiscal_year, fiscal_period, main_account, amount, layer (one of base, challenge, management, board), and optionally dimensions (an object of budget dimension name to value), hierarchy, hierarchy_node; base_modified is optional for optimistic locking. The add-in caches the last value saved per key and skips a repeat save of the same amount. The (scenario, year) Budget Cycle is created Open if absent; a locked cycle refuses the write with HTTP 423; a stale base_modified is refused with HTTP 409 and a conflict payload. See budget_cell_save.

Versioning​

When changing the contract (keys, batch size, response shape), update this page, the add-in (functions.js and functions.json), and the API tests in konsol/tests/test_api.py / test_api_generalisation.py / test_api_refactor.py in the same change. The eight registered functions are listed on Excel custom functions.