> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/harness-cli-commands/fme.md).

# Feature Management & Experimentation

Use the Harness CLI to manage Feature Management & Experimentation (FME) feature flags, segments, metrics, and their per-environment definitions.

Use the Harness CLI to manage Feature Management & Experimentation (FME) feature flags, segments, metrics, and their per-environment definitions.

Harness Feature Management & Experimentation (FME) lets you control feature rollout and measure impact. The CLI manages feature flags, segments, metrics, and their per-environment definitions from your terminal or from a script.

This page covers all FME resources and actions available in the CLI.

## What you will learn in this topic

By the end of this page, you will know how to:

* Find the FME resources and actions the CLI supports.
* List FME environments and find the environment ID that `--env` requires.
* Create segments and segment definitions.
* Manage feature flag definitions and run lifecycle actions such as kill and restore.
* List FME change requests.

## Before you begin

* **Harness CLI installed and authenticated:** Go to [Install and upgrade](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/install-and-upgrade.md) to install the CLI, and [Authenticate](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/authenticate-the-harness-cli.md) to set up credentials.
* **FME module installed:** Run `harness list module` and confirm that `fme` shows `yes` in the **Installed** column.
* **FME access:** Your account must have access to FME and permission to manage the resources you change.

### Resources and actions

Go to [Supported resources and actions](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/supported-resources-and-actions.md#feature-management-and-experimentation) to view the full resource matrix and the meaning of the `S` symbol.

| Resource                                                                                                                 | Alias     | Actions                                     |
| ------------------------------------------------------------------------------------------------------------------------ | --------- | ------------------------------------------- |
| `feature_flag`                                                                                                           | `ff`      | `list`, `get`, `create`, `update`, `delete` |
| `feature_flag:definition`                                                                                                |           | `list`, `get`, `create`, `update`, `delete` |
| `feature_flag:archive`, `feature_flag:unarchive`, `feature_flag:kill`, `feature_flag:restore`, `feature_flag:reallocate` |           | `execute`                                   |
| `fme_environment`                                                                                                        | `fme_env` | `list`, `get`, `create`, `update`, `delete` |
| `segment`                                                                                                                | `seg`     | `list`, `get`, `create`, `update`, `delete` |
| `segment:definition`                                                                                                     |           | `list`, `get`, `create`, `update`, `delete` |
| `metric`                                                                                                                 |           | `list`, `get`, `create`, `update`, `delete` |
| `event_type`                                                                                                             |           | `list`, `get`                               |
| `traffic_type`                                                                                                           |           | `list`                                      |
| `rollout_status`                                                                                                         |           | `list`                                      |
| `change_request`                                                                                                         |           | `list`                                      |

{% hint style="info" %}
**FME environments are not CD environments**

`fme_environment` is separate from the Continuous Delivery `environment` resource. Use `fme_environment` for any FME command.
{% endhint %}

### Environments

Go to [Environments](https://developer.harness.io/feature-management-experimentation/management-and-administration/environments) to learn how FME environments work and how to create and manage them.

Commands that act on a per-environment definition take `--env`. This flag takes the environment ID, not the environment name. List your FME environments to find the ID.

```sh
harness list fme_environment
harness get fme_environment <environment_id>
```

### Feature flags

Go to [Create a feature flag](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/setup/create-a-feature-flag) to learn about feature flags, treatments, and traffic types in FME.

A feature flag is the flag itself. Its targeting rules for one environment live in a separate resource, `feature_flag:definition`.

```sh
harness list feature_flag
harness get feature_flag <flag_name>
harness list ff
```

`create` and `update` on `feature_flag` support `--set` field mutations. The FME module adds custom field types for owners, tags, and flag sets.

### Flag definitions

Go to [Define feature flag treatments and targeting](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/setup/define-feature-flag-treatments-and-targeting) to learn about treatments, targeting rules, and default rules. Go to [Create a rollout plan](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/setup/create-a-rollout-plan) to learn about rollout status.

A flag definition holds the targeting rules for one flag in one environment.

```sh
harness list feature_flag:definition --env <environment_id>
harness get feature_flag:definition <flag_name> --env <environment_id>
```

`create feature_flag:definition` takes its body from a file passed with `-f`. It does not support `--set`.

### Flag lifecycle actions

Go to [Use the kill switch](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/manage-feature-flags/use-the-kill-switch) and [Archive a feature flag](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/manage-feature-flags/archive-a-feature-flag) to learn what these actions do to a flag in FME.

These resources support only the `execute` action:

* **`feature_flag:archive` and `feature_flag:unarchive`:** Archive a flag or bring it back.
* **`feature_flag:kill` and `feature_flag:restore`:** Kill a flag to serve its default treatment, or restore it.
* **`feature_flag:reallocate`:** Reallocate traffic for a flag.

Run `harness execute <resource> --help` to view the exact arguments and flags for each action.

### Segments

Go to [Create a segment](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/targeting/segments) to learn about segment types and how to target segments from a flag.

A segment is a reusable group of users that you can target from any flag. Creating a segment requires `--segment-type`, which accepts `STANDARD`, `LARGE`, or `RULE_BASED`.

```sh
harness create segment my-seg --segment-type STANDARD --traffic-type user
harness list segment
```

To add a segment to an environment, create a segment definition. `create segment:definition` takes `--description` and does not support `--set`.

```sh
harness create segment:definition my-seg --env <environment_id> --description "initial"
harness list segment:definition --env <environment_id>
```

### Metrics, event types, and traffic types

Go to [Metrics](https://developer.harness.io/feature-management-experimentation/use-fme/release-monitoring/metrics), [Events](https://developer.harness.io/feature-management-experimentation/use-fme/release-monitoring/events), and [Traffic types](https://developer.harness.io/feature-management-experimentation/management-and-administration/traffic-types) to learn the definitions behind these resources.

Metrics measure the impact of a flag. `create` and `update` on `metric` support `--set`, with a custom field type for metric references.

```sh
harness list metric
harness list event_type
harness list traffic_type
harness list rollout_status
```

### Change requests

Go to [Approval flows](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/setup/approval-flows) to learn how FME change requests gate changes to flags and segments.

List FME change requests from the CLI. This resource requires CLI v3.10.0 or later.

```sh
harness list change_request
```

Run `harness list change_request --help` to view the filters and flags available in your CLI version.

## Next steps

* Go to [Supported resources and actions](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/supported-resources-and-actions.md#feature-management-and-experimentation) to view the full FME resource matrix.
* Go to [Global flags and output](https://developer.harness.io/harness-platform/3.0/harness-cli/cli/global-flags-and-output-formats.md) to learn about output formats and pagination.
* Go to [Feature Management & Experimentation](https://developer.harness.io/feature-management-experimentation) to learn more about FME.
