Segmentation

Examples to target SMS devices based on tags, named users, test groups, and audience lists.

Target SMS devices as you would any other supported channel, using audience selectors.

Tags

When setting tags on an SMS channel, use the Channel Tags endpoint.

In the provided examples, we will first add a new tag to our SMS channel using tag groups, then send a push to an audience defined by channels containing the new tag with the device type sms.

Example Request: Add tag to SMS channel using tag groups
POST /api/channels/tags HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
   "audience": {
      "channel": "34b3dfc1-d717-40fe-89e8-10584ed1c123"
   },
   "add": {
      "fish_numbers": [
         "one",
         "two"
      ],
      "fish_colors": [
         "red",
         "blue"
      ]
   }
}
Example Request: Send to SMS using your new tag
POST /api/push HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
   "audience": {
      "tag": "blue",
      "group": "fish_colors"
   },
   "notification": {
      "alert": "This one has a little star."
   },
   "device_types": [
      "sms"
   ]
}

Named Users

Named Users let you associate an ID of your choosing with a single user who is opted in across multiple engagement channels. Typically a Named User ID is an internal identifier in your CRM system.

Associate Named Users with individual SMS channels using the Named Users API.

In the provided examples, we take our new channel and associate it with a named user, then use the Push API to deliver the SMS alert.

Example Request: Associate Named User with SMS channel
POST /api/named_users/associate HTTP/1.1
Authorization: Basic <application or master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
   "channel_id": "adc9465c-68d6-481e-b5b4-6ab5a185b35f",
   "named_user_id": "erika_mustermann"
}
Example Request: Send to SMS using your new tag
POST /api/push HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
   "audience": {
      "named_user": "erika_mustermann"
   },
   "notification": {
      "alert": "Test SMS to Named User"
   },
   "device_types": [
      "sms"
   ]
}

Test Groups

Make testing easy by creating Test Groups for use in the Message Composer. Add your SMS channels for testing in the Test Group UI.

Audience Lists

Upload lists of Named Users or SMS channels via the Static Lists API or in the dashboard and use those for targeting through the Push API or Message Composer.