Push Notification Using OneSignal Rest API with PHP

Parvez Alam
2 min readOct 14, 2021

in this article, we’ll create Push Notification functionality for our app using oneSignal Rest API and Laravel. We’ll add a device and create a push notification using Rest API.

The OneSignal is the fastest and most reliable service to send push notifications, in-app messages, SMS, and emails.

What’s Push Notification

Web applications use Push Notification as their primary method of communication with their users. We receive a notification consent alert when we visit any website, with the option to approve or reject notifications. Websites develop these alerts to obtain permission to display notifications with the most recent updates, news, and other information. If we give notice display permissions, the notifications will be pushed to website users by the website administrator.

OneSignal Channel Overview

  • Web Push Notification
  • Mobile Push Notification
  • Email Push Notification
  • In-app Notification
  • SMS
  • Rest API

I am using a web push channel for this tutorial.

You can also check out other RESTful API tutorials:

Free OneSignal Account Features

  • Unlimited Mobile Push
  • Web Push Up to 10K Subscribers
  • Emojis and Images
  • Localization
  • Real-Time Analytics
  • No credit card required

How To Implement Push Notification Using Rest API

In this article, I will show you how to create a simple notification system by using PHP and OneSignal Rest API.


A Firebase Server Key and Firebase Sender ID are required in order to send push notifications to Android mobile app devices.It is optional for Amazon apps.

if you ll use this method instead of OneSignal SDKs, many OneSignal features such as conversion tracking, timezone tracking, language detection, and rich-push won’t work out of the box.

Add a device Using OneSignal Rest API

Register a new device to one of your OneSignal apps

POST https://onesignal.com/api/v1/players

There are two required parameters:

app_id: Your OneSignal App Id
device_type: 0 = iOS, 1 = Android, 2 = Amazon, 3 = WindowsPhone (MPNS) etc.

How To Create OneSignal Rest API Client

How To Add A Device Using OneSignal API

The following method helps to add a new device into OneSignal Notification list.

How To Create Notification

Let’s create method that will create OneSignal notification using Rest API.

Originally published at https://www.restapiexample.com on October 14, 2021.



Parvez Alam

Hey, I am Parvez Alam. A software developer since 2009. I love learning and sharing knowledge. https://www.phpflow.com/