post https://api.onesignal.com/apps//segments
Create segments visible and usable in the dashboard and API.
This API requires a subscription to a paid plan.
The Create Segment method is used when you want your server to programmatically create a segment instead of using the OneSignal Dashboard UI. Just like creating Segments from the dashboard, you can pass in filters
with multiple "AND"
or "OR"
operator
's.
Does Not Update Segments
This endpoint will only create segments, it does not edit or update currently created Segments. You will need to use the Delete Segments endpoint and re-create it with this endpoint to edit.
Additional Examples
{
"name": "Segment 2",
"filters": [
{"field": "session_count", "relation": ">", "value": "1"},
{"operator": "AND"},
{"field": "tag", "relation": "!=", "key": "tag_key", "value": "1"},
{"operator": "OR"},
{"field": "last_session", "relation": "<", "hours_ago": "30"}
]
}
//Another Example
{
"name": "iOS, Android, Web",
"filters": [
{"field": "device_type", "relation": "=", "value": "iOS"},
{"operator": "OR"},
{"field": "device_type", "relation": "=", "value": "Android"},
{"operator": "OR"},
{"field": "device_type", "relation": "=", "value": "Web Push (Browser)"}
]
}