APIYard
Back to APIs
CommunicationBearer TokenFree tier

OneSignal

Send push notifications, in-app messages, SMS, and email to any device. OneSignal's free tier supports unlimited subscribers and 10,000 emails/month.

Base URL

https://api.onesignal.com
push notificationsmobileweb pushin-appSMS

Endpoints

POST/notifications

Send a push notification to subscribed users.

const response = await fetch("https://api.onesignal.com/notifications", {
  method: "POST",
  headers: {
  "Content-Type": "application/json",
  "Authorization": "Bearer YOUR_ACCESS_TOKEN"
  },
  body: JSON.stringify({
  "app_id": "YOUR_APP_ID",
  "included_segments": [
    "All"
  ],
  "headings": {
    "en": "New update!"
  },
  "contents": {
    "en": "Version 2.0 is live."
  }
})
});

const data = await response.json();
console.log(data);

Response Preview

{
  "id": "458dcec4-cf53-11e3-add2-000c2940e62c",
  "recipients": 5142,
  "external_id": null
}