---
title: "Create Kubernetes Cost Allocation"
method: POST
path: "/kubernetes-cost-allocation"
tags: ["Kubernetes Cost Allocation"]
---

# Create Kubernetes Cost Allocation

`POST /kubernetes-cost-allocation`

## Request

- Base URL: `https://oneuptime.com/api`
- URL: `https://oneuptime.com/api/kubernetes-cost-allocation`
- Auth: API key in header `APIKey`
- TypeScript: <https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/docs/kubernetes-cost-allocation/post.ts> (a function with typed inputs; its response is checked against the schema)

Endpoint to create a new Kubernetes Cost Allocation

## Request body

- object
  - `data` KubernetesCostAllocationV1CreateSchema, required: Create schema for KubernetesCostAllocationV1
    - `projectId` string, uuid: ID of project
    - `kubernetesClusterId` string, uuid, required: ID of the KubernetesCluster this cost row was metered on. Resolved at ingest from the cluster name (findOrCreateByClusterIdentifier), so every stored row has one.
    - `clusterName` string, required: Cluster identifier as reported by the agent (matches KubernetesCluster.clusterIdentifier and the resource.k8s.cluster.name metric attribute).
    - `k8sClusterEntityKey` string: Stable 16-hex entity key of the cluster (see Common/Utils/Telemetry/EntityKey.keyForKubernetesCluster); joins cost rows to the metric rollups keyed by the same column.
    - `windowStart` string, date-time, required: Start of the allocation window this row covers.
    - `windowEnd` string, date-time, required: End of the allocation window this row covers.
    - `namespace` string: Kubernetes namespace of the workload. Engine sentinels ("__idle__", "__unallocated__") mark non-workload capacity.
    - `controllerKind` string: Kind of the owning controller (deployment / statefulset / daemonset / job / cronjob / replicaset / pod).
    - `controllerName` string: Name of the owning controller (the workload).
    - `podName` string: Name of the pod, when the row is pod- or container-level.
    - `containerName` string: Name of the container, when the row is container-level.
    - `nodeName` string: Node the workload ran on during the window.
    - `providerId` string: Cloud provider instance identifier of the node, when known.
    - `labels` object: Kubernetes labels of the workload (merged pod/namespace labels as reported by the cost engine). Enables cost-by-label (team / app / env) queries.
    - `labelKeys` string[]: Label keys extracted from labels
    - `cpuCoreHours` number: CPU core-hours allocated over the window.
    - `cpuCoreRequestAverage` number: Average CPU cores requested over the window.
    - `cpuCoreUsageAverage` number: Average CPU cores actually used over the window.
    - `cpuCoreLimitAverage` number: Average CPU core limit over the window. 0 when no limit is set — which is also what a row ingested before this column reads back.
    - `cpuCost` number: Cost of allocated CPU over the window.
    - `gpuHours` number: GPU-hours allocated over the window.
    - `gpuCost` number: Cost of allocated GPUs over the window.
    - `ramByteHours` number: RAM byte-hours allocated over the window.
    - `ramBytesRequestAverage` number: Average RAM bytes requested over the window.
    - `ramBytesUsageAverage` number: Average RAM bytes actually used over the window.
    - `ramBytesLimitAverage` number: Average RAM byte limit over the window. 0 when no limit is set — which is also what a row ingested before this column reads back.
    - `ramBytesUsageMax` number: Peak RAM bytes used during the window, from Prometheus rather than the cost engine — the engine only reports averages, and an hourly mean hides the burst that OOMKills a container. 0 when the agent has no Prometheus configured, when the scrape had no data, or on rows ingested before this column; treat 0 as 'unknown', never as a real peak.
    - `ramCost` number: Cost of allocated RAM over the window.
    - `pvByteHours` number: Persistent-volume byte-hours allocated over the window.
    - `pvCost` number: Cost of persistent volumes over the window.
    - `networkCost` number: Network egress cost over the window.
    - `loadBalancerCost` number: Load balancer cost over the window.
    - `sharedCost` number: Share of cluster overhead distributed to this workload.
    - `externalCost` number: Out-of-cluster cost attributed to this workload, when the engine reports one.
    - `totalCost` number: Total cost of the row over the window (all components).
    - `cpuEfficiency` number: CPU usage / request ratio over the window (0..1+).
    - `ramEfficiency` number: RAM usage / request ratio over the window (0..1+).
    - `totalEfficiency` number: Cost-weighted cpu+ram efficiency over the window (0..1+).
    - `currency` string: Currency code of the cost figures as configured in the cost engine (e.g. "USD"). Empty when the engine reports none — treat as USD.
    - `shipmentId` string: Content hash identifying the agent delivery this row arrived in. Used to deduplicate re-shipped windows; empty for rows ingested before the shipment contract.
    - `shipmentChunk` number: Index of the request within its shipment that carried this row. 0 for single-request shipments and for rows ingested before the shipment contract.

## Response `201`

Created successfully

- object
  - `data` KubernetesCostAllocationV1ReadSchema
    - `projectId` string, required: Project ID
    - `kubernetesClusterId` string, required: Kubernetes Cluster ID
    - `clusterName` string, required: Cluster Name
    - `k8sClusterEntityKey` string: Kubernetes Cluster Entity Key
    - `windowStart` string: Window Start
    - `windowEnd` string: Window End
    - `namespace` string: Namespace
    - `controllerKind` string: Controller Kind
    - `controllerName` string: Controller Name
    - `podName` string: Pod Name
    - `containerName` string: Container Name
    - `nodeName` string: Node Name
    - `providerId` string: Provider ID
    - `labels` string: Labels
    - `labelKeys` string[]: Label Keys
    - `cpuCoreHours` number: CPU Core Hours
    - `cpuCoreRequestAverage` number: CPU Core Request Average
    - `cpuCoreUsageAverage` number: CPU Core Usage Average
    - `cpuCoreLimitAverage` number: CPU Core Limit Average
    - `cpuCost` number: CPU Cost
    - `gpuHours` number: GPU Hours
    - `gpuCost` number: GPU Cost
    - `ramByteHours` number: RAM Byte Hours
    - `ramBytesRequestAverage` number: RAM Bytes Request Average
    - `ramBytesUsageAverage` number: RAM Bytes Usage Average
    - `ramBytesLimitAverage` number: RAM Bytes Limit Average
    - `ramBytesUsageMax` number: RAM Bytes Usage Max
    - `ramCost` number: RAM Cost
    - `pvByteHours` number: PV Byte Hours
    - `pvCost` number: PV Cost
    - `networkCost` number: Network Cost
    - `loadBalancerCost` number: Load Balancer Cost
    - `sharedCost` number: Shared Cost
    - `externalCost` number: External Cost
    - `totalCost` number: Total Cost
    - `cpuEfficiency` number: CPU Efficiency
    - `ramEfficiency` number: RAM Efficiency
    - `totalEfficiency` number: Total Efficiency
    - `currency` string: Currency
    - `shipmentId` string: Shipment ID
    - `shipmentChunk` number: Shipment Chunk

## Other responses

- `400`: Bad request. This response indicates that the request was malformed or contained invalid data.
- `401`: Unauthorized. This response indicates that the request requires user authentication.
- `402`: Payment Required. This response indicates that the request requires payment or a valid subscription.
- `403`: Forbidden. This response indicates that the server understood the request, but refuses to authorize it.
- `405`: Project not found. This response indicates that the requested project does not exist or is not accessible.
- `408`: Request Timeout. This response indicates that the server timed out waiting for the request.
- `415`: Unable to reach server. This response indicates that the server is currently unreachable or down.
- `422`: Not authorized. This response indicates that the user does not have permission to access the requested resource.
- `500`: Internal Server Error. This response indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.

---

[API](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification.md) - [All operations](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/llms.txt) - [OpenAPI document](https://skmtc.dev/oneuptime/apis/oneuptime-openapi-specification/revisions/ba3307d00304?raw)
