Try it free

Export cost data via API (Dynatrace Classic)

  • Dynatrace Classic
  • How-to guide
  • 15-min read

Every usage and cost data point you see in Account Management is also available via the Dynatrace Account Management API. This means you can pull your consumption data into any tool your organization already uses (FinOps platforms, finance systems, chargeback reports, or custom dashboards) without manual exports. Common use cases include:

  • Share cost visibility with budget owners and finance teams.
  • Feed consumption data into enterprise tools.
  • Automate budget reports and alerts.
  • Integrate with internal cost allocation or chargeback systems.

By the end of this tutorial, you will be able to:

  1. Query your subscription, cost, and usage data via curl.

Prerequisites

  • Account Admin or Subscription Viewer permissions
  • curl, or any HTTP client
  • Basic familiarity with REST APIs

What data is available

The Account Management API exposes the following data categories relevant for FinOps use cases:

Data categoryAPI endpoint areaTypical FinOps use case

Subscription details

/sub/v2/.../subscriptions

Budget baseline: total commitment, period, days remaining

Daily costs

/sub/v2/.../cost

Spend tracking, burn-rate calculation, period-over-period comparison

Usage by capability

/sub/v2/.../usage

Allocation, chargeback, anomaly detection per capability

Usage by environment

/sub/v2/.../usage (filtered)

Showback per team or product environment

You can also explore all available endpoints directly in the API Explorer in Account Management or via the Account Management API documentation.

How-to

1. Create an OAuth client

Access to the Account Management API requires an OAuth client with the account-uac-read scope.

  1. In your Dynatrace environment, select your user name in the bottom-left corner, then select Account Management.

  2. Go to Identity & access management > OAuth clients.

  3. Select Create client and enter:

    • An email address to associate with the client.
    • A description (optional).
    • Under Permissions > Account, select View usage and consumption (account-uac-read).
  4. Select Create client. Copy and store the following values securely. You can only access them once:

    • Client ID
    • Client secret
    • Account URN
  5. Save your Account UUID, which visible in the browser address bar in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Store your client secret securely. It cannot be retrieved after creation.

2. Request an access token

Access tokens are short-lived (5 minutes) and must be requested before each API call.

To request an access token, run the following curl command:

curl -X POST "https://sso.dynatrace.com/sso/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=<YOUR_CLIENT_ID>" \
-d "client_secret=<YOUR_CLIENT_SECRET>" \
-d "resource=urn:dtaccount:<YOUR_ACCOUNT_UUID>"

The response contains your access_token:

{
"access_token": "dt0s01.XXXX...",
"token_type": "Bearer",
"expires_in": 300
}

Use the access_token value in the Authorization header for all subsequent API calls.

3. Query cost and usage data

You can now use the API to query subscription details, daily costs, and usage by capability.

Query subscription details

Run the following curl command to get your active subscription UUID and budget status:

curl -X GET "https://api.dynatrace.com/sub/v2/accounts/<ACCOUNT_UUID>/subscriptions" \
-H "Authorization: Bearer <ACCESS_TOKEN>"

The response includes:

  • uuid: your subscription UUID, needed for cost and usage queries.
  • budget.total: your annual commitment.
  • budget.used: spend to date.
  • currentPeriod.daysRemaining: days left in the current subscription period.

Query daily costs

Run the following curl command to get costs broken down by day for the active subscription:

curl -X GET "https://api.dynatrace.com/sub/v2/accounts/<ACCOUNT_UUID>/subscriptions/<SUBSCRIPTION_UUID>/cost" \
-H "Authorization: Bearer <ACCESS_TOKEN>"

Each record in the response represents one day and contains:

  • startTime / endTime: the day covered.
  • value: monetary cost for that day (in your subscription's currency).
  • capability: which DPS capability incurred the cost.

Query usage by capability

Get raw metered usage across capabilities:

curl -X GET "https://api.dynatrace.com/sub/v2/accounts/<ACCOUNT_UUID>/subscriptions/<SUBSCRIPTION_UUID>/usage" \
-H "Authorization: Bearer <ACCESS_TOKEN>"

Filter by environment or capability using query parameters. See the Account Management API reference for the full parameter list.

Use daily cost data for financial reporting and chargeback. Use usage data when you need the raw metered units (for example, GiB-hours or host-hours) for capacity planning.

Next steps

  • Set up budget alerts to be notified before anomalies hit your bill. For more information, see Control.
  • Explore the full API reference. For more information, see Account Management API.

Related topics

  • Account Management API
  • Where to view your costs (Dynatrace Classic)
  • Billing report (Dynatrace Classic)
Related tags
Dynatrace Platform