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:
curl.curl, or any HTTP clientThe Account Management API exposes the following data categories relevant for FinOps use cases:
| Data category | API endpoint area | Typical FinOps use case |
|---|---|---|
Subscription details |
| Budget baseline: total commitment, period, days remaining |
Daily costs |
| Spend tracking, burn-rate calculation, period-over-period comparison |
Usage by capability |
| Allocation, chargeback, anomaly detection per capability |
Usage by environment |
| Showback per team or product environment |
The full API specification is available at Account Management API and Account Management > API Explorer.
Access to the Account Management API requires an OAuth client with the account-uac-read scope.
In your Dynatrace environment, select your user name in the bottom-left corner, then select Account Management.
Go to Identity & access management > OAuth clients.
Select Create client and enter:
account-uac-read).Select Create client. Copy and store the following values securely. You can only access them once:
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.
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.
You can now use the API to query subscription details, daily costs, and usage by capability.
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.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.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.
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:
In your Dynatrace environment, go to
Workflows.
Create a new workflow with a Time trigger (for example, daily at 06:00 UTC).
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 tokenconst 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 costsconst 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 platformawait 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.