Terraform API support and access permission handling

  • Latest Dynatrace
  • Reference
  • 3-min read
  • Published Jul 22, 2025

Dynatrace offers different options to authenticate API calls. The Dynatrace Terraform Provider supports the following authentication options.

  • Platform tokens
  • OAuth clients
  • Access tokens (classic)

For more information about Identity and Access Management (IAM), including platform tokens, OAuth clients, and API tokens / access tokens classic, see Tokens and OAuth clients.

Create platform tokens

Platform tokens can be used to authenticate API calls against Dynatrace. These platform tokens are long-lived access tokens. For the full list of supported platform token services, see Available services for platform tokens.

Defining the environment variables for your authentication client and secret is useful. The following code blocks shows you how to define the environment variables for Windows and Linux.

set DYNATRACE_ENV_URL=https://<YOUR-DT-ENV-ID>.apps.dynatrace.com
set DYNATRACE_PLATFORM_TOKEN=<YOUR_PLATFORM_TOKEN>

Create OAuth client

To create an OAuth client, follow the steps described in OAuth clients.

To ensure the OAuth client works as intended, verify that the service user's groups grant the same scopes as the OAuth client you have created for all environments you want to use it with. For more details on controlling permissions, see Working with policies.

The Dynatrace Terraform Provider requests OAuth access tokens using your client credentials to make authenticated API calls. Therefore, defining the environment variables for your authentication client and secret is useful. The following code blocks show you how to define the environment variables for Windows and Linux.

set DYNATRACE_ENV_URL=https://<YOUR-DT-ENV-ID>.apps.dynatrace.com
set DYNATRACE_OAUTH_CLIENT_ID=<YOUR_CLIENT_ID>
set DYNATRACE_OAUTH_CLIENT_SECRET=<YOUR_CLIENT_SECRET>

Create API access token

Use access tokens to authenticate Dynatrace Classic API calls. For more information on how to use a Dynatrace API token, see Dynatrace API - Tokens and authentication.

It's useful to define the environment variables for the authentication client and secret.

The following table shows you how to define the environment variables for Windows and Linux.

set DYNATRACE_ENV_URL=https://<YOUR-DT-ENV-ID>.apps.dynatrace.com
set DYNATRACE_API_TOKEN=<YOUR_API_TOKEN>

API coverage

The Dynatrace Terraform Provider contains most Dynatrace APIs. All supported resources are listed in the Dynatrace Terraform Provider documentation in the Terraform Registry.

Always consider the correct permission scopes that are needed for the selected API resources. Information can be found at IAM policy reference and the Dynatrace Terraform provider GitHub repository.

Related tags
Software Delivery