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.
filters
operator
"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.tag
include_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_session
relation
= ">"
or "<"
hours_ago
= number of hours before or after the user’s last session. Example: "1.1"
first_session
relation
= ">"
or "<"
hours_ago
= number of hours before or after the user’s first session. Example: "1.1"
session_count
relation
= ">"
, "<"
, "="
or "!="
value
= number sessions. Example: "1"
session_time
relation
= ">"
or "<"
value
= Time in seconds the user has been in your app. Example: 1 day is "86400"
secondslanguage
relation
= "="
or "!="
value
= 2 character language code. Example: "en"
.app_version
relation
= ">"
, "<"
, "="
or "!="
value
= app version. Example: "1.0.0"
location
radius
= 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 used to define the segment audience.
1 - 200
elementsUUID of the segment. If left empty, it will be assigned automatically.