---
title: "Aggregate costs based on input criteria"
method: POST
path: "/v2/billing/aggregation"
tags: ["Billing"]
---

# Aggregate costs based on input criteria

`POST /v2/billing/aggregation`

Generate cost aggregation.

## Request body

- BillingAggregationRequest
  - `service_account_ids` string[] — Service Account IDs
  - `filters` QueryOperator
    - `__type` string, required — Concrete type used for polymorphic deserialization (discriminator)
  - `start_date` string, date-time, required — start of the spend period
  - `end_date` string, date-time, required — end of the spend period
  - `time_zone` string — Optional timezone of the caller
  - `platform` 'kubernetes' — Platforms
  - `skip_service_account_grouping` boolean — If set, do not group by service account
  - `billing_source` string, required — Billing plan to select data from
  - `group_by` BillingGroupByDetails[] — If set, the dimensions to group results by
    - `selector` 'service_account_tags' | 'service_name' | 'tenant_id' | 'tenant_tags' | 'service_account_id' | 'delegate_service_account_id' | 'availability_zone' | 'billing_entity' | 'line_item_type' | 'location' | 'meter_sub_category' | 'pricing_category' | 'pricing_purchase_option' | 'product_category' | 'product_family' | 'product_service_code' | 'product_sku' | 'publisher' | 'resource_category' | 'resource_group' | 'resource_id' | 'resource_name' | 'resource_operation' | 'extras' | 'tags' | 'hierarchy' | 'dimension' | 'compartment_name' | 'compartment_id' | 'resource_type' | 'utilization_type', required — Dimension to group results by
    - `key` string — Key to use with Extras, Tags, Hierarchy, and Dimension
    - `value` string — Value to use with Extras, Tags and Hierarchy
    - `kind` string — Value to use in Tags
    - `groups` BillingCustomGroup[] — List of custom groups to use with Dimension
      - `attribute_value` string — Value for the group
      - `attribute_key` string — Key for the group
      - `filter` QueryOperator
        - `__type` string, required — Concrete type used for polymorphic deserialization (discriminator)
      - `grouping_rule_id` string — Grouping Rule ID
      - `dimension_id` string — Dimension ID
  - `limit` integer — If set, limits the results to given number.
  - `billing_mode` boolean — If set, results for cost data gets computed based on billing period start dates that falls in the range of the start date and end date.
  - `include_resource_children` boolean — If set, intercept the query operators to manipulate platform specific accounts. This is only applicable for ServiceAccountQueryOperator manipulation when the visitor is platform and call made through billing plans.

## Response `200`

Success

- BillingAggregationResult[]
  - `identity` BillingLineItemIdentityPlus
    - `service_account_id` string — Service Account the line item belongs to
    - `delegate_service_account_id` string — Service Account internally responsible for creating, updating, or deleting the line item
    - `line_item_type` string — Line item type
    - `availability_zone` string — Availability Zone
    - `billing_entity` string — Billing Entity
    - `currency` 'AED' | 'ALL' | 'ARS' | 'AUD' | 'BAM' | 'BDT' | 'BGN' | 'BHD' | 'BRL' | 'CAD' | 'CHF' | 'CLP' | 'CNY' | 'COP' | 'CRC' | 'CZK' | 'DKK' | 'EGP' | 'EUR' | 'GBP' | 'HKD' | 'HRK' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'ISK' | 'JPY' | 'KES' | 'KRW' | 'KWD' | 'KZT' | 'MOP' | 'MVR' | 'MXN' | 'MYR' | 'NOK' | 'NZD' | 'OMR' | 'PEN' | 'PHP' | 'PKR' | 'PLN' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'SAR' | 'SEK' | 'SGD' | 'THB' | 'TRY' | 'TWD' | 'USD' | 'VND' | 'ZAR' — currency of the cost. Example 'currency':'USD'
    - `location` string — Line item location
    - `meter_sub_category` string — Meter Sub Category
    - `pricing_category` string — Pricing Category
    - `pricing_purchase_option` string — Pricing Purchase Option
    - `product_category` string — Product category
    - `product_family` string — Product family
    - `product_service_code` string — Product service code
    - `product_sku` string — Product SKU
    - `publisher` string — Publisher
    - `resource_category` string — Resource category
    - `resource_group` string — Resource group
    - `resource_id` string — Resource ID
    - `resource_name` string — Resource name
    - `resource_operation` string — Resource operation
    - `resource_type` string — Resource type
    - `utilization_type` string — Utilization type
    - `extras` KeyValuePair[] — List of tag key/value pairs
      - `key` string — Key of the pair
      - `value` string — Value of the pair
    - `tags` KeyValuePair[] — List of tag key/value pairs
      - `key` string — Key of the pair
      - `value` string — Value of the pair
    - `hierarchy` KeyValuePair[] — List of tag key/value pairs
      - `key` string — Key of the pair
      - `value` string — Value of the pair
    - `custom` KeyValuePair[] — List of tag key/value pairs
      - `key` string — Key of the pair
      - `value` string — Value of the pair
    - `dimension_memberships` DimensionMembershipKeyValuePair[] — List of Dimension Membership Key-Value Pairs
      - `dimension_id` string, required — Dimension ID
      - `grouping_rule_id` string, required — Grouping Rule ID
    - `compartment_id` string — Compartment ID
    - `compartment_name` string — Compartment Name
    - `service_name` string — Service name
    - `tenant_id` string — Tenant ID
  - `value` number — Result of aggregation

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `500` — Internal Server Error

---

[API](https://skmtc.net/corestack/apis/corestack-external-api.md) · [All operations](https://skmtc.net/corestack/apis/corestack-external-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/corestack/corestack-external-api/versions/bf2cdf20826d/schema)
