Making API Endpoint Calls to Send Push Notifications

I want to manually make an api call to the API endpoint for push notifications,

So far I have this POST request setup but I am unsure of how to pass the data in a JSON string.


var headers = new Headers();
headers.append('Content-Type', 'application/json');"",
      //data goes here
    }), {headers: headers})
    .map(res => res.text())
    .subscribe(data => console.log(data)
        , err => console.log("server_error"));

I think I need to pass variables for the following:

“tokens”: [“DEVICE_TOKEN”],
“profile”: “PROFILE_TAG”,
“notification”: {
“message”: “Hello World!”

However how do I get my device token and how do I specify the message property under notification? Can someone give me an api call code example? Thank you!

Do you managed to solve this? I’m stuck on this matter too

The device token needed for the API can be retrieved by going to then selecting your project, going to SETTINGS, clicking “API Keys”, then “+New Token”

To create a profile go to SETTINGS again and click “Certificates” then “+New Security Profile”

Here’s a working example using XHR, this will send to all devices:

<!DOCTYPE html>
	<script type="text/javascript">

	function sendNotification() {

		var title = document.getElementById("title").value;
		var body = document.getElementById("body").value;

		var data = JSON.stringify({
		  "send_to_all": true,
		  "notification": {
		    "title": title,
		    "message": body

		var xhr = new XMLHttpRequest();
		xhr.withCredentials = true;

		xhr.addEventListener("readystatechange", function () {
		  if (this.readyState === 4) {
		});"POST", "");
		xhr.setRequestHeader("content-type", "application/json");
		xhr.setRequestHeader("authorization", "Bearer [INSERT YOUR API TOKEN HERE]");
		xhr.setRequestHeader("cache-control", "no-cache");




	<style type="text/css">
		.container {
			display: flex;
			flex-direction: column;
			width: 300px;

		.container > div {
			margin-bottom: 30px;

		textarea {
			width: 400px;
			height: 100px;

<div class="container">
	<div><input type="text" id="title" placeholder="Title"></div>
	<div><textarea id="body" placeholder="Notification Message"></textarea></div>
	<div><button onclick="sendNotification()">Send Notification</button></div>