OneSignal - Creating Segments

onesignal documentation
onesignal subscribe user
onesignal send notification to specific user php
onesignal nodejs
cdn onesignal
onesignal pricing
onesignal javascript api
onesignal send notification to all users

I want to create Segments in oneSignal with out having to access the dashboard so I was wondering if they have an API for that for or any other way to it with me to do it

Currently OneSignal does not have any api for creating segment, but if you want to send notifications to specific group you can use tags.

Yes you can send notification to a particular tag, tags can be used as an alternate to segments. If you want to send notification to segment A. set tags for that users to {user:A} and can send notification using this php request.

$fields = array(
        'app_id' => YOUR_ONE_SIGNAL_APP_ID,
        //'included_segments' => array('plant_a'),
        'filters' => array(array("field" => "tag", "key" => "user", "relation" => "=", "value" => "A")),
        'data' => array("foo" => "bar"),
        'contents' => $content

Your complete code will be like

    function sendMessage(){
        $content = array(
            "en" => 'English Message'

        $fields = array(
            'app_id' => YOUR_ONE_SIGNAL_APP_ID,
            'filters' => array(array("field" => "tag", "key" => "user", "relation" => "=", "value" => "A")),
            'data' => array("foo" => "bar"),
            'contents' => $content

        $fields = json_encode($fields);
        print("\nJSON sent:\n");

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "");
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
                                                'Authorization: Basic REST_API_KEY'));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

        $response = curl_exec($ch);

        return $response;

    $response = sendMessage();
    $return["allresponses"] = $response;
    $return = json_encode( $return);

    print("\n\nJSON received:\n");

Segments, Supersize your push strategy by saving segments and building automated drip campaigns for users in each segment. For example, Evino uses segments to target  OneSignal has four built-in segments: All (every subscribed), Engaged (frequent visitors), Active (recent visitors), and Inactive (it's been a while). We recommend you set up automated messages to reengage users when they become inactive, send more messages to engaged users, and create special offers to turn active into engaged users.

According to their docs, Unfortunately OneSignal does not have this feature at the moment:

There are no limits on the number of filters you may add to a segment or the number of segments you may create in OneSignal. Segments may only be created from the Dashboard, but segments may be referenced from the SDK and API.

Targeting & Segmenting Users, Segment that will be excluded when sending. Users in these segments will not receive a notification, even if they were included in included_segments . This  OneSignal features - Segmenting your users. Segments give you the ability to target users with more personalized and more engaging push notifications by dividing your total user base into specific audiences based on data attributes like activity, location, and Data Tags.

According to their docs[] you can call de api but you need a ONESIGNAL PAID PLAN

Create notification, Detailed walkthrough of creating basic segments with OneSignal Data Filters. More details Duration: 3:16 Posted: Nov 21, 2019 Segments, this is just a list of the segments that the devices currently in. Tags are the ability to set custom key-value pair of data to users. The key and value can be a string or integer data. It cannot be array data. So, string or integer data, you can use that to create segments. You can use this for tag variable substitution.

OneSignal Creating Segments, Tutorial on creating advanced segments with tags and location data. More details in our Duration: 3:45 Posted: Nov 21, 2019 Currently OneSignal does not have any api for creating segment, but if you want to send notifications to specific group you can use tags. Yes you can send notification to a particular tag, tags can be used as an alternate to segments.

OneSignal Advanced Segments, OneSignal is a complete push notification solution for mobile apps. After destination Segment with your app, enable OneSignal in your segment When the audience is first created an identify call is sent for every user in the  OneSignal still requires you to bundle its SDK into your Segment SDK, but that can be done with a single line of code in your pod file. Once it’s bundled, the rest of your customer data gets translated and sent to OneSignal in the format it expects. Device information, push tokens,

OneSignal Destination, All the push notification sending rules are handled in the OneSignal dashboard, so there's no need for custom code on that end. Automates campaign delivery  Powerful targeting lets you leverage existing OneSignal segments, or trigger in-app messages based on actions a user takes while in your app. Add images and gifs from your computer or the web, customize font, and button styles to your own liking. Built-in analytics shows you what users are clicking on so you can optimize for engagement. Test to see what provides value to your user experience.