---
name: azion-create-device-groups
description: >-
  Create a device group that matches the User-Agent header in Azion Console, then confirm it with a rule that adds a response header.
---

# Create device groups

You can create a [device group](/en/documentation/platform/applications/device-groups/) for an [application](/en/documentation/platform/applications/) in Azion Console, then confirm it with a rule that marks the responses to that group. A device group pairs a name with a regular expression, and the application compares the expression with the `User-Agent` header of each request.

To keep a separate cached copy of each object for every device group, set the variation in a cache setting instead. For more information, refer to [Application Accelerator settings](/en/documentation/platform/applications/application-accelerator/settings/#cache-variation).

---

## Prerequisites

- An application served by a [workload](/en/documentation/platform/workloads/). To create both, refer to [Applications quickstart](/en/documentation/platform/applications/quickstart/).
- Application Accelerator turned on for the application. The rule on this page reads the `${device_group}` variable, which requires it. To turn it on, refer to [Main Settings](/en/documentation/platform/applications/main-settings/#products).
- Access to Azion Console. To sign in, refer to [Access Azion Console](/en/documentation/guides/platform/account-and-billing/how-to-access-azion-console/).

---

## Create the device group

The device group in this section is named `Mobile`. Its expression matches any `User-Agent` header that contains `Mobile`, `iPhone`, or `Android`, because a match on part of the header is enough. Each application keeps its own device groups, in its **Device Groups** tab.

To create the device group in Azion Console:

1. **Open the application**

   Access [Azion Console](https://console.azion.com/) > **Applications**, and select the application.

2. **Select the Device Groups tab**

3. **Start a new device group**

4. **Name the device group**

   In **Name**, enter `Mobile`. The name takes letters and numbers only, with no spaces. For any other character, the Console shows `Name must be alphanumeric`.

5. **Enter the regular expression**

   In the **Match to User-Agent** section, enter `(Mobile|iPhone|Android)` as the **Regular Expression**.

6. **Save the device group**

Azion Console shows `Device Group successfully created`, and the group appears in the **Device Groups** tab. For each field of a device group and the messages the form shows, refer to [Device Groups](/en/documentation/platform/applications/device-groups/#device-group-fields).

---

## Match the device group in a rule

A rule that reads `${device_group}` applies its behaviors only to the requests of one device group. The rule in this section runs in the Response Phase. It adds the header `Device-Is: Mobile device` to each response sent to the `Mobile` group, so a response shows whether the group matched its request. The rule is a check: once the group is confirmed, you change its behavior or turn it off.

To create the rule in Azion Console:

1. **Open the application**

   Access [Azion Console](https://console.azion.com/) > **Applications**, and select the application.

2. **Select the Rules Engine tab**

3. **Select + Rule**

4. **Name the rule**

   In **General**, enter `Device Group: Mobile` as the **Name**.

5. **Select the response phase**

   In **Phase**, select *Response Phase*. A rule's phase cannot change after you create the rule.

6. **Set the criterion**

   Under **Criteria**, select the variable `${device_group}` and the operator `is_equal`, and enter `Mobile` as the argument.

7. **Add the response header behavior**

   Under **Behaviors**, select the behavior that adds a header to the response. In the API, its type is `add_response_header`.

8. **Enter the header**

   Enter `Device-Is: Mobile device` as the argument. The Console refuses an argument that is not in the `header-name: value` format.

9. **Select Save**

The rule appears in the **Rules Engine** tab, under the **Response** heading. For every variable, operator, and behavior a rule accepts, refer to [Rules Engine for Applications](/en/documentation/platform/applications/rules-engine/).

---

## Confirm the device group

The rule that reads `${device_group}` marks each response to the `Mobile` group, so one request confirms whether the group matches a device. [Send the request to the application](/en/documentation/guides/platform/migration/configure-a-domain/) from a device that the expression matches. A browser on a mobile device works, and so does any client that sets the `User-Agent` header to a matching value, such as `iPhone Android`.

The response carries the header the rule adds, `device-is: Mobile device`. A request whose `User-Agent` header the expression does not match receives no such header.

A new rule can take a few minutes to take effect, and until then no response carries the header. Send the request again before you change the rule or the expression.

Once the header appears, the device group is confirmed. Replace the behavior of the rule with the one the group is for, or turn off **Active** in the **Status** section of the rule so that it stops running. For more information, refer to [Create an application rule](/en/documentation/guides/application-development/getting-started/work-with-rules-engine/).

---

## Next steps

- [Device Groups](/en/documentation/platform/applications/device-groups.md): The fields of a device group, the order in which groups match, and the cache key of each variation.
- [Rules Engine for Applications](/en/documentation/platform/applications/rules-engine.md): Every variable, operator, and behavior a rule that matches a device group can use.
- [Application Accelerator settings](/en/documentation/platform/applications/application-accelerator/settings.md#cache-variation): Keep a separate cached copy of each object for every device group.
- [Create an application rule](/en/documentation/guides/application-development/getting-started/work-with-rules-engine.md): Build the rules that act on a device group once it matches the right requests.
