=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
| Purpose | Method | Path | Used by |
|---|---|---|---|
| Batch value read | POST | /api/method/konsol.api.epm_batch | K.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 read | GET/POST | /api/method/konsol.api.epm_value | other clients; the add-in does not call it |
| Budget write-back, one cell | POST | /api/method/konsol.api.budget_cell_save | K.EPMSAVE |
| Budget write-back, many lines | POST | /api/method/konsol.api.budget_save_batch | other clients (a JSON array of lines) |
| Health | GET | /api/method/konsol.api.health | monitoring; 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).
yearmust be a positive integer; a blank Excel cell (JSONnull) fails only that row withInvalid year, not the batch.periodaccepts1–12or a period code such asP07,OPN(0),CLS(13), or a range tokenQ1–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 aValidationErrornaming the declared set.- A blank
measuretakes the Dataset'sdefault_measure; a Dataset without one is refused with a message naming its measures. - Do not use
fiscal_year/fiscal_periodforepm_batch— those are the doctype field names, not the API keys. - Maximum 2000 items per request (
MAX_BATCH_SIZEinkonsol/api.py). The add-in chunks atMAX_BATCHinfunctions.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. entitymay beALLwithhierarchy+hierarchy_nodefor a cross-entity rollup;hierarchymay 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"] }
valuesis an array of numbers (ornull), positionally matching the request array.errorsis present only if at least one row failed; same positional indexing.error_codesis present only if at least one row has a code; it runs parallel toerrors."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 readresponse.message.values(the add-in:payload = data.message). - The add-in resolves
null/undefinedto0in the cell. It turns a row error with codeno_datainto#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.