Skip to main content

Hierarchy endpoints

Two read-only endpoints return a tree as nested JSON, both as of a date. Both are @frappe.whitelist() with no verb restriction (GET or POST) and need a logged-in user.

EndpointTree
get_hierarchy_treeLegal entities: Consolidation Group with ownership from Ownership Period
get_reporting_hierarchy_treeManagement roll-ups: one Reporting Hierarchy and its dated members

get_hierarchy_tree​

GET /api/method/konsol.api.get_hierarchy_tree

Parameters​

ParameterTypeRequiredDefaultDescription
consolidation_groupstringNo—Return only the subtree rooted at this group (nested-set lft/rgt range)
as_ofdate (YYYY-MM-DD)NotodayThe date on which ownership_pct and consolidation_method are read

Response​

{
"message": {
"tree": [
{
"name": "CG-GROUP_CORP-GBMF",
"consolidation_group": "GROUP_CORP",
"data_area_id": "GBMF",
"entity_name": "GB Manufacturing",
"parent_group": null,
"ownership_pct": 100,
"consolidation_method": "full",
"children": [
{
"name": "CG-GROUP_EMEA-DEMF",
"consolidation_group": "GROUP_EMEA",
"data_area_id": "DEMF",
"entity_name": "DE Manufacturing",
"parent_group": "CG-GROUP_CORP-GBMF",
"ownership_pct": 80,
"consolidation_method": "full",
"children": []
}
]
}
]
}
}
FieldTypeDescription
namestringConsolidation Group document name
consolidation_groupstringGroup code
data_area_idstringEntity code
entity_namestringDisplay name
parent_groupstring or nullThe parent document name (parent_consolidation_group); null for a root
ownership_pctnumber or nullWhat the parent owns of this node on as_of, from the submitted Ownership Period whose date range covers as_of
consolidation_methodstring or nullFrom the same Ownership Period
childrenarrayChild nodes

ownership_pct and consolidation_method are null when no submitted Ownership Period covers as_of. "No ownership recorded" and "0%" are different answers, so the code does not default one to the other (change F2, konsol/api.py).

Examples​

curl "http://localhost:8069/api/method/konsol.api.get_hierarchy_tree" -b "cookies.txt"

curl "http://localhost:8069/api/method/konsol.api.get_hierarchy_tree?\
consolidation_group=GROUP_EMEA&as_of=2025-12-31" -b "cookies.txt"

get_reporting_hierarchy_tree​

GET /api/method/konsol.api.get_reporting_hierarchy_tree

Returns one management reporting hierarchy (for example a cost-centre roll-up) as of a date. Each Reporting Hierarchy Member row is one dated tranche of a member code (konsol#220); the tree keeps the rows whose effective_from/effective_to window covers as_of. A child is attached to the tranche of its parent code that is current on the date.

Parameters​

ParameterTypeRequiredDefaultDescription
hierarchy_namestringYes—The Reporting Hierarchy's hierarchy_name
as_ofdate (YYYY-MM-DD)NotodayThe date to read the members on

Response​

{
"message": {
"hierarchy_name": "cost_centre_rollup",
"dimension": "dim_cost_center",
"label": "Cost centre roll-up",
"status": "Published",
"as_of": "2026-11-05",
"tree": [
{
"name": "RHM-0001",
"member_code": "OPS",
"member_label": "Operations",
"is_group": true,
"effective_from": "2024-01-01",
"effective_to": null,
"children": [
{
"name": "RHM-0007",
"member_code": "CC001",
"member_label": "Plant 1",
"is_group": false,
"effective_from": null,
"effective_to": null,
"children": []
}
]
}
]
}
}

A member with no effective_from means "always". A row whose parent code has no tranche on as_of is shown as a root.

Errors​

MessageCause
hierarchy_name is requiredParameter missing
as_of must be a date (YYYY-MM-DD).Bad date
Reporting Hierarchy '{x}' not foundNo such hierarchy

Example​

curl "http://localhost:8069/api/method/konsol.api.get_reporting_hierarchy_tree?\
hierarchy_name=cost_centre_rollup&as_of=2026-06-30" -b "cookies.txt"

Values for a member of a reporting hierarchy are read with the hierarchy and node parameters of epm_value and epm_batch.