---
title: Update an environment
description: Updates an environment's name, DD_ENV values, and settings.
breadcrumbs: Docs > API > Update an environment
---

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

# Update an environment

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

Updates an environment's name, DD_ENV values, and settings.

Every request must include `name` and `queries`, even when changing only subject authorization or evaluation data settings.
To preserve the current name and DD_ENV values, get the environment first and include those values in the request.

Omitting `is_production` or `require_feature_flag_approval` resets that setting to `false`.
Include their current values to preserve them. Omitting `observe_full_evaluation_data` preserves its current value. Omitting either subject authorization field preserves its stored value. Set `subject_authorization_oidc_provider_id` to `null` to clear the association while subject authorization is disabled. The following requests return `400 Bad Request`: enabling subject authorization without a provider, an unrecognized `subject_authorization_state` value, a malformed or zero UUID provider ID, or an unregistered provider ID. If the provider registry is unavailable, a new provider ID returns `503 Service Unavailable`. Omitted, cleared, or unchanged provider IDs skip the registry check, including when enabling a retained provider. Saving does not verify provider eligibility or key publication, so a successful save does not mean the environment is ready for assignment requests. Concurrent policy changes return `409 Conflict`; reload the environment and retry.

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/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 for updating an environment.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| attributes   | subject_authorization_oidc_provider_id | uuid     | The ID of a Custom OIDC provider, formatted as a nonzero UUID. If omitted, the stored association is preserved. Set to `null` to clear the association, which is allowed only when the resulting `subject_authorization_state` is `disabled`. A new non-null ID must be registered in the current organization and site, even when subject authorization is disabled. An unregistered ID returns `400 Bad Request`, and an unavailable registry returns `503 Service Unavailable`. Omitted, cleared, and unchanged IDs skip this check, including when you enable a retained provider. An ID that matches the stored ID in a different format, such as different letter case, is treated as unchanged. Saving does not verify provider eligibility or key publication. |
| attributes   | subject_authorization_state            | enum     | Whether assignment requests for this environment require subject authorization. Allowed values are `disabled` and `enabled`. Enabling requires a provider ID formatted as a nonzero UUID. If omitted on create, defaults to `disabled`. If omitted on update, the stored state is preserved. `null` is not accepted. This setting applies only to the current Datadog site and is not copied to other sites. Before you enable it, configure an eligible Custom OIDC provider in the same organization and site, and verify that the provider's keys are published. Assignment requests fail when the required verification configuration is unavailable. Allowed enum values: `disabled`, `enabled`.                                                                  |
| 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   | subject_authorization_oidc_provider_id | uuid      | The associated Custom OIDC provider ID, or `null` when no provider is associated. Disabled environments may retain a provider association.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| attributes   | subject_authorization_state            | enum      | Whether assignment requests for this environment require subject authorization. Allowed values are `disabled` and `enabled`. Enabling requires a provider ID formatted as a nonzero UUID. If omitted on create, defaults to `disabled`. If omitted on update, the stored state is preserved. `null` is not accepted. This setting applies only to the current Datadog site and is not copied to other sites. Before you enable it, configure an eligible Custom OIDC provider in the same organization and site, and verify that the provider's keys are published. Assignment requests fail when the required verification configuration is unavailable. Allowed enum values: `disabled`, `enabled`. |
| 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,
      "subject_authorization_oidc_provider_id": "550e8400-e29b-41d4-a716-446655440003",
      "subject_authorization_state": "disabled",
      "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="409" %}
Conflict

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

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | code                | string   | An application-specific error code.                                             |
| 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 label="Example" %}
```json
{
  "errors": [
    {
      "code": "invalid_request",
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "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 %}
