Hierarchy Aggregation Service
API Contract
REST
/api/v1/hierarchy-aggregation
4 endpoints
GET
/api/v1/hierarchy-aggregation/api/v1/hierarchy-aggregation/units/{unitId}/activities
Aggregate activity metrics for a unit within a date range
Public
Response Example
{
"data": [
{
"unit_id": "unit-002",
"unit_name": "Oslo Chapter",
"total_activities": 87,
"completed": 72,
"in_progress": 10,
"cancelled": 5,
"date_from": "2026-01-01",
"date_to": "2026-03-31"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 1
}
}
GET
/api/v1/hierarchy-aggregation/api/v1/hierarchy-aggregation/units/{unitId}/descendants/count
Count all activities across descendant units
Public
Response Example
{
"unit_id": "unit-001",
"descendant_activity_count": 342,
"descendant_unit_count": 8
}
GET
/api/v1/hierarchy-aggregation/api/v1/hierarchy-aggregation/organizations/{organizationId}/by-level
Aggregate activities grouped by hierarchy level
Public
Response Example
{
"data": [
{
"level_type": "chapter",
"unit_id": "unit-002",
"unit_name": "Oslo Chapter",
"total_activities": 87,
"completed": 72
},
{
"level_type": "chapter",
"unit_id": "unit-019",
"unit_name": "Bergen Chapter",
"total_activities": 54,
"completed": 50
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 4
}
}
GET
/api/v1/hierarchy-aggregation/api/v1/hierarchy-aggregation/units/{unitId}/aggregation-path
Get the aggregation rollup path from unit to root
Public
Response Example
{
"unit_id": "unit-002",
"aggregation_path": [
{
"unit_id": "unit-002",
"name": "Oslo Chapter",
"level_type": "chapter",
"depth": 1
},
{
"unit_id": "unit-001",
"name": "Northern Region",
"level_type": "region",
"depth": 0
}
]
}