---
title: 環境の更新
description: 名前や説明などの既存の環境の メタデータを更新します。
breadcrumbs: ドキュメント > API > 環境の更新
---

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

# 環境の更新

## v2 (latest)

| Datadog site      | API endpoint                                                                         |
| ----------------- | ------------------------------------------------------------------------------------ |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v2/feature-flags/environments/{environment_id}     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v2/feature-flags/environments/{environment_id} |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v2/feature-flags/environments/{environment_id} |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v2/feature-flags/environments/{environment_id}      |
| ap1.datadoghq.com | PUT https://api.ap1.datadoghq.com/api/v2/feature-flags/environments/{environment_id} |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v2/feature-flags/environments/{environment_id} |
| uk1.datadoghq.com | PUT https://api.uk1.datadoghq.com/api/v2/feature-flags/environments/{environment_id} |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v2/feature-flags/environments/{environment_id}      |
| us2.ddog-gov.com  | PUT https://api.us2.ddog-gov.com/api/v2/feature-flags/environments/{environment_id}  |

### Overview

名前や説明などの既存の環境の
メタデータを更新します。

This endpoint requires the `feature_flag_environment_config_write` permission.

OAuth apps require the `feature_flag_environment_config_write` authorization [scope](https://docs.datadoghq.com/ja/api/latest/scopes.md#feature-flags) to access this endpoint.

### Arguments

#### Path Parameters

| Field                       | Type   | Description                |
| --------------------------- | ------ | -------------------------- |
| environment_id [*required*] | string | The ID of the environment. |

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field                         | Type     | Description                                                                                                                                                                                                                                                                          |
| ------------ | ----------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|              | data [*required*]             | object   | 環境を更新するためのリクエスト。                                                                                                                                                                                                                                                                     |
| data         | attributes [*required*]       | object   | Attributes for updating an environment.                                                                                                                                                                                                                                              |
| attributes   | is_production                 | boolean  | Indicates whether this is a production environment. If omitted, resets to false. Include the existing value to preserve it.                                                                                                                                                          |
| attributes   | name                          | string   | The name of the environment. Required on every request and unique within the organization. Must contain 1 to 200 ASCII characters, start with a letter or digit, and contain only letters, digits, spaces, underscores, hyphens, and periods.                                        |
| attributes   | observe_full_evaluation_data  | boolean  | Controls whether feature flag evaluation events may include original targeting identifiers and full evaluation context. When true, SDKs may include this data. When false, SDKs hash targeting identifiers and omit evaluation context. If omitted, the existing value is preserved. |
| attributes   | queries                       | [string] | Required list of at least one exact DD_ENV value associated with this environment. Values cannot be used by another environment in the same organization. Wildcards and search expressions are not supported.                                                                        |
| attributes   | require_feature_flag_approval | boolean  | Indicates whether feature flag changes require approval in this environment. If omitted, resets to false. Include the existing value to preserve it.                                                                                                                                 |
| data         | type [*required*]             | enum     | The resource type. Allowed enum values: `environments`.                                                                                                                                                                                                                              |
{% /tab %}

{% tab label="Example" %}
**Update an environment to disable full evaluation data returns "OK" response**

```json
{
  "data": {
    "type": "environments",
    "attributes": {
      "name": "Updated Privacy Example-Feature-Flag",
      "queries": [
        "updated-privacy-example-feature-flag"
      ],
      "observe_full_evaluation_data": false
    }
  }
}
```

**Update an environment to enable full evaluation data returns "OK" response**

```json
{
  "data": {
    "type": "environments",
    "attributes": {
      "name": "Updated Privacy Example-Feature-Flag",
      "queries": [
        "updated-privacy-example-feature-flag"
      ],
      "observe_full_evaluation_data": true
    }
  }
}
```

**Update an environment to preserve disabled full evaluation data when omitted returns "OK" response**

```json
{
  "data": {
    "type": "environments",
    "attributes": {
      "name": "Updated Privacy Example-Feature-Flag",
      "queries": [
        "updated-privacy-example-feature-flag"
      ]
    }
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response containing an environment.

| Parent field | Field                         | Type      | Description                                                                                                          |
| ------------ | ----------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]             | object    | A feature flag environment resource.                                                                                 |
| data         | attributes [*required*]       | object    | Attributes of an environment.                                                                                        |
| attributes   | created_at                    | date-time | The timestamp when the environment was created.                                                                      |
| attributes   | is_production                 | boolean   | Indicates whether this is a production environment.                                                                  |
| attributes   | name [*required*]             | string    | The name of the environment.                                                                                         |
| attributes   | observe_full_evaluation_data  | boolean   | Indicates whether feature flag evaluation events include original targeting identifiers and full evaluation context. |
| attributes   | queries                       | [string]  | List of queries to define the environment scope.                                                                     |
| attributes   | require_feature_flag_approval | boolean   | Indicates whether feature flag changes require approval in this environment.                                         |
| attributes   | updated_at                    | date-time | The timestamp when the environment was last updated.                                                                 |
| data         | id [*required*]               | uuid      | The unique identifier of the environment.                                                                            |
| data         | type [*required*]             | enum      | The resource type. Allowed enum values: `environments`.                                                              |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "created_at": "2023-01-01T00:00:00Z",
      "is_production": false,
      "name": "env-search-term",
      "observe_full_evaluation_data": false,
      "queries": [
        "staging",
        "test"
      ],
      "require_feature_flag_approval": false,
      "updated_at": "2023-01-01T00:00:00Z"
    },
    "id": "550e8400-e29b-41d4-a716-446655440001",
    "type": "environments"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Forbidden

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Path parameters
export environment_id="550e8400-e29b-41d4-a716-446655440001"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/feature-flags/environments/${environment_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "type": "environments",
    "attributes": {
      "name": "Updated Privacy Example-Feature-Flag",
      "queries": [
        "updated-privacy-example-feature-flag"
      ],
      "observe_full_evaluation_data": false
    }
  }
}
EOF
```

```bash
# Path parameters
export environment_id="550e8400-e29b-41d4-a716-446655440001"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/feature-flags/environments/${environment_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "type": "environments",
    "attributes": {
      "name": "Updated Privacy Example-Feature-Flag",
      "queries": [
        "updated-privacy-example-feature-flag"
      ],
      "observe_full_evaluation_data": true
    }
  }
}
EOF
```

```bash
# Path parameters
export environment_id="550e8400-e29b-41d4-a716-446655440001"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/feature-flags/environments/${environment_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "type": "environments",
    "attributes": {
      "name": "Updated Privacy Example-Feature-Flag",
      "queries": [
        "updated-privacy-example-feature-flag"
      ]
    }
  }
}
EOF
```
{% /tab %}
{% /tabs %}
