For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/api/latest/cloud-cost-management/upsert-a-cloud-cost-management-tag-description.md. A documentation index is available at /llms.txt.

Upsert a Cloud Cost Management tag description

PUT https://api.ap1.datadoghq.com/api/v2/cost/tag_descriptions/{tag_key}https://api.ap2.datadoghq.com/api/v2/cost/tag_descriptions/{tag_key}https://api.datadoghq.eu/api/v2/cost/tag_descriptions/{tag_key}https://api.ddog-gov.com/api/v2/cost/tag_descriptions/{tag_key}https://api.us2.ddog-gov.com/api/v2/cost/tag_descriptions/{tag_key}https://api.uk1.datadoghq.com/api/v2/cost/tag_descriptions/{tag_key}https://api.datadoghq.com/api/v2/cost/tag_descriptions/{tag_key}https://api.us3.datadoghq.com/api/v2/cost/tag_descriptions/{tag_key}https://api.us5.datadoghq.com/api/v2/cost/tag_descriptions/{tag_key}

Overview

Create or update a Cloud Cost Management tag key description. The new description and optional cloud scoping are supplied in the request body. Omit cloud to set a cross-cloud default for the tag key. This endpoint requires the cloud_cost_management_write permission.

OAuth apps require the cloud_cost_management_write authorization scope to access this endpoint.

Arguments

Path Parameters

Name

Type

Description

tag_key [required]

string

The tag key whose description is being upserted.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Resource envelope carrying the tag key description being upserted. The id is informational; the authoritative tag key is taken from the URL path.

attributes [required]

object

Mutable attributes set when creating or updating a Cloud Cost Management tag key description.

cloud

string

Cloud provider this description applies to (for example, aws). Omit to set the cross-cloud default for the tag key.

description [required]

string

The human-readable description for the tag key.

id

string

Identifier of the tag key the description applies to. Matches the tag_key path parameter.

type [required]

enum

Type of the Cloud Cost Management tag description resource. Allowed enum values: cost_tag_description

default: cost_tag_description

{
  "data": {
    "attributes": {
      "cloud": "aws",
      "description": "AWS account that owns this cost."
    },
    "id": "account_id",
    "type": "cost_tag_description"
  }
}

Response

No Content

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

                  ## default
# 

# Path parameters
export tag_key="CHANGE_ME"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/cost/tag_descriptions/${tag_key}" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DD_BEARER_TOKEN}" \ -d @- << EOF { "data": { "attributes": { "cloud": "aws", "description": "AWS account that owns this cost." }, "id": "account_id", "type": "cost_tag_description" } } EOF
"""
Upsert a Cloud Cost Management tag description returns "No Content" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.cloud_cost_management_api import CloudCostManagementApi
from datadog_api_client.v2.model.cost_tag_description_type import CostTagDescriptionType
from datadog_api_client.v2.model.cost_tag_description_upsert_request import CostTagDescriptionUpsertRequest
from datadog_api_client.v2.model.cost_tag_description_upsert_request_data import CostTagDescriptionUpsertRequestData
from datadog_api_client.v2.model.cost_tag_description_upsert_request_data_attributes import (
    CostTagDescriptionUpsertRequestDataAttributes,
)

body = CostTagDescriptionUpsertRequest(
    data=CostTagDescriptionUpsertRequestData(
        attributes=CostTagDescriptionUpsertRequestDataAttributes(
            cloud="aws",
            description="AWS account that owns this cost.",
        ),
        id="account_id",
        type=CostTagDescriptionType.COST_TAG_DESCRIPTION,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = CloudCostManagementApi(api_client)
    api_instance.upsert_cost_tag_description_by_key(tag_key="tag_key", body=body)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
# Upsert a Cloud Cost Management tag description returns "No Content" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new

body = DatadogAPIClient::V2::CostTagDescriptionUpsertRequest.new({
  data: DatadogAPIClient::V2::CostTagDescriptionUpsertRequestData.new({
    attributes: DatadogAPIClient::V2::CostTagDescriptionUpsertRequestDataAttributes.new({
      cloud: "aws",
      description: "AWS account that owns this cost.",
    }),
    id: "account_id",
    type: DatadogAPIClient::V2::CostTagDescriptionType::COST_TAG_DESCRIPTION,
  }),
})
api_instance.upsert_cost_tag_description_by_key("tag_key", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
// Upsert a Cloud Cost Management tag description returns "No Content" response

package main

import (
	"context"
	"fmt"
	"os"

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

func main() {
	body := datadogV2.CostTagDescriptionUpsertRequest{
		Data: datadogV2.CostTagDescriptionUpsertRequestData{
			Attributes: datadogV2.CostTagDescriptionUpsertRequestDataAttributes{
				Cloud:       datadog.PtrString("aws"),
				Description: "AWS account that owns this cost.",
			},
			Id:   datadog.PtrString("account_id"),
			Type: datadogV2.COSTTAGDESCRIPTIONTYPE_COST_TAG_DESCRIPTION,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewCloudCostManagementApi(apiClient)
	r, err := api.UpsertCostTagDescriptionByKey(ctx, "tag_key", body)

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

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
// Upsert a Cloud Cost Management tag description returns "No Content" 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.CostTagDescriptionType;
import com.datadog.api.client.v2.model.CostTagDescriptionUpsertRequest;
import com.datadog.api.client.v2.model.CostTagDescriptionUpsertRequestData;
import com.datadog.api.client.v2.model.CostTagDescriptionUpsertRequestDataAttributes;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    CloudCostManagementApi apiInstance = new CloudCostManagementApi(defaultClient);

    CostTagDescriptionUpsertRequest body =
        new CostTagDescriptionUpsertRequest()
            .data(
                new CostTagDescriptionUpsertRequestData()
                    .attributes(
                        new CostTagDescriptionUpsertRequestDataAttributes()
                            .cloud("aws")
                            .description("AWS account that owns this cost."))
                    .id("account_id")
                    .type(CostTagDescriptionType.COST_TAG_DESCRIPTION));

    try {
      apiInstance.upsertCostTagDescriptionByKey("tag_key", body);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling CloudCostManagementApi#upsertCostTagDescriptionByKey");
      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 and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
// Upsert a Cloud Cost Management tag description returns "No Content" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
use datadog_api_client::datadogV2::model::CostTagDescriptionType;
use datadog_api_client::datadogV2::model::CostTagDescriptionUpsertRequest;
use datadog_api_client::datadogV2::model::CostTagDescriptionUpsertRequestData;
use datadog_api_client::datadogV2::model::CostTagDescriptionUpsertRequestDataAttributes;

#[tokio::main]
async fn main() {
    let body = CostTagDescriptionUpsertRequest::new(
        CostTagDescriptionUpsertRequestData::new(
            CostTagDescriptionUpsertRequestDataAttributes::new(
                "AWS account that owns this cost.".to_string(),
            )
            .cloud("aws".to_string()),
            CostTagDescriptionType::COST_TAG_DESCRIPTION,
        )
        .id("account_id".to_string()),
    );
    let configuration = datadog::Configuration::new();
    let api = CloudCostManagementAPI::with_config(configuration);
    let resp = api
        .upsert_cost_tag_description_by_key("tag_key".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Upsert a Cloud Cost Management tag description returns "No Content" response
 */

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

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.CloudCostManagementApi(configuration);

const params: v2.CloudCostManagementApiUpsertCostTagDescriptionByKeyRequest = {
  body: {
    data: {
      attributes: {
        cloud: "aws",
        description: "AWS account that owns this cost.",
      },
      id: "account_id",
      type: "cost_tag_description",
    },
  },
  tagKey: "tag_key",
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"