Programmatically create segments in your OneSignal app using flexible filters and targeting rules.
Documentation Index
Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
Use this file to discover all available pages before exploring further.
"AND" and "OR", mirroring the segmentation capabilities of the OneSignal Dashboard.
included_segments and excluded_segments targeting parameters.
description (max 255 characters) to record the segment’s purpose. The description is returned by the View segments and View segment APIs.
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.tagrelation = ">", "<", "=", "!=", "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_sessionhours_ago).
relation = ">" or "<"
hours_ago = number of hours before or after the user’s last session. Example: "1.1"
first_sessionhours_ago).
relation = ">" or "<"
hours_ago = number of hours before or after the user’s first session. Example: "1.1"
session_countrelation = ">", "<", "=" or "!="
value = number of sessions. Example: "1"
session_timerelation = ">" or "<"
value = time in seconds the user has been in your app. Example: 1 day is "86400" seconds.
languagerelation = "=", "!=", "in_array", or "not_in_array"
value = 2 character language code. Example: "en".
For "in_array" and "not_in_array", the value should be a comma-separated list of values.
app_versionrelation = ">", "<", "=" or "!="
value = app version. Example: "1.0.0"
locationradius = in meters
lat = latitude
long = longitude
countryrelation = "=", "!=", "in_array", or "not_in_array"
value = Two-letter country code in uppercase. Example: "US", "GB", "CA".
For "in_array" and "not_in_array", the value should be a comma-separated list of values.
Your 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.
Optional human-readable description for the segment. Maximum 255 characters.
255