---
title: Get cost anomaly
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Cloud Cost Management
---

# Get cost anomaly{% #get-cost-anomaly %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in Preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                         |
| ----------------- | -------------------------------------------------------------------- |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/cost/anomalies/{anomaly_id} |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/cost/anomalies/{anomaly_id} |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/cost/anomalies/{anomaly_id}      |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/cost/anomalies/{anomaly_id}      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/cost/anomalies/{anomaly_id}  |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/cost/anomalies/{anomaly_id}     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/cost/anomalies/{anomaly_id} |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/cost/anomalies/{anomaly_id} |

### Overview

Get a detected Cloud Cost Management anomaly by UUID.

OAuth apps require the `cloud_cost_management_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#cloud-cost-management) to access this endpoint.



### Arguments

#### Path Parameters

| Name                         | Type   | Description                   |
| ---------------------------- | ------ | ----------------------------- |
| anomaly_id [*required*] | string | The UUID of the cost anomaly. |

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response object containing a single Cloud Cost Management anomaly.

| Parent field         | Field                                   | Type     | Description                                                                                           |
| -------------------- | --------------------------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
|                      | data                                    | object   | Resource wrapper for a single cost anomaly.                                                           |
| data                 | attributes [*required*]            | object   | A single detected Cloud Cost Management anomaly.                                                      |
| attributes           | actual_cost [*required*]           | double   | Actual cost incurred during the anomaly window.                                                       |
| attributes           | anomalous_cost_change [*required*] | double   | Anomalous cost change relative to the expected baseline.                                              |
| attributes           | anomaly_end [*required*]           | int64    | Anomaly end timestamp in Unix milliseconds.                                                           |
| attributes           | anomaly_start [*required*]         | int64    | Anomaly start timestamp in Unix milliseconds.                                                         |
| attributes           | correlated_tags [*required*]       | object   | Map of correlated tag keys to the list of correlated tag values.                                      |
| additionalProperties | <any-key>                               | [string] | The list of correlated values for the tag key.                                                        |
| attributes           | dimensions [*required*]            | object   | Map of cost dimension keys to their values for the anomaly grouping.                                  |
| additionalProperties | <any-key>                               | string   | The dimension value.                                                                                  |
| attributes           | dismissal                               | object   | Resolution metadata for an anomaly that has been dismissed.                                           |
| dismissal            | cause [*required*]                 | string   | Reason the anomaly was dismissed.                                                                     |
| dismissal            | dismissal_id [*required*]          | string   | Unique identifier of the dismissal record.                                                            |
| dismissal            | message [*required*]               | string   | Optional message explaining the dismissal.                                                            |
| dismissal            | updated_at [*required*]            | int64    | Timestamp of the last dismissal update in Unix milliseconds.                                          |
| dismissal            | updated_by [*required*]            | string   | Identifier of the user that last updated the dismissal.                                               |
| attributes           | max_cost [*required*]              | double   | Maximum cost observed during the anomaly window.                                                      |
| attributes           | provider [*required*]              | string   | Cloud or SaaS provider associated with the anomaly (for example `aws`, `gcp`, `azure`).               |
| attributes           | query [*required*]                 | string   | The metrics query that detected the anomaly.                                                          |
| attributes           | uuid [*required*]                  | string   | The unique identifier of the anomaly.                                                                 |
| data                 | id [*required*]                    | string   | The unique identifier of the anomaly.                                                                 |
| data                 | type [*required*]                  | enum     | Type of the cost anomalies collection resource. Must be `anomalies`. Allowed enum values: `anomalies` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "actual_cost": 3001.24,
      "anomalous_cost_change": 1250.75,
      "anomaly_end": 1730429150000,
      "anomaly_start": 1730259950000,
      "correlated_tags": {
        "<any-key>": []
      },
      "dimensions": {
        "<any-key>": "string"
      },
      "dismissal": {
        "cause": "false_positive",
        "dismissal_id": "12345678-1234-1234-1234-123456789abc",
        "message": "This was expected due to planned infrastructure changes.",
        "updated_at": 1730344150000,
        "updated_by": "user@example.com"
      },
      "max_cost": 5000.5,
      "provider": "aws",
      "query": "sum:aws.cost.net.amortized{aws_cost_type IN (Usage,DiscountedUsage,SavingsPlanCoveredUsage) AND aws_product NOT IN (supportenterprise) AND service:\"ec2\"}.rollup(sum, daily)",
      "uuid": "b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09"
    },
    "id": "b0a6aaa9-3c4c-48cb-9447-a0d1338b3e09",
    "type": "anomalies"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Forbidden
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \# Path parameters export anomaly_id="CHANGE_ME" \# Curl command curl -X GET "https://api.datadoghq.com/api/v2/cost/anomalies/${anomaly_id}" \
-H "Accept: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" 
                
##### 

```python
"""
Get cost anomaly returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi

configuration = Configuration()
configuration.unstable_operations["get_cost_anomaly"] = True
with ApiClient(configuration) as api_client:
    api_instance = CloudCostManagementApi(api_client)
    response = api_instance.get_cost_anomaly(
        anomaly_id="anomaly_id",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get cost anomaly returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.get_cost_anomaly".to_sym] = true
end
api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new
p api_instance.get_cost_anomaly("anomaly_id")
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get cost anomaly returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.GetCostAnomaly", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewCloudCostManagementApi(apiClient)
	resp, r, err := api.GetCostAnomaly(ctx, "anomaly_id")

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `CloudCostManagementApi.GetCostAnomaly`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `CloudCostManagementApi.GetCostAnomaly`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get cost anomaly returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CloudCostManagementApi;
import com.datadog.api.client.v2.model.CostAnomalyResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.getCostAnomaly", true);
    CloudCostManagementApi apiInstance = new CloudCostManagementApi(defaultClient);

    try {
      CostAnomalyResponse result = apiInstance.getCostAnomaly("anomaly_id");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling CloudCostManagementApi#getCostAnomaly");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Get cost anomaly returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;

#[tokio::main]
async fn main() {
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.GetCostAnomaly", true);
    let api = CloudCostManagementAPI::with_config(configuration);
    let resp = api.get_cost_anomaly("anomaly_id".to_string()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get cost anomaly returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.getCostAnomaly"] = true;
const apiInstance = new v2.CloudCostManagementApi(configuration);

const params: v2.CloudCostManagementApiGetCostAnomalyRequest = {
  anomalyId: "anomaly_id",
};

apiInstance
  .getCostAnomaly(params)
  .then((data: v2.CostAnomalyResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
