Targeting your audience using attributes

You can target attributes using the dashboard and API.

For messages sent from the dashboard, follow the steps in Target Specific Users.

For the API, follow the steps on this page.

 Warning

If you want to target users based on a unique user ID or other external identifier, do not use custom attributes. Instead, target Named UserA customer-provided identifier used for mapping multiple devices and channels to a specific individual. .


To target users based on attributes, use the attributes audience object, which consists of the attribute ID, comparison operator, attribute value, and an optional precision in the case of a DATE attribute.

Example push to a TEXT attribute
POST /api/push HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-type: application/json

{
    "audience": {
        "attribute": "item_purchased",
        "operator": "contains",
        "value": "jeans"
    },
    "device_types": [
        "ios",
        "android",
        "web"
    ],
    "notification": {
        "alert": "Hello from Airship"
    }
}

See Attributes in our API reference for details and example requests.

Use boolean NOT or AND operators to create compound audience expressions. In the following example, the NOT operator gives you the same result as if you had used the “does not contain” operator via the UI.

See Compound Selector for details on using boolean audience operators.

{
    "NOT": {
        "attribute": "item_purchased",
        "operator": "contains",
        "value": "jeans"
    }
}
{
    "AND": [
        {
            "attribute": "size",
            "operator": "greater",
            "value": 12
        },
        {
            "attribute": "size",
            "operator": "less",
            "value": 15
        }
    ]
}