> 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/feature-flags/use-feature-flags/use-ff/ff-target-management/add-target-groups.md).

# Add & Manage Target Groups

{% hint style="info" %}
**NOTE**

While targets are often users, a target can be anything that can be uniquely identified. For example, a target can be a user, an application, a system, a machine, or any resource uniquely identified by an IP address, email ID, user ID, etc.
{% endhint %}

Target groups are a collection of [targets](/feature-flags/use-feature-flags/use-ff/ff-target-management/add-targets.md) that allow you to serve Feature Flag Variations to a list of users in bulk. You can group targets into a group either by picking individual targets or by defining rules that automatically map targets to a target group. For example, you can add individual targets `joe@harness.io` and `jane@harness.io` to the QA internal users group or you can define a rule that all the emails ending with `@harness.io` are added to the QA internal users group.

You can also do the opposite and exclude specific targets from a target group.

This topic describes how to add a target group to your Environment, add targets to the group, and apply the target group to a Feature Flag.

Watch this video for an introduction to target groups:

{% embed url="<https://www.loom.com/share/99284d3b921045858b93f2e24c6a5335>" %}

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

Make sure you've [created targets to add to the target group](/feature-flags/use-feature-flags/use-ff/ff-target-management/add-targets.md).

### Create a target group <a href="#create-a-target-group" id="create-a-target-group"></a>

To create a target group:

1. In **Feature Flags**, click **Target Management**, then click **Target Groups**.
2. Click **+ New Target Group**.
3. In **Create a Target Group**, enter a Name for your group and click **Create**.
4. (Optional) In **Description**, add a description of the group.

After you have created a target group, you need to add targets to it. You can add targets to a target group by selecting them individually or by setting conditions to add all targets that meet those criteria.

### Add targets from the Target Groups page <a href="#add-targets-from-the-target-groups-page" id="add-targets-from-the-target-groups-page"></a>

You can add individual targets from the Targets page or the Target Groups page.

1. In **Target Management**, in **Target Groups**, select the target group you want to add targets to.

   ![A screenshot of the Target Management page with a target group highlighted](/files/LVaAkIddRgskJHMpgknp)
2. In **Criteria**, click **Edit**.

<figure><img src="/files/P0PE0pR0LdrwKSsfHat5" alt="The edit button next to Criteria."><figcaption></figcaption></figure>

1. From here, you can [**include or exclude specific targets**](#add-or-exclude-specific-targets), or you can set rules to [**add targets based on conditions**](#add-targets-based-on-conditions) you set.

#### Include or exclude specific targets <a href="#include-or-exclude-specific-targets" id="include-or-exclude-specific-targets"></a>

* To add specific targets, in **Include the following**, select the targets.
* To exclude targets, in **Exclude the following**, select the targets.

  <figure><img src="/files/3cbZrFwhPFkD9WqHklkm" alt="A screenshot of targets added to the Target Group Criteria."><figcaption></figcaption></figure>

#### Add targets based on conditions <a href="#add-targets-based-on-conditions" id="add-targets-based-on-conditions"></a>

{% hint style="info" %}
**NOTE**

When you create a target based on Conditions, on the target overview page the group isn't displayed under the **Target Groups** column.
{% endhint %}

In addition to targeting individual users, Harness Feature Flags also allows you to target a group based on the conditions you set. You can add conditions by constructing rules using the following:

* The name or identifier of the target.
* An operator.
* Text that must match the target name or identifier.

The following operators are supported:

|                        |                    |                                                                                                                                                                                      |
| ---------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Operator**           | **Attribute Type** | **Definition**                                                                                                                                                                       |
| **starts with**        | String             | Matches the prefix of a string. If you enter multiple string values, only the first is matched.                                                                                      |
| **ends with**          | String             | Matches the suffix of a string. If you enter multiple string values, only the first is matched.                                                                                      |
| **contains**           | String             | Matches a part of a string. If you enter multiple string values, only the first is matched.                                                                                          |
| **equals**             | Number or string   | Matches the string or number. If you enter multiple string values, only the first is matched.                                                                                        |
| **equals (sensitive)** | Number or string   | Matches the number or string and is case-sensitive. If you enter multiple string values, only the first is matched.For example, the string HELLO is different from the string hello. |
| **in**                 | Number or string   | Acts as an “or” operator, so you can add multiple values at once.                                                                                                                    |

For example, you could set a rule to add all targets whose identifiers end in `@harness.io`.

To add targets based on conditions:

1. In **Target Group Criteria**, click **+ Add Rule**.
2. In the first drop-down menu, select whether the condition applies to the Target Name or Identifier.
3. In the second drop-down menu, select the operator to apply to the Target Name or Identifier.
4. In the search bar, enter the value you want the Target Name or Identifier to match and click the **+** button to add it. The following shows an example of a rule that adds all targets with a Target Identifier ending in harness.io to the target group.

<figure><img src="/files/b3VPOsGtmInLa0SHVBDO" alt="An example of the target group Criteria page with a condition added."><figcaption></figcaption></figure>

5. Click **Save**. Targets that meet the criteria are now included in the target group.

<figure><img src="/files/kFpruu1PGtL6sQwBs3Dj" alt="The Target Groups page with the new condition displayed."><figcaption></figcaption></figure>

When you add targets based on conditions, on the **Target Management:Targets** page, the target group is **not**displayed in the **Target Groups** column.

### Add or exclude targets from target settings <a href="#add-or-exclude-targets-from-target-settings" id="add-or-exclude-targets-from-target-settings"></a>

You can use Target Settings to include or exclude targets from a target group. Complete the following steps to include or exclude targets using the Target Settings:

1. Go to **Target Management > Targets**, and then click the target you want to add to a group.
2. Click **Target Groups**, and then select either or both of the following:

   * **Add to Target Groups** to add a this target to groups
   * **Exclude from Target Groups** to exclude a specific target

     <figure><img src="/files/95UXTkGRTXedKzsGxrB8" alt="A screenshot of a target with the Target Groups tab opened."><figcaption></figcaption></figure>

   You can add or exclude the target to multiple groups at once.
3. Select the group(s) to add or exclude a target to/from, then click **Add to Target Group**, or **Exclude from Target Group**.
4. The targets are now added to, or excluded from, the target groups.

### Targeting using AND rules (beta feature) <a href="#targeting-using-and-rules-beta-feature" id="targeting-using-and-rules-beta-feature"></a>

{% hint style="info" %}
**NOTE**

This beta feature is behind the `FFM_11173_TARGET_GROUP_AND_OPERATOR` feature flag. AND rules won't be available via the UI or work with sdks or the relay proxy unless this flag is enabled on Harness SaaS.

Contact [Harness Support](mailto:support@harness.io) to enable this feature.
{% endhint %}

#### SDK compatibility <a href="#sdk-compatibility" id="sdk-compatibility"></a>

| SDK            | Compatible Versions | Other Config Required?                                                                                                    |
| -------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Golang         | v0.1.24+            |                                                                                                                           |
| .NET           | v1.6.10+            |                                                                                                                           |
| Java           | v1.6.1+             |                                                                                                                           |
| Python         | v1.6.2+             |                                                                                                                           |
| Node.js        | v1.8.2+             |                                                                                                                           |
| Ruby           | v1.3.1+             |                                                                                                                           |
| Erlang         | n/a                 |                                                                                                                           |
| Apex           | n/a                 |                                                                                                                           |
| Javascript     | All                 |                                                                                                                           |
| Android/IOS    | All                 |                                                                                                                           |
| React          | All                 |                                                                                                                           |
| React Native   | All                 |                                                                                                                           |
| Flutter        | All                 |                                                                                                                           |
| Xamarin        | All                 |                                                                                                                           |
| Relay Proxy V2 | 2.0.1+              | Enable and-rules flag in your relay proxy - see [here](https://github.com/harness/ff-proxy/blob/v2/docs/configuration.md) |

#### Creating AND rules <a href="#creating-and-rules" id="creating-and-rules"></a>

<figure><img src="/files/lwkL7oIKjzNljz8lLRg0" alt="A screenshot showing target group AND rules"><figcaption></figcaption></figure>

1. Click into the target group you want to add rules for
2. Click ‘edit’ beside criteria to open the side panel to add rules
3. Click ‘Add rule’ to add a new OR rule
4. Click the + sign beside an existing rule to add an AND condition to a rule

#### Behavior with compatible SDKs <a href="#behavior-with-compatible-sdks" id="behavior-with-compatible-sdks"></a>

The AND rule will be used to evaluate the flag i.e. the flag in the example will only be true if (Identifier equals Harness AND loc equals US) OR (Identifier equals Test\_Acc)

#### Behavior with older SDKs <a href="#behavior-with-older-sdks" id="behavior-with-older-sdks"></a>

Older SDKs don’t have the logic to handle the AND section of each rule. They will only evaluate the first clause of each rule i.e. for the above example older non compatible SDK’s will evaluate the rule as (Identifier equals Harness) OR (Identifier equals Test\_Acc). The same behaviour applies when the `FFM_11173_TARGET_GROUP_AND_OPERATOR` flag is disabled.

#### Backwards/forwards compatibility <a href="#backwardsforwards-compatibility" id="backwardsforwards-compatibility"></a>

These AND rules are backwards and forwards compatible with existing target group rules. When the `FFM_11173_TARGET_GROUP_AND_OPERATOR` flag is enabled all your existing OR rules will still exist, you’ll just now have the ability to add the additional AND rules to them via the + symbol in the updated UI.

If for any reason you need the flag to be disabled in future all newly created rules will still exist, however they will only display the first clause of each rule i.e. if you rolled back to the old UI/functionality you would only see 2 rules in the UI for this example, Identifier equals Harness OR Identifier equals Test\_Acc, the AND portions would be dropped.

### Next step <a href="#next-step" id="next-step"></a>

After you have added the targets and target groups, you can then [use them on your Feature Flags.](/feature-flags/use-feature-flags/use-ff/ff-target-management/targeting-users-with-flags.md)
