---
title: "ezgh flags config set"
description: "Replace a flag's targeting in an environment from JSON."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh flags config set

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh flags config set <key> --env <environment> --file config.json [--comment text] [flags]
```

Replace a flag's whole targeting in one environment with a JSON file (- for stdin): enabled, offVariation, targets, rules and defaultServe, as `ezgh flags config get` prints them (other fields are ignored). A file with a version is written only if the config is still at that version: if someone else changed it since you read it, nothing changes (precondition_failed), and you can read it again and reapply your edit. Without a version it replaces whatever is there.

Rules are tried top to bottom, the first match serving; each rule's clauses are ANDed. Clause operators are in, notIn, contains, startsWith, endsWith, lt, lte, gt, gte, semverEq, semverLt, semverGt, segmentMatch and notSegmentMatch (the last two take segment keys and no attribute). A rollout's weights are thousandths of a percent and add up to 100000.

Part of [`ezgh flags config`](/cli/reference/flags-config).

## Examples

```sh
ezgh flags config get new-checkout --env staging > c.json && $EDITOR c.json
ezgh flags config set new-checkout --env staging --file c.json --comment "Add the beta rule"
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--comment` | string |  | why, kept with the version (overrides the file's) |
| `--env` | string |  | the environment's key (required) |
| `--file` | string |  | the config as JSON, or - for stdin (required) |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/flags-config-set/index.mdx
