---
title: Create Google Cloud Usage Cost config
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Cloud Cost Management
---

# Create Google Cloud Usage Cost config{% #create-google-cloud-usage-cost-config %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                 |
| ----------------- | ------------------------------------------------------------ |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/cost/gcp_uc_config |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/cost/gcp_uc_config |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/cost/gcp_uc_config      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/cost/gcp_uc_config      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/cost/gcp_uc_config  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/cost/gcp_uc_config     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/cost/gcp_uc_config |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/cost/gcp_uc_config |

### Overview

Create a Cloud Cost Management account for an Google Cloud Usage Cost config. This endpoint requires the `cloud_cost_management_write` permission.

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



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                                 | Type   | Description                                                                                            |
| ------------ | ------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------ |
|              | data [*required*]                | object | Google Cloud Usage Cost config post data.                                                              |
| data         | attributes                            | object | Attributes for Google Cloud Usage Cost config post request.                                            |
| attributes   | billing_account_id [*required*]  | string | The Google Cloud account ID.                                                                           |
| attributes   | bucket_name [*required*]         | string | The Google Cloud bucket name used to store the Usage Cost export.                                      |
| attributes   | export_dataset_name [*required*] | string | The export dataset name used for the Google Cloud Usage Cost report.                                   |
| attributes   | export_prefix                         | string | The export prefix used for the Google Cloud Usage Cost report.                                         |
| attributes   | export_project_name [*required*] | string | The name of the Google Cloud Usage Cost report.                                                        |
| attributes   | service_account [*required*]     | string | The unique Google Cloud service account email.                                                         |
| data         | type [*required*]                | enum   | Type of Google Cloud Usage Cost config post request. Allowed enum values: `gcp_uc_config_post_request` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "billing_account_id": "123456_A123BC_12AB34",
      "bucket_name": "dd-cost-bucket",
      "export_dataset_name": "billing",
      "export_prefix": "datadog_cloud_cost_usage_export",
      "export_project_name": "dd-cloud-cost-report",
      "service_account": "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com"
    },
    "type": "gcp_uc_config_post_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response of Google Cloud Usage Cost config.

| Parent field | Field                                 | Type     | Description                                                                  |
| ------------ | ------------------------------------- | -------- | ---------------------------------------------------------------------------- |
|              | data                                  | object   | Google Cloud Usage Cost config.                                              |
| data         | attributes [*required*]          | object   | Attributes for a Google Cloud Usage Cost config.                             |
| attributes   | account_id [*required*]          | string   | The Google Cloud account ID.                                                 |
| attributes   | bucket_name [*required*]         | string   | The Google Cloud bucket name used to store the Usage Cost export.            |
| attributes   | created_at                            | string   | The timestamp when the Google Cloud Usage Cost config was created.           |
| attributes   | dataset [*required*]             | string   | The export dataset name used for the Google Cloud Usage Cost Report.         |
| attributes   | error_messages                        | [string] | The error messages for the Google Cloud Usage Cost config.                   |
| attributes   | export_prefix [*required*]       | string   | The export prefix used for the Google Cloud Usage Cost Report.               |
| attributes   | export_project_name [*required*] | string   | The name of the Google Cloud Usage Cost Report.                              |
| attributes   | months                                | int32    | **DEPRECATED**: The number of months the report has been backfilled.         |
| attributes   | project_id                            | string   | The `project_id` of the Google Cloud Usage Cost report.                      |
| attributes   | service_account [*required*]     | string   | The unique Google Cloud service account email.                               |
| attributes   | status [*required*]              | string   | The status of the Google Cloud Usage Cost config.                            |
| attributes   | status_updated_at                     | string   | The timestamp when the Google Cloud Usage Cost config status was updated.    |
| attributes   | updated_at                            | string   | The timestamp when the Google Cloud Usage Cost config status was updated.    |
| data         | id                                    | string   | The ID of the Google Cloud Usage Cost config.                                |
| data         | type [*required*]                | enum     | Type of Google Cloud Usage Cost config. Allowed enum values: `gcp_uc_config` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "account_id": "123456_A123BC_12AB34",
      "bucket_name": "dd-cost-bucket",
      "created_at": "string",
      "dataset": "billing",
      "error_messages": [],
      "export_prefix": "datadog_cloud_cost_usage_export",
      "export_project_name": "dd-cloud-cost-report",
      "months": "integer",
      "project_id": "my-project-123",
      "service_account": "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com",
      "status": "active",
      "status_updated_at": "string",
      "updated_at": "string"
    },
    "id": "string",
    "type": "gcp_uc_config"
  }
}
```

{% /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="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
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/cost/gcp_uc_config" \
-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": {
      "billing_account_id": "123456_A123BC_12AB34",
      "bucket_name": "dd-cost-bucket",
      "export_dataset_name": "billing",
      "export_prefix": "datadog_cloud_cost_usage_export",
      "export_project_name": "dd-cloud-cost-report",
      "service_account": "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com"
    },
    "type": "gcp_uc_config_post_request"
  }
}
EOF 
                        
##### 

```go
// Create Google Cloud Usage Cost config 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() {
	body := datadogV2.GCPUsageCostConfigPostRequest{
		Data: datadogV2.GCPUsageCostConfigPostData{
			Attributes: &datadogV2.GCPUsageCostConfigPostRequestAttributes{
				BillingAccountId:  "123456_A123BC_12AB34",
				BucketName:        "dd-cost-bucket",
				ExportDatasetName: "billing",
				ExportPrefix:      datadog.PtrString("datadog_cloud_cost_usage_export"),
				ExportProjectName: "dd-cloud-cost-report",
				ServiceAccount:    "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com",
			},
			Type: datadogV2.GCPUSAGECOSTCONFIGPOSTREQUESTTYPE_GCP_USAGE_COST_CONFIG_POST_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewCloudCostManagementApi(apiClient)
	resp, r, err := api.CreateCostGCPUsageCostConfig(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `CloudCostManagementApi.CreateCostGCPUsageCostConfig`:\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
// Create Google Cloud Usage Cost config 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.GCPUsageCostConfigPostData;
import com.datadog.api.client.v2.model.GCPUsageCostConfigPostRequest;
import com.datadog.api.client.v2.model.GCPUsageCostConfigPostRequestAttributes;
import com.datadog.api.client.v2.model.GCPUsageCostConfigPostRequestType;
import com.datadog.api.client.v2.model.GCPUsageCostConfigResponse;

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

    GCPUsageCostConfigPostRequest body =
        new GCPUsageCostConfigPostRequest()
            .data(
                new GCPUsageCostConfigPostData()
                    .attributes(
                        new GCPUsageCostConfigPostRequestAttributes()
                            .billingAccountId("123456_A123BC_12AB34")
                            .bucketName("dd-cost-bucket")
                            .exportDatasetName("billing")
                            .exportPrefix("datadog_cloud_cost_usage_export")
                            .exportProjectName("dd-cloud-cost-report")
                            .serviceAccount(
                                "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com"))
                    .type(GCPUsageCostConfigPostRequestType.GCP_USAGE_COST_CONFIG_POST_REQUEST));

    try {
      GCPUsageCostConfigResponse result = apiInstance.createCostGCPUsageCostConfig(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling CloudCostManagementApi#createCostGCPUsageCostConfig");
      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"
##### 

```python
"""
Create Google Cloud Usage Cost config returns "OK" response
"""

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.gcp_usage_cost_config_post_data import GCPUsageCostConfigPostData
from datadog_api_client.v2.model.gcp_usage_cost_config_post_request import GCPUsageCostConfigPostRequest
from datadog_api_client.v2.model.gcp_usage_cost_config_post_request_attributes import (
    GCPUsageCostConfigPostRequestAttributes,
)
from datadog_api_client.v2.model.gcp_usage_cost_config_post_request_type import GCPUsageCostConfigPostRequestType

body = GCPUsageCostConfigPostRequest(
    data=GCPUsageCostConfigPostData(
        attributes=GCPUsageCostConfigPostRequestAttributes(
            billing_account_id="123456_A123BC_12AB34",
            bucket_name="dd-cost-bucket",
            export_dataset_name="billing",
            export_prefix="datadog_cloud_cost_usage_export",
            export_project_name="dd-cloud-cost-report",
            service_account="dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com",
        ),
        type=GCPUsageCostConfigPostRequestType.GCP_USAGE_COST_CONFIG_POST_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = CloudCostManagementApi(api_client)
    response = api_instance.create_cost_gcp_usage_cost_config(body=body)

    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
# Create Google Cloud Usage Cost config returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::CloudCostManagementAPI.new

body = DatadogAPIClient::V2::GCPUsageCostConfigPostRequest.new({
  data: DatadogAPIClient::V2::GCPUsageCostConfigPostData.new({
    attributes: DatadogAPIClient::V2::GCPUsageCostConfigPostRequestAttributes.new({
      billing_account_id: "123456_A123BC_12AB34",
      bucket_name: "dd-cost-bucket",
      export_dataset_name: "billing",
      export_prefix: "datadog_cloud_cost_usage_export",
      export_project_name: "dd-cloud-cost-report",
      service_account: "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com",
    }),
    type: DatadogAPIClient::V2::GCPUsageCostConfigPostRequestType::GCP_USAGE_COST_CONFIG_POST_REQUEST,
  }),
})
p api_instance.create_cost_gcp_usage_cost_config(body)
```

#### 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"
##### 

```rust
// Create Google Cloud Usage Cost config returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_cloud_cost_management::CloudCostManagementAPI;
use datadog_api_client::datadogV2::model::GCPUsageCostConfigPostData;
use datadog_api_client::datadogV2::model::GCPUsageCostConfigPostRequest;
use datadog_api_client::datadogV2::model::GCPUsageCostConfigPostRequestAttributes;
use datadog_api_client::datadogV2::model::GCPUsageCostConfigPostRequestType;

#[tokio::main]
async fn main() {
    let body = GCPUsageCostConfigPostRequest::new(
        GCPUsageCostConfigPostData::new(
            GCPUsageCostConfigPostRequestType::GCP_USAGE_COST_CONFIG_POST_REQUEST,
        )
        .attributes(
            GCPUsageCostConfigPostRequestAttributes::new(
                "123456_A123BC_12AB34".to_string(),
                "dd-cost-bucket".to_string(),
                "billing".to_string(),
                "dd-cloud-cost-report".to_string(),
                "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com".to_string(),
            )
            .export_prefix("datadog_cloud_cost_usage_export".to_string()),
        ),
    );
    let configuration = datadog::Configuration::new();
    let api = CloudCostManagementAPI::with_config(configuration);
    let resp = api.create_cost_gcp_usage_cost_config(body).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
/**
 * Create Google Cloud Usage Cost config returns "OK" response
 */

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

const configuration = client.createConfiguration();
const apiInstance = new v2.CloudCostManagementApi(configuration);

const params: v2.CloudCostManagementApiCreateCostGCPUsageCostConfigRequest = {
  body: {
    data: {
      attributes: {
        billingAccountId: "123456_A123BC_12AB34",
        bucketName: "dd-cost-bucket",
        exportDatasetName: "billing",
        exportPrefix: "datadog_cloud_cost_usage_export",
        exportProjectName: "dd-cloud-cost-report",
        serviceAccount:
          "dd-ccm-gcp-integration@my-environment.iam.gserviceaccount.com",
      },
      type: "gcp_uc_config_post_request",
    },
  },
};

apiInstance
  .createCostGCPUsageCostConfig(params)
  .then((data: v2.GCPUsageCostConfigResponse) => {
    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 %}
