const API_URL = "https://api.pushbase.dev/broadcasts/client-push";
const API_KEY = "YOUR_API_KEY"; // Available in Pushbase dashboard app setting section
const myHeaders = new Headers();
myHeaders.append("x-api-key", API_KEY);
myHeaders.append("Content-Type", "application/json");
/* Replace this with the subscribed device records from your existing database.
*
*/
const notification = {
title: "Terms & Policies updates",
body: "We have updated our policies and terms. Review now.",
/* Important: this is where you define target users from the dashboard.*/
segment_id: 1,
/* When notification will be delivered. Only `instant` and `scheduled` supported. */
delivery: "instant",
/* For deep linking to a custom route. default to 1 for Main Screen */
link_id: 1,
/* Applied while notification is scheduled. Must be future ISO 8601 datetime string. Scheduled in your local time.*/
scheduled_at: "2026-05-12T05:50:00",
};
const raw = JSON.stringify(notification);
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow",
};
fetch(API_URL, requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));