Documentation
Send Notifications API
Instantly send push notifications to devices and more with this powerful API.
Backend Code Samples
We provide implementations of this API in the following languages to help you send push notifications from your backend:
API Endpoint
POST https://api.pushy.me/push?api_key=SECRET_API_KEY
Make sure to replace SECRET_API_KEY
with your app's Secret API Key listed in the Dashboard.
Note: This is a backend API endpoint. Never expose your application's Secret API Key in your client code.
Request Headers
Content-type: application/json
JSON Post Parameters
Key | Description | Type |
---|---|---|
to
|
A device token, multiple device tokens, or a topic (prefixed with /topics/ ).
Note: Unlike GCM / FCM, we do not limit the number of tokens to 1,000. |
A string or string[] array |
data
|
The payload data you want to push to devices, limited to 4kb.
Contact us if you need to send larger payloads. |
An object |
tokens
|
An alternative parameter to to for specifying recipient device tokens.
Can also be specified as registration_ids .
|
A string[] array |
time_to_live
(optional) |
Specifies how long (in seconds) the push notification should be kept if the device is offline.
The default value is 1 month. The maximum value is 1 year. |
An integer |
notification
(iOS only) |
iOS notification options, such as the alert message, sound, or badge number (see below). | An object |
content_available
(iOS only) |
When set to true , your app's notification handler will be invoked even if the app is running in the background, making it possible to fetch updated content from the server or execute other custom logic without necessarily alerting the user.
Requires the Background Modes -> Remote Notifications capability to be enabled. |
A boolean |
mutable_content
(iOS 10+ only) |
When set to true , your app's Notification Service Extension will be invoked even if the app is running in the background, making it possible to download and display rich media attachments within your notification.
Requires the Background Modes -> Remote Notifications capability to be enabled. |
A boolean |
notification
(iOS only, all are optional)
Key | Description | Type |
---|---|---|
body
|
The main alert message, visible on the lock screen and in other areas on iOS. Supports Apple Emojis via their unicode representation. | A string |
badge
|
The number to display as the badge of the app icon. | An integer |
sound
|
The name of a sound file in the app bundle or in the Library/Sounds folder of your app's data container. |
A string |
title
|
A short string describing the purpose of the notification, visible only on Apple Watch. Added in iOS 8.2. | A string |
category
(iOS 10+ only) |
Your app's Notification Content Extension with the matching category will be invoked in order to display custom notification UI. |
A string |
loc_key
|
The localization key of a string present in your app's Localizable.strings file.
Use this parameter to localize the notification body. Refer to the APNs Documentation for more information. |
A string |
loc_args
|
The replacement strings to substitute in place of the %@ placeholders of the localization string matching the specified loc_key .
Use this parameter to localize the notification body. Refer to the APNs Documentation for more information. |
A string[] array |
title_loc_key
|
The localization key of a string present in your app's Localizable.strings file.
Use this parameter to localize the notification title. Refer to the APNs Documentation for more information. |
A string |
title_loc_args
|
The replacement strings to substitute in place of the %@ placeholders of the localization string matching the specified title_loc_key .
Use this parameter to localize the notification title. Refer to the APNs Documentation for more information. |
A string[] array |
Sample POST Body
{
"to": "a6345d0278adc55d3474f5",
"data": {
"message": "Hello World!"
},
"notification": {
"body": "Hello World \u270c",
"badge": 1,
"sound": "ping.aiff"
}
}
Tip: Your app will be able to parse and extract the notification payload data
you send within its notification listener / receiver.
API Response
Successful Response Example
{"success":true, "id":"5742ea5dacf3a92e17ba7126"}
Failure Response Example
{"error":"Please supply your API key to send a push notification."}
API Response Objects
Key | Description | Type |
---|---|---|
id
|
The push notification unique ID. Returned if the API request was successful. Use it to check delivery status using the Notification Status API. | A string |
success
|
Returned if the API request was successful. | A boolean |
error
|
Returned if the API request failed, along with an explanation. | A string |
info
|
Contains additional information about the notification, for debugging purposes. | An object |