If your app already has production users, Pushbase provides an API to seamlessly import your existing subscribed devices. This allows you to begin sending push notifications to those devices directly from the Pushbase Dashboard.
To enable device segmentation and targeting in Pushbase, each device must conform to the following format.Only the following properties are required: platform, country, language, timezone, and expo_push_token.
Copy
interface Device { /** One of React Native mobile supported OS * @see https://gist.github.com/pushbasedev/5bf3c4ad6874d953d6399796cd0c282e * */ platform: Platform; /** * Alpha-2 valid country code * @see https://gist.github.com/pushbasedev/ab8046f6fe04de143e5500f0d9ce7e7f */ country: CountryCode; /** * Alpha-2 valid language code * @see https://gist.github.com/pushbasedev/07be3c9c3cb416bc5d09c78bd2554fd1 */ language: Language; /** * A valid timezone identifier * @see https://gist.github.com/pushbasedev/f2275af1af486fb694de7e835d9c9e6a */ timezone: Timezone; expo_push_token: string; device_push_token?: string; manufacturer?: string; model?: string; brand?: string; os_name?: string; os_version?: string; region?: string; city?: string; latitude?: string; longitude?: string; /* Unique Id from your database to identifier device owner */ external_id?: string; /* User name from your database to identifier device owner */ external_name?: string; /* Email from your database to identifier device owner */ external_email?: string; /* Phone from your database to identifier device owner */ external_phone?: string; /* When set true, this device will be used for push testing*/ is_tester?: boolean;}
The devices array must not exceed 1000 items. Please split your data into
chunks of 1000 or fewer devices per request.
Copy
const API_URL = "https://api.pushbase.dev/devices/import";const API_KEY = "YOUR_API_KEY"; // Available in Pushbase dashboard app setting sectionconst 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. * The ‘devices’ array must not exceed 1000 items. Please split your data into chunks of 1000 or fewer devices per request. */const devices = [ { /* Required properties*/ platform: "ios", country: "PL", language: "PL", timezone: "Europe/Warsaw", expo_push_token: "ExponentPushToken[VSdTS398767-876hSpj4Aoc9]", /* Optional properties*/ device_push_token: "c5b8u2adQjqey4fmIP8UYN:APA91bHiAM88JhhaYrLm9h9DKRzOdNAs3LIk6..." /* Location specific */ region: "Mazowieckie", city: "Warsaw", latitude: "52.237049", longitude: "21.017532", /* User identity*/ external_id: "cd23bf3c-bddf-431d-9145-d9b41fcecdcd", external_name: "Maria Curie", external_email: "marie-curie@kva.se", external_phone: "08-673 95 00", /* Device specific*/ manufacturer: "Apple", brand: "Apple", model: "iPhone 16", os_name: "iOS", os_version: "26.0", }, { platform: "android", country: "US", language: "EN", timezone: "America/New_York", expo_push_token: "ExponentPushToken[TAHZDfF9qqG10FaYku9eB9]", //... more properties here },];const raw = JSON.stringify({ devices,});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));
Having trouble setting up or configuring the SDK? Our support team is here to
help — feel free to reach
out