Try it free

Export cost data via API

  • Latest Dynatrace
  • How-to guide
  • 15-min read
  • Published May 26, 2026

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.

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

  1. Query your subscription, cost, and usage data via curl.
  2. Understand how to automate that export using a Dynatrace Workflow.

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

The full API specification is available at Account Management API and Account Management > API Explorer.

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.

4. Automate with a Dynatrace Workflow

Optional

Running a manual curl is useful for exploration, but for recurring FinOps reporting you want this to run automatically.

A Dynatrace Workflow lets you schedule the API export without any external infrastructure: For example, this section describes a workflow that will run according to the schedule, fetch the latest cost data, and forward the data to whatever endpoint your FinOps tooling exposes.

To set up the Workflow:

  1. In your Dynatrace environment, go to Workflows Workflows.

  2. Create a new workflow with a Time trigger (for example, daily at 06:00 UTC).

  3. Add a Run JavaScript action and paste the following skeleton:

    import { execution } from '@dynatrace-sdk/automation-utils';
    export default async function ({ execution_id }) {
    // 1. Request access token
    const tokenResponse = await fetch("https://sso.dynatrace.com/sso/oauth2/token", {
    method: "POST",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    body: new URLSearchParams({
    grant_type: "client_credentials",
    client_id: "<YOUR_CLIENT_ID>",
    client_secret: "<YOUR_CLIENT_SECRET>",
    resource: "urn:dtaccount:<YOUR_ACCOUNT_UUID>"
    })
    });
    const { access_token } = await tokenResponse.json();
    // 2. Query daily costs
    const costResponse = await fetch(
    "https://api.dynatrace.com/sub/v2/accounts/<ACCOUNT_UUID>/subscriptions/<SUBSCRIPTION_UUID>/cost",
    { headers: { Authorization: `Bearer ${access_token}` } }
    );
    const costs = await costResponse.json();
    // 3. Forward to your webhook / FinOps platform
    await fetch("<YOUR_WEBHOOK_URL>", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(costs)
    });
    }

Replace the placeholders with your OAuth credentials and target webhook URL.

If you want to store cost data inside Dynatrace and query it with DQL or build dashboards from it, see Explore your DPS for Hybrid subscription with dashboards for a full walkthrough using business events and Grail.

Next steps

  • Attribute costs to teams using allocation tags. For more information, see Allocate.
  • 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
  • Billing report
  • Allocate
Related tags
Dynatrace Platform