Cost Centers
The CostCenterController and CostAllocationService manage cost center allocation within tenants. Cost centers allow organizations to track and attribute platform costs to specific departments, projects, or business units.
Cost Center Management
Cost centers are organizational units for cost allocation. Each tenant can define multiple cost centers and assign resources, users, or workloads to them.
CostCenter Entity
| Field | Type | Description |
|---|---|---|
id | UUID | Cost center identifier |
tenantId | UUID | Owning tenant |
name | String | Cost center name (e.g., "Engineering", "Marketing") |
code | String | Short code for the cost center (e.g., "ENG-001") |
description | String | Description of the cost center |
parentId | UUID | Parent cost center for hierarchical allocation |
budget | BigDecimal | Allocated budget |
isActive | boolean | Whether the cost center is active |
Endpoints
Create Cost Center
Endpoint: POST /api/v1/billing/cost-centers
curl -X POST http://localhost:8087/api/v1/billing/cost-centers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${TOKEN}" \
-d '{
"tenantId": "550e8400-e29b-41d4-a716-446655440000",
"name": "Data Engineering",
"code": "DE-001",
"description": "Data engineering team costs",
"budget": 10000.00
}'List Cost Centers
Endpoint: GET /api/v1/billing/cost-centers/tenants/:tenantId
Get Cost Center
Endpoint: GET /api/v1/billing/cost-centers/:costCenterId
Update Cost Center
Endpoint: PUT /api/v1/billing/cost-centers/:costCenterId
Delete Cost Center
Endpoint: DELETE /api/v1/billing/cost-centers/:costCenterId
Cost Allocation
Costs are allocated to cost centers based on resource tagging. When usage records are created, they can include a cost center reference in the metadata. The CostAllocationService aggregates costs per cost center for reporting.
Allocation Report
The cost allocation report provides a breakdown of costs by cost center within a billing period, including:
- Total cost per cost center
- Percentage of total spend
- Cost trend over time
- Budget utilization percentage
- Cost by metric type (compute, storage, API calls, etc.)
Hierarchical Cost Centers
Cost centers support a parent-child hierarchy for organizational cost roll-up:
Company (root)
|-- Engineering
| |-- Data Engineering
| |-- Backend
| |-- Frontend
|-- Marketing
| |-- Campaigns
| |-- Analytics
|-- OperationsCosts allocated to child cost centers roll up to their parent for aggregated reporting.