# Manage organization feature flags

> Add, update, or delete feature flags for an organization.

Feature flags toggle Self-Hosted Deployment capabilities such as a preview of UI functionality or a temporary workaround for a customer-specific issue. They're scoped to one organization at a time: a flag set in organization A has no effect on organization B.

> **Note:**
>
> A typical Self-Hosted Deployment deployment contains only one organization, so there is only one possible scope for the flags.

The upc-cli tool exposes the four operations needed to administer feature flags end-to-end:

| Operation      | Description                                                        |
| -------------- | ------------------------------------------------------------------ |
| `flags list`   | Shows all feature flags currently set for an organization.         |
| `flags add`    | Creates a new feature flag and sets its value.                     |
| `flags update` | Changes the value of an existing feature flag.                     |
| `flags delete` | Removes a feature flag entirely (reverts to the platform default). |

## Before you start

To work with feature flags, you need:

* The ID of the target organization (a UUID-formatted string, like `00000000-0000-0000-0000-000000000000`). Find it with the [`orgs list` command](/cloud/virtual-private-cloud/admin/upc-cli/run-upc-cli.md#example---list-organizations) or in the organization properties in the Dashboard (go to **Administration** > **Settings**).
* No explicit authentication is required - the tool runs in-cluster and calls relevant APIs directly. Anyone who can execute `kubectl run` in the solution namespace can change feature flags; treat `kubectl` access as the only access boundary.
* The commands on this page work in a Unix-based shell (Linux, MacOS, WSL on Windows, Git Bash on Windows). If you need to run them in a Windows shell:
  * Use PowerShell 7.3 or newer, not Windows PowerShell 5.x.
  * Replace line continuation characters (`\`) with backticks (`` ` ``).

## Use cases

These examples cover:

* Listing current feature flags.
* Enabling and disabling a feature flag.
* Changing the value of an existing feature flag.
* Removing a feature flag.
* Previewing a flag change without applying it.

### List the current feature flags

This command lists all feature flags set for an organization.

Replace the `<organizationId>` string with the ID of the target organization.

```shell
kubectl run -it upc-cli --rm \
  --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:latest \
  -n asset-solutions \
  --restart=Never \
  --overrides='{"spec":{"imagePullSecrets":[{"name":"acr-unity-registry"}]}}' \
  -- \
  --fqdn http://mini-usf:8080 \
  --path-prefix="" \
  --no-auth \
  flags list --organization-id <organizationId>
```

The response is a JSON array of feature flag objects. Each entry includes:

* The feature name.
* The flag's boolean value.
* The flag's internal ID for the particular organization.
* When the flag was created and last updated.

Only feature flags that have been explicitly set for the organization appear in the list. Platform defaults aren't listed.

### Enable or disable a feature flag

To turn on a flag for the first time run the following command:

* Replace the `<organizationId>` string with the ID of the target organization.
* Replace the `<flag-name>` string with the feature flag name.
* Accepted literals for `--value` (case-insensitive):
  * For enabling a flag: `true`, `yes`, `on`, and `1`
  * For disabling a flag: `false`, `no`, `off`, and `0`

    Any other input is rejected before an HTTP call is made.

```shell
kubectl run -it upc-cli --rm \
  --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:latest \
  -n asset-solutions \
  --restart=Never \
  --overrides='{"spec":{"imagePullSecrets":[{"name":"acr-unity-registry"}]}}' \
  -- \
  --fqdn http://mini-usf:8080 \
  --path-prefix="" \
  --no-auth \
  flags add --organization-id <organizationId> --name <flag-name> --value true
```

### Change a flag's value

To change the value of a feature flag that's already set for an organization, (in this example, to `false`):

```shell
kubectl run -it upc-cli --rm \
  --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:latest \
  -n asset-solutions \
  --restart=Never \
  --overrides='{"spec":{"imagePullSecrets":[{"name":"acr-unity-registry"}]}}' \
  -- \
  --fqdn http://mini-usf:8080 \
  --path-prefix="" \
  --no-auth \
  flags update --organization-id <organizationId> --name <flag-name> --value false
```

The distinction between `add` and `update` matters:

* `add` fails (HTTP 409) if a flag with the same name already exists for the organization. Use it for first-time enablement.
* `update` looks up the existing flag by name and changes its value. It fails if the flag is not yet set for the organization.

If you don't know whether the flag is already set, run `flags list` first.

### Remove a feature flag

Removing a flag reverts the organization to the platform's default behavior for that feature. This is different from setting the flag to `false`; a removed flag is no longer overridden at the organization level at all.

Use the following command to remove a feature flag for an organization:

* Replace the `<organizationId>` string with the ID of the target organization.
* Replace the `<flag-name>` string with the feature flag name.

```shell
kubectl run -it upc-cli --rm \
  --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:latest \
  -n asset-solutions \
  --restart=Never \
  --overrides='{"spec":{"imagePullSecrets":[{"name":"acr-unity-registry"}]}}' \
  -- \
  --fqdn http://mini-usf:8080 \
  --path-prefix="" \
  --no-auth \
  flags delete --organization-id <organizationId> --name <flag-name>
```

## Preview a change without applying it

To run a preview, add the `--dry-run` parameter before the `flags` command. The upc-cli tool prints the HTTP method, URL, and request body it would have sent, and exits without contacting the API.

For example, to preview adding a new flag:

```shell
kubectl run -it upc-cli --rm \
  --image=uccmpprivatecloud.azurecr.io/docker/upc-cli:latest \
  -n asset-solutions \
  --restart=Never \
  --overrides='{"spec":{"imagePullSecrets":[{"name":"acr-unity-registry"}]}}' \
  -- \
  --fqdn http://mini-usf:8080 \
  --path-prefix="" \
  --no-auth \
  --dry-run \
  flags add --organization-id <organizationId> --name <flag-name> --value true
```
