Programmatically create segments in your OneSignal app using flexible filters and targeting rules.
"AND" and "OR", mirroring the segmentation capabilities of the OneSignal Dashboard.
included_segments and excluded_segments targeting parameters.
filtersoperator"AND" have higher priority than "OR" filters.
"AND" = the 2+ connected filters must be satisfied for the recipient to be included. Filter entries use this by default and its not required to be included."OR" = the 2 filters separated by the "OR" operator are mutually exclusive. The recipients only need to satisfy the conditions on either side of the "OR" operator.taginclude_aliases targeting property.
relation = ">", "<", "=", "!=", "exists", "not_exists", "time_elapsed_gt", (time elapsed greater than) and "time_elapsed_lt" (time elapsed less than)
time_elapsed_gt/lt fields correspond to Time Operators and require a paid plan.key = Tag key to compare.value = Tag value to compare. Not required for "exists" or "not_exists".last_sessionrelation = ">" or "<"hours_ago = number of hours before or after the user’s last session. Example: "1.1"first_sessionrelation = ">" or "<"hours_ago = number of hours before or after the user’s first session. Example: "1.1"session_countrelation = ">", "<", "=" or "!="value = number sessions. Example: "1"session_timerelation = ">" or "<"value = Time in seconds the user has been in your app. Example: 1 day is "86400" secondslanguagerelation = "=" or "!="value = 2 character language code. Example: "en".app_versionrelation = ">", "<", "=" or "!="value = app version. Example: "1.0.0"locationradius = in meterslat = latitudelong = longitudeYour OneSignal App ID in UUID v4 format. See Keys & IDs.
An internal name you set to help organize and track Segments. Maximum 128 characters.
Filters define the segment based on user properties like tags, activity, or location using flexible AND/OR logic. Limited to 200 total entries, including fields and OR operators. See Sending messages with the OneSignal API.
1 - 200 elementsRequired. The fitler object.
UUID of the segment. If left empty, it will be assigned automatically.