Segmentation (Filters) API

API methods to manage Filters

createFilter

POST https://api.pushwoosh.com/json/1.3/createFilter

Creates a new filter.

Request Body

{
  "status_code": 200,
  "status_message": "OK",
  "response": {
      "name": "filter name"
  }
}

Example
{
  "request": {
    "auth": "yxoPUlwqm…………pIyEX4H", // required, API access token from Pushwoosh Control Panel
    "name": "filter name", // required
    "conditions": [["TagName1", "IN", ["value1", "value2"]], ["TagName2", "IN", ["value1", "value2"]]], // required, filter conditions
    "operator": "AND", // optional, operator values: 'AND', 'OR'
    "application": "AAAAA-00000", // optional, this parameter is usable only with High-Speed setup; omit otherwise
    "expiration_date": "2018-12-31" // optional, filter expiry. The filter will be automatically deleted on date specified, unless it's used in a Push Preset or an RSS feed
  }
}

  // creating Filters for Timezones 
{
  "request": {
    "auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
    "name": "timezone name",
    "conditions": [["Timezone", "BETWEEN", ["UTC-12:00", "UTC+14:00"]]],
  }
}

listFilters

POST https://api.pushwoosh.com/json/1.3/listFilters

Returns a list of available filters with their conditions.

Request Body

{
    "status_code": 200,
    "status_message": "OK",
    "response": {
    "filters": [
       {
           "name": "filter name",
           "conditions": "#TagName1(value1, value2) AND #TagName2(value1, value2)",
           "application" : "AAAAA-ZZZZZ", //only for app-specific filters
           "expiration_date": "YYYY-MM-DD", //"null" for filters without expiration date
           "application" : "AAAAA-ZZZZZ" // only for app-specific filters
       }
    ]
  }
}

Example
  {
      "request":{
        "auth": "yxoPUlwqm…………pIyEX4H" // API access token from Pushwoosh Control Panel
      }
  }

deleteFilter

POST https://api.pushwoosh.com/json/1.3/deleteFilter

Deletes an existing filter.

Request Body

{
  "status_code": 200,
  "status_message": "OK",
  "response": null
}

Example
{
  "request": {
    "auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
    "name": "filter name"
  }
}

exportSegment

POST https://api.pushwoosh.com/api/v2/audience/exportSegment

A scheduled request. Exports the list of subscribers that fall under specified Filter conditions.

Request Body

{
    "task_id": "177458"
}

Example
{
        "auth": "yxoPUlwqm…………pIyEX4H", // required, API access token from Pushwoosh Control Panel
        "filterExpression": "AT(\"12345-67890\", \"Name\", any)", // filter conditions, refer to the Segmentation Language guide for syntax 
        "filterCode": "12345-67890", // pre-made filter code, can be used instead of filterExpression
        "applicationCode": "00000-AAAAA", // Pushwoosh app code (needed when filterCode is applied instead of filterExpression). Can be obtained from /listFilters API request or address bar of your browser while viewing the filter in Control Panel.
        "generateExport": true // if false, devices count only will be sent in response; by default, a response contains a link to download the CSV file
        "format": "json_each_line", // format of the file to present the data in: "csv" – the .csv file is downloaded; "json" – a JSON file with all expored devices; or "json_each_line" – JSON line for each device. If not specified, CSV is the default format. 
        "exportData": ["hwids", "tags"], // optional, data to export. Possible values: "hwids", "push_tokens", "users", "tags", "fcm_keys", "web keys"
        "tagsList": ["Name", "Level"] // optional, specifies tags to export. To obtain the specific tags only, the "tags" value should be sent within the "exportData" array or the "exportData" be empty. 
}

Please find Segmentation Language reference for writing filter expressions here.

For example, to export all subscribers of a particular app, use the following Filter conditions:

{
        "auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
        "filterExpression": "A(\"AAAAA-BBBBB\")" // Pushwoosh app code
}

In the response, you'll get the task_id to get the resulting file. Then, call /exportSegment/result with that task_id in the request body to retrieve the resulting file.

exportSegment results

POST https://api.pushwoosh.com/api/v2/audience/exportSegment/result

Retrieves the link to the CSV with the the /exportSegment results.

Request Body

{
  "devicesCount": "24735",
  "csvFilename": "https://static.pushwoosh.com/segment-export/export_segment_XXXXX_XXXXX_xxxxxxxxxxxxxxxxx.csv.zip",
",
  "status": "completed"
}

Pass the "task_id" received in your /exportSegment response in the /exportSegment/result request body.

In /exportSegment/result response, you'll get the "filename" parameter; go to the link specified as that param value. A ZIP archive will be downloaded automatically. Unpack the archive to get the CSV or JSON (depending on what "format" you've sent in the request) file with the devices' data.

If you specify the "exportData" in your /exportSegment request, the file downloaded will contain the data requested only. By default, the file contains the following user data:

Last updated