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

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Update a unit cost{% #update-a-unit-cost %}
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 | PUT https://api.ap1.datadoghq.com/api/v2/cost/unit_costs/{unit_cost_id} |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v2/cost/unit_costs/{unit_cost_id} |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v2/cost/unit_costs/{unit_cost_id}      |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v2/cost/unit_costs/{unit_cost_id}      |
| us2.ddog-gov.com  | PUT https://api.us2.ddog-gov.com/api/v2/cost/unit_costs/{unit_cost_id}  |
| uk1.datadoghq.com | PUT https://api.uk1.datadoghq.com/api/v2/cost/unit_costs/{unit_cost_id} |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v2/cost/unit_costs/{unit_cost_id}     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v2/cost/unit_costs/{unit_cost_id} |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v2/cost/unit_costs/{unit_cost_id} |

### Overview

Replace an ROI metric (unit cost) with a new set of attributes. This endpoint requires the `cloud_cost_management_read` permission.

### Arguments

#### Path Parameters

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

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field      | Field                               | Type     | Description                                                                             |
| ----------------- | ----------------------------------- | -------- | --------------------------------------------------------------------------------------- |
|                   | data [*required*]              | object   | The data object of a unit cost replace request.                                         |
| data              | attributes [*required*]        | object   | The attributes of a unit cost create or replace request.                                |
| attributes        | denominator_query [*required*] | object   | A timeseries object containing `queries` and `formulas` arrays.                         |
| denominator_query | formulas [*required*]          | [object] | The list of formulas applied to the queries for this side of the ratio.                 |
| denominator_query | queries [*required*]           | [object] | The list of queries evaluated for this side of the ratio.                               |
| attributes        | description                         | string   | An optional description of the unit cost. At most 2000 characters.                      |
| attributes        | name [*required*]              | string   | The name of the unit cost. At most 200 characters.                                      |
| attributes        | numerator_query [*required*]   | object   | A timeseries object containing `queries` and `formulas` arrays.                         |
| numerator_query   | formulas [*required*]          | [object] | The list of formulas applied to the queries for this side of the ratio.                 |
| numerator_query   | queries [*required*]           | [object] | The list of queries evaluated for this side of the ratio.                               |
| attributes        | unit_label [*required*]        | string   | The label describing the denominator unit, for example `user`. At most 100 characters.  |
| data              | id [*required*]                | uuid     | The UUID of the unit cost being replaced. Must match the `unit_cost_id` path parameter. |
| data              | type [*required*]              | enum     | The JSON:API resource type for a unit cost. Allowed enum values: `unit_cost`            |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "denominator_query": {
        "formulas": [
          []
        ],
        "queries": [
          []
        ]
      },
      "description": "Amortized cloud spend divided by the number of active users.",
      "name": "Cloud cost per active user",
      "numerator_query": {
        "formulas": [
          []
        ],
        "queries": [
          []
        ]
      },
      "unit_label": "user"
    },
    "id": "64aecd58-e355-4f07-9c3a-56ff6bda6cd8",
    "type": "unit_cost"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
A response containing a single unit cost.

| Parent field      | Field                               | Type      | Description                                                                                                               |
| ----------------- | ----------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------- |
|                   | data [*required*]              | object    | The data object of a unit cost response.                                                                                  |
| data              | attributes [*required*]        | object    | The attributes of a unit cost.                                                                                            |
| attributes        | created_at [*required*]        | date-time | The time the unit cost was created.                                                                                       |
| attributes        | created_by [*required*]        | uuid      | The UUID of the user who created the unit cost.                                                                           |
| attributes        | denominator_query [*required*] | object    | A timeseries object containing `queries` and `formulas` arrays.                                                           |
| denominator_query | formulas [*required*]          | [object]  | The list of formulas applied to the queries for this side of the ratio.                                                   |
| denominator_query | queries [*required*]           | [object]  | The list of queries evaluated for this side of the ratio.                                                                 |
| attributes        | denominator_type [*required*]  | string    | The data source of the denominator queries, or `multisource` when the denominator queries span more than one data source. |
| attributes        | description                         | string    | The description of the unit cost. Omitted when the unit cost has no description.                                          |
| attributes        | name [*required*]              | string    | The name of the unit cost.                                                                                                |
| attributes        | numerator_query [*required*]   | object    | A timeseries object containing `queries` and `formulas` arrays.                                                           |
| numerator_query   | formulas [*required*]          | [object]  | The list of formulas applied to the queries for this side of the ratio.                                                   |
| numerator_query   | queries [*required*]           | [object]  | The list of queries evaluated for this side of the ratio.                                                                 |
| attributes        | org_id [*required*]            | int64     | The ID of the organization the unit cost belongs to.                                                                      |
| attributes        | unit_label [*required*]        | string    | The label describing the denominator unit.                                                                                |
| attributes        | updated_at [*required*]        | date-time | The time the unit cost was last updated.                                                                                  |
| attributes        | updated_by [*required*]        | uuid      | The UUID of the user who last updated the unit cost.                                                                      |
| data              | id [*required*]                | uuid      | The UUID of the unit cost.                                                                                                |
| data              | type [*required*]              | enum      | The JSON:API resource type for a unit cost. Allowed enum values: `unit_cost`                                              |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "created_at": "2026-09-01T18:46:15.933716Z",
      "created_by": "36ea1610-8866-4bd3-bb6d-9bb9fc87cad2",
      "denominator_query": {
        "formulas": [
          []
        ],
        "queries": [
          []
        ]
      },
      "denominator_type": "metrics",
      "description": "Amortized cloud spend divided by the number of active users.",
      "name": "Cloud cost per active user",
      "numerator_query": {
        "formulas": [
          []
        ],
        "queries": [
          []
        ]
      },
      "org_id": 321813,
      "unit_label": "user",
      "updated_at": "2026-09-01T19:52:08.820536Z",
      "updated_by": "13cc0adf-2595-479e-b448-5051c180dddb"
    },
    "id": "64aecd58-e355-4f07-9c3a-56ff6bda6cd8",
    "type": "unit_cost"
  }
}
```

{% /tab %}

{% /tab %}

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

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

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

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

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

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "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

##### 
                  \## default
# 
 \# Path parameters export unit_cost_id="64aecd58-e355-4f07-9c3a-56ff6bda6cd8" \# Curl command curl -X PUT "https://api.datadoghq.com/api/v2/cost/unit_costs/${unit_cost_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "denominator_query": {
        "formulas": [
          {
            "formula": "denominator"
          }
        ],
        "queries": [
          {
            "data_source": "metrics",
            "name": "denominator",
            "query": "avg:system.cpu.user{*}"
          }
        ],
        "response_format": "timeseries"
      },
      "name": "Cloud cost per active user",
      "numerator_query": {
        "formulas": [
          {
            "formula": "numerator"
          }
        ],
        "queries": [
          {
            "data_source": "cloud_cost",
            "name": "numerator",
            "query": "sum:aws.cost.net.amortized.shared.resources.allocated{*}.rollup(sum, daily)"
          }
        ],
        "response_format": "timeseries"
      },
      "unit_label": "user"
    },
    "id": "64aecd58-e355-4f07-9c3a-56ff6bda6cd8",
    "type": "unit_cost"
  }
}
EOF 
                
{% /tab %}
