# Adaptive Groups

With Adaptive Groups, you can automatically segment subscribers based on predefined criteria. Once configured, these groups auto-populate with subscribers who meet the defined conditions, without manual intervention. This ongoing audience segmentation enables targeted messaging for smarter, data-driven campaigns.

This page explains how to create and configure Adaptive Groups using the Mobile Text Alerts API. [Click here](https://mobile-text-alerts.deskpro.com/kb/articles/adaptive-groups) for more details about using Adaptive Groups in the platform dashboard.

## Manage Adaptive Groups with the API

Adaptive Groups use the same API endpoints as standard groups for all actions, but they use additional request fields for Adaptive Group settings.

### Create an Adaptive Group

Adaptive Groups are created using the same `POST` [`/groups` endpoint](https://developers.mobile-text-alerts.com/tutorials/manage-subscribers/group-subscribers/..#create-a-new-group) used for standard groups. A group will be stored as an Adaptive Group when the `settings` field is included in the request body.

`settings` **object definition:**

```
interface IGroupSettings {
match: 'AND' | 'OR';
conditions: IGroupCondition[];
}
```

`match: 'AND' | 'OR'` *required* - Determines which `conditions` (detailed below) must be met for a subscriber to be added to a group:

* `AND` - A subscriber needs to meet *all* conditions.
* `OR` - A subscriber needs to meet *any* condition.

In the platform dashboard, this is shown as "All conditions" (`AND`) and "Any condition" (`OR`) when creating or editing an Adaptive Group.

<figure><img src="https://879775583-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM0P3gHFFZE4c6PMaPvHm%2Fuploads%2FoGMZKMU3sVgC7yIs6N5e%2FScreen%20Shot%202025-06-24%20at%203.16.01%20PM.png?alt=media&#x26;token=1300d8fd-94d0-4b3a-9a87-cfb8e83ab3af" alt=""><figcaption><p>How the match field is selected in the platform dashboard</p></figcaption></figure>

`conditions: IGroupCondition[]` *required* - Contains the rules or conditions of an Adaptive Group.

<pre><code>type IGroupCondition = {
    type: string;
    conditionAttribute: string;
    conditionOperator: IGroupOperator;
<strong>    conditionValue: (string | number)[];
</strong>};
</code></pre>

See below for details on the subfields:

* `type: string` *required* - Identifies the data type of the attribute referenced in the rule. For preset attributes, the types are as follows:
  * First Name: `"string"`
  * Last Name: `"string"`
  * Phone Number: `"number"`
  * Email: `"string"`
  * Opt-In Source: `"number"` - Set of [hardcoded values that map to IDs](#opt-in-source-ids)
  * Join Date: `"date"`
  * Clicked Link: `"number"` - The numeric ID corresponding to the desired short link.
  * Groups: `"number"` - The numeric ID corresponding to the desired group.
* `conditionAttribute: string` *required* - Defines the field that will be checked when the Adaptive Group rules are evaluated. The preset attributes are as follows:
  * ```
    enum IGroupConditionAttribute { 
        FIRST_NAME = 'firstName', 
        LAST_NAME = 'lastName',
        EMAIL = 'email', 
        PHONE_NUMBER = 'number', 
        JOIN_DATE = 'date', 
        SIGN_UP_METHOD = 'signUpMethod', 
        CLICKED_LINK = 'linkClickTracking', 
        CUSTOM_FIELD = 'custom-' 
    } 
    ```

{% hint style="info" %}
*You can use `CUSTOM_FIELD` to reference* [*Custom Subscriber Attributes*](https://developers.mobile-text-alerts.com/tutorials/custom-subscriber-attributes) *that have been created on your account. For the value, use the custom field ID to reference the specific field as follows: `'custom-<customFieldId>'`. Call the* [*GET /custom-fields endpoint*](https://developers.mobile-text-alerts.com/custom-subscriber-attributes#get-custom-fields) *to retrieve the `customFieldId` values for attributes on your account.*

*Note that the type of this field must match the type of the specific custom attribute.*
{% endhint %}

* `conditionOperator: string enum` *required* - This comparison expression determines how the attribute is compared to the chosen value. This must be one of the following `enum` values:

  ```ts
  enum IGroupOperator {
    EQUALS = 'equals',
    NOT_EQUALS = 'not equals',
    CONTAINS = 'contains',
    STARTS_WITH = 'starts with',
    ENDS_WITH = 'ends with',
    GREATER_THAN = 'greater than',
    LESS_THAN = 'less than',
    IS_EMPTY = 'is empty',
    IS_NOT_EMPTY = 'is not empty',
    BETWEEN = 'between',
    NOT_BETWEEN = 'not between',
    IS_TRUE = 'is checked',
    IS_FALSE = 'is not checked',
  }
  ```
* `conditionValue: (string | number)[]` *required* - This is the value that the subscriber attribute will be compared against. The type of this value must match the type listed in the `type` field.

{% hint style="info" %}

#### Optional Advanced Settings

The `settings` field can also contain optional fields `conditionSubOperator` and `conditionSubValue`. These fields add an additional layer of comparison and complexity. They are recommended only for advanced users.
{% endhint %}

<details>

<summary>List of Opt-In Source IDs</summary>

```
OPT_IN_MESSAGE = 1,
SIGN_UP_FORM = 2,
CONTROL_PANEL = 3,
SPREADSHEET_IMPORT = 4,
API = 5,
ACTIVE_DIRECTORY_SYNC = 6,
BLESS_IMPORT = 7,
CONSTANT_CONTACT = 8,
SONLET_SYNC = 9,
THIRD_PARTY_SYNC = 9,
BLESS_REGISTRATION = 10,
MANUAL_ENTRY = 11,
ZIPWHIP_SYNC = 12,
OPT_IN_WEB_BANNER = 13,
ZAPIER_SYNC = 14,
SHOPIFY_SYNC = 15,
HUBSPOT_SYNC = 16,
KEYWORD = 17,
QR_CODE = 18,
WEBINAR_IMPORT = 19
```

</details>

#### Example `settings` configuration for an Adaptive Group

Let's create an Adaptive Group with two conditions. If a subscriber meets either condition, they will be added to the group.

If a subscriber matches any of these conditions, they will be added to the group, so `match: "OR"`.

* **Join Date is between 06/01/2025 to 06/30/2025**
  * The following shows how this would be mapped to fields:
    * `"type": "date"` - The Join Date field uses the type `"date"`.
    * `"conditionAttribute": "date"` - The Attribute Name for Join Date is just `"date"`.
    * `"conditionOperator": "between"` - The comparison being configured is **between** two dates.
    * `"conditionValue": ["2025-06-01 04:00", "2025-06-30 04:00"]` - The start and end range of the "between" comparison are provided as an array with two date strings.
* **Email ends with "@yourorg.com"**
  * The following shows how this would be mapped to fields:
    * `"type":"string"` - The Email field uses the type `"string"`.
    * `"conditionAttribute":"email"` - The Attribute Name for Email is `"email"`.
    * `"conditionOperator":"ends with"` - Here we want to look for matching domains of the email address, so `"ends with"` is used.
    * `"conditionValue":["@yourorg.com"]` - The string value that the subscriber email will be compared against to see if it matches `"ends with"`.

Below shows how this is displayed in the platform dashboard:

<figure><img src="https://879775583-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FM0P3gHFFZE4c6PMaPvHm%2Fuploads%2FcUl3y6zu5GsVbb8ynSBS%2FScreen%20Shot%202025-06-25%20at%204.58.46%20PM.png?alt=media&#x26;token=6b8be9e6-1610-4252-a155-e4d9e968d563" alt=""><figcaption><p>Example Adaptive Group conditions shown in the platform dashboard</p></figcaption></figure>

Complete `settings` configuration for this example:

```json
"settings":
    {"match":"OR",
    "conditions": [
        {"type":"date",
        "conditionAttribute":"date",
        "conditionOperator":"between",
        "conditionValue":["2025-06-01 04:00","2025-06-30 04:00"]},
        
        {"type":"string",
        "conditionAttribute":"email",
        "conditionOperator":"ends with",
        "conditionValue":["@yourorg.com"]}
        ]
    }
```

See [Create Group](https://developers.mobile-text-alerts.com/tutorials/manage-subscribers/group-subscribers/..#create-a-new-group) to learn more about this endpoint.

### Update an Adaptive Group

The `settings` field that contains the conditions for an Adaptive Group can be updated at any time by calling the <mark style="color:purple;">`PATCH`</mark> [`/groups/{groupId}`](https://developers.mobile-text-alerts.com/tutorials/manage-subscribers/group-subscribers/..#update-groups) endpoint with the identifying `{groupId}` of the group to be updated.

### List Adaptive Groups

By default, Adaptive Groups are **not** listed when calling the `GET` [`/groups`](https://developers.mobile-text-alerts.com/tutorials/manage-subscribers/group-subscribers/..#list-all-groups) endpoint. To include Adaptive Groups, add the optional query parameter `filters[includeAdaptive]`.

#### Example query with Adaptive Groups included:

*(Note: the `[]` brackets are escaped characters in the cURL request.)*

{% code overflow="wrap" %}

```
curl --location 'https://api.mobile-text-alerts.com/v3/groups?filters%5BincludeAdaptive%5D=true' \
  --header 'Authorization: Bearer 3068eebf-7661-5458-830e-65cd055a0b03'
```

{% endcode %}
