API

Send Notification

POST
https://www.pushmix.co.uk/api/notify

The response data encoded in JSON format. Any none-200 HTTP response code are an error, the returned data will contain more information.

Parameter Type Description
key_id string REQUIRED Your Subscription ID, used to identify your account with Pushmix. Threat it as password and do not share with anyone or add to public repositories. See Subscription ID.
to string REQUIRED The subscriber audience you want to target. Available options:
all - all subscribers, anyone opted in for notifications
one - topic one subscribers only
two - topic two subscribers only
title string REQUIRED Notification title
body string REQUIRED Notification body content
default_url string REQUIRED Notification URL
time_to_live integer Maximum period of time for which message delivery will be attempted
priority string Regulates how notification being delivered, available options:
high - messages attempted to be delivered immediately
normal - messages won't open network connections on a sleeping device, and message delivery may be delayed to conserve battery
icon string Notification Icon URL
badge string Notification Badge Icon URL
image string Large Image URL
action_title_one string Action button title
action_url_one string REQUIRED WITH ACTION_TITLE_ONE Action button URL
action_title_two string Action button title
action_url_two string REQUIRED WITH ACTION_TITLE_TWO Action button URL


$data = [

    // Required Parameters
    'key_id'            => 'YOUR SUBSCRIPTION_ID', // Subscription ID
    'to'                => 'all', // accepted options 'all', 'one', 'two'
    'title'             => 'Hello',
    'body'              => 'Welcome to Pushmix!',
    'default_url'       => 'https://www.pushmix.co.uk',

];

$ch = curl_init( 'https://www.pushmix.co.uk/api/push' );

# Setup request to send json via POST.
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $data ) );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

# Send request.
$result = curl_exec($ch);
curl_close($ch);


return json_decode($result);
    
    
const payloadData = {
    // Required Parameters
    'key_id'            : 'YOUR_SUBSCRIPTION_ID', // Subscription ID
    'to'                : 'all', // accepted options 'all', 'one', 'two'
    'title'             : 'Hello',
    'body'              : 'Welcome to Pushmix!',
    'default_url'       : 'https://www.pushmix.co.uk',
};

  // Format data into URI
  const payloadString = Object.keys(payloadData)
  .filter(function(key) {
    return payloadData[key];
  })
  .map(function(key) {
    return key + '=' + encodeURIComponent(payloadData[key]);
  })
  .join('&');


fetch('https://www.pushmix.co.uk/api/push', {
  method: 'POST',
  body:payloadString,
  headers:{
      "Content-Type": "application/x-www-form-urlencoded",
   }
})
.then(res => res.json())
.then(response => {

    // contains error
    if(response.hasOwnProperty("error")){
        throw new Error(response.error);
    }

    // response object
    console.log(response);


    } )
.catch(function(error){
  // catch and display an error
  console.log(error);
});

    
var express     = require('express');
var router      = express.Router();
var querystring = require('querystring');
var https       = require('https');

// Build the post string from an object
var post_data = querystring.stringify({
    'key_id'            : 'YOUR_SUBSCRIPTION_ID', // Subscription ID
    'to'                : 'all', // accepted options 'all', 'one', 'two'
    'title'             : 'Hello',
    'body'              : 'Welcome to Pushmix!',
    'default_url'       : 'https://www.pushmix.co.uk',
})


// HTTP Request options
var post_options = {
    host: 'www.pushmix.co.uk',
    port: '443',
    path: '/api/get/topics',
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Content-Length': Buffer.byteLength(post_data)
  }
};

var response_data = '';
var req = https.request(post_options, (res) => {

    res.setEncoding('utf8');
    res.on('data', (d) => {
        response_data += d;
    });


    res.on('end', () => {
      // do something with your response object
      console.log(response_data);
     });

});

// catch an error response
req.on('error', (e) => {
    console.error(e);
});

//send request witht the post_data form
req.write(post_data);
req.end();

    
curl -d "key_id=YOUR_SUBSCRIPTION_ID&to=all&title=Hello&body=Welcome%20to%20Pushmix%21&default_url=https%3A%2F%2Fwww.pushmix.co.uk" 'https://www.pushmix.co.uk/api/notify'
    
    
    // /api/notify - response
    {succes: true}


    // Error response
    {error:"Error details message"}