Skip to main content

API Overview

Konsolidat exposes a REST API through the Frappe/Konsol web framework. The API is consumed primarily by the Excel VBA module but can be called from any HTTP client.

Base URL

http://localhost:8069/api/method/konsol.api.{endpoint}

In production, replace with your Frappe server URL (e.g., https://epm.yourcompany.com).

Authentication

The API uses Frappe session-based authentication (cookies).

Login

curl -X POST http://localhost:8069/api/method/login \
-H "Content-Type: application/json" \
-d '{"usr": "admin@example.com", "pwd": "your_password"}'

The response sets Set-Cookie headers. Include these cookies in subsequent requests.

Session Check

curl http://localhost:8069/api/method/frappe.auth.get_logged_user \
-b "cookies.txt"

Guest Access

Only the health endpoint allows guest access (allow_guest=True). All other endpoints require authentication.

Request Flow

sequenceDiagram
participant Client as Excel / HTTP Client
participant Frappe as Frappe (Konsol)
participant Cube as Cube.js (Semantic Layer)
participant CH as ClickHouse

Client->>Frappe: POST /api/method/konsol.api.epm_batch
Frappe->>Frappe: Resolve fact + validate measure/dimensions per item
Frappe->>Cube: Query metrics & dimensions
Cube->>CH: Optimized SQL query
CH-->>Cube: Result set
Cube-->>Frappe: Structured response
Frappe-->>Client: JSON {values: [...], errors: [...]}

Endpoints

Data Retrieval

MethodEndpointAuthDescription
GEThealthGuestHealth check
GETepm_valueSessionSingle value query
POSTepm_batchSessionBatch query (up to 2000 items)

Budget Write-Back

MethodEndpointAuthDescription
POSTbudget_saveSessionSave full budget line
POSTbudget_cell_saveSessionSave single cell (EPMSAVE)
POSTbudget_save_batchSessionSave multiple budget lines

Consolidation

MethodEndpointAuthDescription
GETget_hierarchy_treeSessionConsolidation hierarchy as nested JSON
POSTapprove_adjustmentSessionApprove topside journal
POSTreverse_adjustmentSessionReverse approved journal

Allocation

MethodEndpointAuthDescription
POSTrun_allocationSessionCreate and execute allocation run
POSTreverse_allocationSessionReverse active allocation run
GETallocation_historySessionList runs with filters

Error Handling

All errors return a JSON object with exc_type and message:

{
"exc_type": "ValidationError",
"_server_messages": "[\"Invalid scenario 'forecast'. Allowed: actuals, budget, variance\"]"
}

Validation is registry-driven (Fact Table, Measure, and Dimension doctypes). The allowed values listed in each message are computed at request time from the registry, so adding a fact, measure, or dimension changes the messages without a code change.

Validation Errors

ErrorCause
Invalid scenario '{x}'. Allowed: ...No Fact Table has scenario_key = {x}; the allowed list is the distinct scenario_key values across all Fact Table records
Invalid fact '{x}'. Allowed: ...A fact was supplied but no Fact Table with that fact_name exists; the allowed list is every registered fact_name
Invalid measure '{m}' for fact '{fact}'. Allowed: ...Measure not in the fact's allowed measures intersected with the Published Measure registry
Invalid dimension '{d}' for fact '{fact}'. Allowed: ...Dimension not in the resolved fact's allowed dimensions
Batch size {n} exceeds maximum of 2000Too many items in a single batch request

ClickHouse Errors

ErrorCause
ClickHouse query timeoutQuery took > 30 seconds
ClickHouse connection failedClickHouse is unreachable

Batch Size Limit

MAX_BATCH_SIZE = 2000

The batch endpoint rejects requests exceeding 2000 items. The VBA module sends all EPM formulas on a sheet in a single batch, so this limit applies per-sheet refresh.

Fact → Table Resolution

There is no fixed scenario→table map. Each request resolves a Fact Table record — by fact_name when fact is supplied, otherwise by scenario_key from the legacy scenario argument — and reads its clickhouse_table field. Adding or repointing a fact is a registry operation that requires no code change. See GET epm_value for details.

Query Optimization

The batch endpoint groups requests by (scenario, measure, period_tuple, has_cost_center, has_department) and issues one SQL query per group. This means 500 requests for the same scenario/measure/period combination become a single ClickHouse query with an IN clause.

Next Steps

Data Retrieval:

Budget Write-Back:

Consolidation:

Allocation: