Create a Feature Flag

Updated 4 months ago by Archana Singh

This topic describes how to create a feature flag in Harness. Feature flags wrap your code and allow you to manage the feature release in a controlled way.

In this topic:

Before You Begin

Visual Summary

Step 1: Create a Project

As a first step, you need to create a project in Harness.

  1. In Harness, click Feature Flags and click Create Project.
  2. In Projects, click Project.
  3. In About the Project, in Name, enter the name for your project.
  4. Select color for your project.
  5. Select the Organization from the list. If you need to create a new organization, see Create a Harness Organization and Projects and Organizations.
  6. Click Save and Continue.
  7. (Optional) In Invite Collaborators, in Invite People to Collaborate, add members to collaborate.
  8. (Optional) Assign a role to the collaborators and click Add. You can select Project Admin, Project Member, or Project Viewer. For more information on the permissions, see Permissions Reference.
  9. Once you're done adding contributors and adding a role, click Save and Continue.
  10. In Which Harness modules would you like to enable for this project?, enable CONTINUOUS Features.

Step 2: Create an Environment

Once you've created a project, you need to create an environment. An environment is the representation of your production or non-production infrastructure. You can configure the targeting rules of your flag in the environment.

  1. In Feature Flags, select the Project that you created. For example, FFDOcs.
  2. In your Project, in Environments, click Create an Environment.
  3. Enter a name for your environment.
  4. Select the environment type and click Create.
    Your environment is listed in Environments.

Step 3: Create an SDK Key

Now you have the environment ready, you need to create an SDK key for your environment. The SDK keys are used in your application's code to authorize your application to connect to the Feature Flag client.

  1. Click on the environment that you created in the previous step.
  2. In Environments, in Settings, click Add Key.
  3. In Create SDK Key, in Name, enter a name for your SDK key.
  4. In Key Type, select the Key Type. You can select Client or Server.

    Client Key Type

    Server Key Type

    The client-side ID is not considered confidential and they are visible all the time.

    Keys are visible right after the creation and redacted once you leave the page. Make sure to copy and store your secret.

    The keys are used to authenticate to client-side SDKs.

    The keys are used to authenticate to server-side SDKs. With this key, server-side SDKs can download the entire flag ruleset for all flags in the environment.

    Server SDKs sync flag rulesets in the background and keep an in-memory cache.


    If your organization needs to rotate the keys, you can choose to add more than one key for the same environment.
    The SDK keys with the secret are created.
  5. Copy and store your secret.

Step 4: Create a Flag Type

Harness Feature Flags support Boolean and Multivariate flag type.

Create a Boolean Flag Type

A Boolean flag typically has two variations true or false. Perform the following steps to create a boolean flag type:

  1. In Feature Flags, click Flag.
  2. Select the Boolean type.
  3. In About the Flag, in Name, enter a name for your boolean flag and click Next.

    When you name a feature flag, Harness automatically generates its identifier. You can edit the Identifier when you are creating the feature flag, but not after it is saved. If you rename the feature flag, the Identifier remains the same. For more information, see Entity Identifier Reference.
    If you need to make the feature flag a permanent flag, select the checkbox This is a permanent flag.
  4. In Variation settings, do the following:
    1. Select the flag type: In Flag Type, select Boolean.
    2. Define the variation: In boolean, you can have only two variations true or false.
      1. Enter a name for your variations. For example, True and False.
    3. Define rules for the flag: Defines which variation you will see by default when the flag is ON or OFF.
      Once you save the variations, a flag is created for the environment with these variations set as ON and OFF.

      For example,

      If the flag is ON, serve the variation True.
      If the flag is OFF, serve the variation False.
  5. Click Save and Close. The feature flag is created. By default, the feature flag is set to OFF.

Once you have created your boolean flag type, optionally you can modify the following settings of your flag:

Create a Multivariate Flag Type

Multivariate flags allow you to serve multiple variations of a feature to different user segments simultaneously. There is no limit to the number of variations that you can add to a multivariate flag, making it useful for complex use cases and to manage two or more variations of a feature. Multivariate flags have multiple settings that allow you to define different variations using, strings, numbers, and JSON.

Perform the following steps to create a multivariate flag type:

  1. In Feature Flags, click Flag.
  2. Select the Multivariate type.
  3. In About the Flag, in Name, enter a name for your multivariate flag and click Next.
    If you need to make the feature flag a permanent flag, select the checkbox This is a permanent flag.
  4. In Variation settings, do the following:
    1. Select the flag type: In Flag Type, select Multivariate and then select the type for your multivariate flag. You can select, STRING, JSON, or NUMBER.
    2. Define the variation: Enter a value and name for your variation. For example, "name":"CF" and name.
    3. Define rules for the flag: Defines which variation you will see by default when the flag is ON or OFF.

      Once you save the variations, a flag is created for the environment with these variations set as ON and OFF.

      For example,

      If the flag is ON, serve the variation name.
      If the flag is OFF, serve the variation email.
Once you have created your multivariate flag type, optionally you can manage targets and modify the variations, rules, and add prerequisites of your flag.

Next Steps


Please Provide Feedback