provider Usage Metering GET /api/v2/cost_by_tag/monthly_cost_attribution
@utdk/datadog /api/v2/cost_by_tag/monthly_cost_attribution
Get Monthly Cost Attribution
Get monthly cost attribution by tag across multi-org and single root-org accounts. Cost Attribution data for a given month becomes available no later than the 19th of the following month. This API endpoint is paginated. To make sure you receive all records, check if the value of `next_record_id` is set in the response. If it is, make another request and pass `next_record_id` as a parameter. Pseudo code example: ``` response := GetMonthlyCostAttribution(start_month, end_month) cursor := response.metadata.pagination.next_record_id WHILE cursor != null BEGIN sleep(5 seconds) # Avoid running into rate limit response := GetMonthlyCostAttribution(start_month, end_month, next_record_id=cursor) cursor := response.metadata.pagination.next_record_id END ``` This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/). This endpoint is not available in the Government (US1-FED) site.
start_month query required
Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost beginning in this month.
string
end_month query
Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost ending this month.
string
fields query required
Comma-separated list specifying cost types (e.g., `<billing_dimension>_on_demand_cost`, `<billing_dimension>_committed_cost`, `<billing_dimension>_total_cost`) and the proportions (`<billing_dimension>_percentage_in_org`, `<billing_dimension>_percentage_in_account`). Use `*` to retrieve all fields. Example: `infra_host_on_demand_cost,infra_host_percentage_in_account` To obtain the complete list of active billing dimensions that can be used to replace `<billing_dimension>` in the field names, make a request to the [Get active billing dimensions API](https://docs.datadoghq.com/api/latest/usage-metering/#get-active-billing-dimensions-for-cost-attribution).
string
sort_direction query
The direction to sort by: `[desc, asc]`.
enum: desc, asc
sort_name query
The billing dimension to sort by. Always sorted by total cost. Example: `infra_host`.
string
tag_breakdown_keys query
Comma separated list of tag keys used to group cost. If no value is provided the cost will not be broken down by tags. To see which tags are available, look for the value of `tag_config_source` in the API response.
string
next_record_id query
List following results with a next_record_id provided in the previous query.
string
include_descendants query
Include child org cost in the response. Defaults to `true`.
boolean

Try it

Authentication
Configure credentials for Datadog API V2 Collection
Gateway
The gateway proxies requests and injects credentials server-side. Configure credentials above, then enter your gateway URL.

Saved automatically to browser storage.

getmonthlycostattribution
GET/api/v2/cost_by_tag/monthly_cost_attribution
Get monthly cost attribution by tag across multi-org and single root-org accounts. Cost Attribution data for a given month becomes available no later than the 19th of the following month. This API endpoint is paginated. To make sure you receive all records, check if the value of `next_record_id` is set in the response. If it is, make another request and pass `next_record_id` as a parameter. Pseudo code example: ``` response := GetMonthlyCostAttribution(start_month, end_month) cursor := response.metadata.pagination.next_record_id WHILE cursor != null BEGIN sleep(5 seconds) # Avoid running into rate limit response := GetMonthlyCostAttribution(start_month, end_month, next_record_id=cursor) cursor := response.metadata.pagination.next_record_id END ``` This endpoint is only accessible for [parent-level organizations](https://docs.datadoghq.com/account_management/multi_organization/). This endpoint is not available in the Government (US1-FED) site.

required

Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost beginning in this month.

Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for cost ending this month.

required

Comma-separated list specifying cost types (e.g., `<billing_dimension>_on_demand_cost`, `<billing_dimension>_committed_cost`, `<billing_dimension>_total_cost`) and the proportions (`<billing_dimension>_percentage_in_org`, `<billing_dimension>_percentage_in_account`). Use `*` to retrieve all fields. Example: `infra_host_on_demand_cost,infra_host_percentage_in_account` To obtain the complete list of active billing dimensions that can be used to replace `<billing_dimension>` in the field names, make a request to the [Get active billing dimensions API](https://docs.datadoghq.com/api/latest/usage-metering/#get-active-billing-dimensions-for-cost-attribution).

The direction to sort by: `[desc, asc]`.

The billing dimension to sort by. Always sorted by total cost. Example: `infra_host`.

Comma separated list of tag keys used to group cost. If no value is provided the cost will not be broken down by tags. To see which tags are available, look for the value of `tag_config_source` in the API response.

List following results with a next_record_id provided in the previous query.

Include child org cost in the response. Defaults to `true`.

Enter a gateway URL above to enable sending.

Code snippet
Updates live as you fill in the form above.

TypeScript

import datadog from '@utdk/datadog';

await datadog.getmonthlycostattribution({
  "sort_direction": "desc",
  "include_descendants": true
})