Get cost details for a pay-as-you-go subscription

If your subscription is through Microsoft Online Service Program (MOSP) pay-as-you-go, or Visual Studio, we suggest using Exports or the Exports API to access detailed cost data, previously referred to as usage details. The Cost Details API report isn't supported for your subscription type yet.

If you need to download small datasets and you don't want to use Azure Storage, you can also use the Consumption Usage Details API. To use the API, read the following instructions.

Note

The API is deprecated for all customers except those with pay-as-you-go and Visual Studio subscriptions. If you're an EA or MCA customer don't use this API.

The exact date for discontinuing the API is undetermined. Before the Consumption Usage Details API is deprecated, the Cost Details API will get updates to support both pay-as-you-go and Visual Studio subscriptions.

Example Consumption Usage Details API requests

The following example requests are used by Microsoft customers to address common scenarios.

Get usage details for a scope during a specific date range

The data that gets returned by the request corresponds to the date when the data got received by the billing system. It might include costs from multiple invoices. The call to use varies by your subscription type.

For pay-as-you-go subscriptions, use the following call.

GET https://management.chinacloudapi.cn/{scope}/providers/Microsoft.Consumption/usageDetails?$filter=properties%2FusageStart%20ge%20'2020-02-01'%20and%20properties%2FusageEnd%20le%20'2020-02-29'&$top=1000&api-version=2019-10-01

Get amortized cost details

If you need actual costs to show purchases as they're accrued, change the metric to ActualCost in the following request. To use amortized and actual costs, you must use version 2019-04-01-preview or later.

GET https://management.chinacloudapi.cn/{scope}/providers/Microsoft.Consumption/usageDetails?metric=AmortizedCost&$filter=properties/usageStart+ge+'2019-04-01'+AND+properties/usageEnd+le+'2019-04-30'&api-version=2019-04-01-preview