Organization Unit Repository
API Contract
REST
/api/v1/organization-units
7 endpoints
GET
/api/v1/organization-units/api/v1/organization-units
Fetch all units for an organization (flat list)
Public
Response Example
{
"data": [
{
"unit_id": "unit-001",
"organization_id": "org-42",
"name": "Northern Region",
"level_type": "region",
"parent_id": null,
"depth": 0
},
{
"unit_id": "unit-002",
"organization_id": "org-42",
"name": "Oslo Chapter",
"level_type": "chapter",
"parent_id": "unit-001",
"depth": 1
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 12
}
}
GET
/api/v1/organization-units/api/v1/organization-units/{unitId}
Fetch a single unit by ID
Public
Response Example
{
"unit_id": "unit-002",
"organization_id": "org-42",
"name": "Oslo Chapter",
"level_type": "chapter",
"parent_id": "unit-001",
"depth": 1,
"created_at": "2025-02-10T11:30:00Z"
}
GET
/api/v1/organization-units/api/v1/organization-units/{unitId}/children
Fetch direct children of a unit
Public
Response Example
{
"data": [
{
"unit_id": "unit-019",
"name": "Bergen Chapter",
"level_type": "chapter",
"parent_id": "unit-001",
"depth": 1
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 4
}
}
GET
/api/v1/organization-units/api/v1/organization-units/{unitId}/ancestors
Fetch all ancestor units up to the root
Public
Response Example
{
"data": [
{
"unit_id": "unit-001",
"name": "Northern Region",
"level_type": "region",
"depth": 0
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 1
}
}
POST
/api/v1/organization-units/api/v1/organization-units
Insert a new organization unit record
Public
Request Example
{
"organization_id": "org-42",
"name": "Trondheim Chapter",
"level_type": "chapter",
"parent_id": "unit-001"
}
Response Example
{
"unit_id": "unit-020",
"organization_id": "org-42",
"name": "Trondheim Chapter",
"level_type": "chapter",
"parent_id": "unit-001",
"depth": 1,
"created_at": "2026-03-26T10:50:00Z"
}
PUT
/api/v1/organization-units/api/v1/organization-units/{unitId}
Update an organization unit record
Public
Request Example
{
"name": "Trondheim & Stjørdal Chapter"
}
Response Example
{
"unit_id": "unit-020",
"name": "Trondheim & Stjørdal Chapter",
"updated_at": "2026-03-26T11:10:00Z"
}
DELETE
/api/v1/organization-units/api/v1/organization-units/{unitId}
Delete an organization unit record
Public
Response Example
{
"deleted": true,
"unit_id": "unit-020"
}