> 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/api-reference/more-products-apis/feature-management-and-experimentation.md).

# Feature Flags

Manage feature flags, segments, environments, experiments, and metrics in Harness Feature Management & Experimentation (FME) with the Feature Flags API.

The Feature Flags API manages the feature flags, segments, and experiments in Harness Feature Management & Experimentation (FME). For the classic Harness Feature Flags product, use the [Feature Flags Classic](https://developer.harness.io/api-reference/more-products-apis/feature-flags-classic.md) API instead. For the original Split API, use the [FME Admin API (Legacy Split)](https://developer.harness.io/api-reference/more-products-apis/fme-admin-api.md).

## Request basics

* **API key token**: Send a service account token or personal access token in the `x-api-key` header. Go to [Manage API keys](https://developer.harness.io/harness-platform/use-harness-platform/automation/api/add-and-manage-api-keys) to create one.
* **Account, organization, and project IDs**: This API names them `account_id`, `organization_identifier`, and `project_identifier`. Send all three as query parameters on every request. Go to [Organizations and projects](https://developer.harness.io/harness-platform/use-harness-platform/organizations-and-projects) to find these identifiers.
* **Environment ID**: Endpoints that work on a single environment also take `environment_id`.
* **Base URL**: Send requests to `https://app.harness.io/fme/api`, followed by the endpoint path. Accounts on the US-3 cluster use `https://app3.harness.io/fme/api`.

## Example request

List the feature flags in a project:

```bash
curl "https://app.harness.io/fme/api/v4/feature-flags?account_id=ACCOUNT_ID&organization_identifier=ORG_ID&project_identifier=PROJECT_ID" \
  -H "x-api-key: $HARNESS_API_KEY"
```

Replace `ACCOUNT_ID`, `ORG_ID`, and `PROJECT_ID` with your own values, and set `HARNESS_API_KEY` to your API key token.

## Find an endpoint

Endpoint paths are relative to the base URL.

* **Feature flags**: The flag itself: its name, traffic type, tags, and lifecycle. List flags with `GET /v4/feature-flags`, create one with `POST /v4/feature-flags`, and archive one with `POST /v4/feature-flags/{feature-flag-name}/archive`. Go to [Create a Feature Flag and Target Users](https://developer.harness.io/feature-management-experimentation/new-to-fme/get-started/create-a-feature-flag) to create a feature flag.
* **Feature flag definitions**: A flag's settings in one environment: its treatments, targeting rules, and traffic allocation. Kill, restore, and reallocate act here. Read a flag's definition in an environment with `GET /v4/feature-flag-definitions/{feature-flag-name}`, change it with `PATCH /v4/feature-flag-definitions/{feature-flag-name}`, and kill it with `POST /v4/feature-flag-definitions/{feature-flag-name}/kill`. Go to [Creating, Editing, and Deleting Feature Flags](https://developer.harness.io/feature-management-experimentation/management-and-administration/api-best-practices/feature-flags) to edit flag definitions through the API.
* **Segments and segment definitions**: Named lists of users or accounts you target together. List segments with `GET /v4/segments`, and add keys to a segment in an environment with `POST /v4/segment-definitions/{segment-name}/keys`. Go to [Create a segment](https://developer.harness.io/feature-management-experimentation/use-fme/feature-management/targeting/segments) to create a segment.
* **Environments**: Separate copies of your flag settings, such as staging and production. List environments with `GET /v4/environments` and create one with `POST /v4/environments`. Go to [Environments](https://developer.harness.io/feature-management-experimentation/management-and-administration/environments) to manage environments.
* **Traffic types and event types**: What a flag targets, such as user or account, and the kinds of events you send to measure impact. List them with `GET /v4/traffic-types` and `GET /v4/event-types`. Go to [Traffic Types](https://developer.harness.io/feature-management-experimentation/management-and-administration/traffic-types) to set up traffic types.
* **Experiments and metrics**: Tests that compare treatments, and the measures used to judge them. List experiments with `GET /v4/experiments` and metrics with `GET /v4/metrics`. Go to [Create a Metric](https://developer.harness.io/feature-management-experimentation/new-to-fme/get-started/create-a-metric) to create a metric.
