Send push notifications

Overview

In order to optimize the delivery of push notifications and streamline operational processes, a new endpoint, https://connect.routee.net/push-notifications/messages, has been seamlessly integrated into the existing Push Notifications service.

Specifically designed for Routee API users, this endpoint facilitates the transmission of structured notifications via HTTP POST requests. The detailed JSON payloads mandated by this endpoint encompass crucial information like message content, recipient device tokens, and any other pertinent data essential for targeted and personalized notifications.

Moreover, stringent security measures, such as API keys or OAuth tokens, have been implemented for authentication purposes, ensuring that only authorized users can initiate notifications and guaranteeing the secure processing of each request. The system also offers immediate feedback on the status of sent notifications, ranging from successful queueing to detailed error reports in the event of any issues, thereby enhancing transparency and providing users with greater control over the notification process.

This enhancement not only simplifies the process of sending notifications for users but also ensures that the infrastructure can efficiently scale to meet escalating demands, thereby upholding the performance and reliability of communication services.

Resource

Method: POST

URL: https://connect.routee.net/push-notifications/messages


Request Headers

NameTypeDescription
AuthorizationStringBearer {access_token}
Content-Type*Stringapplication/json

Request:

curl --location 'https://connect.routee.net/push-notifications/messages' \
--header 'Authorization: Bearer adf1a590-94ab-4754-884c-6a8e4d172ab8' \
--header 'Content-Type: application/json' \
--data '{
  "implementationId": "64be7af142fe590001a22923",
  "routeeContactId": “12345678”,
  "body": {
    "title": {
      "en": "This is the title of the  notification"
    },
    "text": {
      "en": "This is the message of the  notification"
    },
    "forceLocale": "en"
  },
  "imageUrl": "https://pics.freeicons.io/uploads/ic",
  "android": {
    "clickAction": "OPEN_ACTIVITY_1",
    "icon": "https://pics.freeicons.io/uploads/icons/png/15798659891536125452-512.png",
    "localizedTitle": "LOCALIZATION_TITLE_KEY",
    "localizedText": "LOCALIZATION_TEXT_KEY",
    "ttl": 3600
  },
  "web": {
    "iconUrl": "https://cdn-icons-png.flaticon.com/512/1006/1006771.png",
    "targetUrl": "https://target.url"
  },
  "apn": {
    "localizedTitle": "LOCALIZATION_TITLE_KEY",
    "localizedText": "LOCALIZATION_TEXT_KEY",
    "ttl": 8000
  },
  "data": {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3",
    "key4": "value4"
  },
 "callback": {
    "url": "https://webhook.site/ccd40751-d757-440d-bcdf-549f87faec79"}
}'

Response:

200 OK
{
    "routeeContactId": "64be7af142fe590001a22923"
}

Request Params

NameMandatoryTypeNotes & Validation Checks
implementationIdYesStringThere should be an implementation with the particular id that belongs to the accountId.
Not blank.
routeeContactIdYesStringroutee contact id
bodyNoObjectThe notification's body which contains the following fields:
title;
text;
forceLocale.
body.titleYesObjectThe notification's title.
Map: (Key) NotBlank - Language (ISO 639-1),
(Value) NotBlank.
body.textYesObjectThe notification's text.
Map: (Key) NotBlank - Language (ISO 639-1) ,
(Value) NotBlank.
body.forceLocaleYesStringLocalization settings. Switches body.title and body.text to the selected language.
NotNull, Language (ISO 639-1).
Title and text should contain an entry with forceLocale as their key.
imageUrlNoStringURL that should begin with https://
androidNoObjectDevice-specific parameters (Android).
android.clickActionNoStringThe action associated with a user click on the notification.
android.iconNoStringThe notification's icon.
Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest.
android.localizedTitleNoStringThe key to the title string in the app's string resources to use to localize the title text to the user's current localization.
Example: NOTIFICATION_TITLE
android.localizedTextNoStringThe key to the body string in the app's string resources to use to localize the body text to the user's current localization.
Example: NOTIFICATION_MESSAGE
android.ttlNoNumberIn seconds
Min: 0
Max: 2.419.200
Default: Same as Firebase (current: 2.419.200)
apnNoObjectDevice-specific parameters (iOS).
apn.localizedTitleNoStringThe key for a localized title string. Specify this key instead of the title key to retrieve the title from your app's Localizable.strings files. The value must contain the name of a key in your strings file.
apn.localizedTextNoStringThe key for a localized message string. Use this key, instead of the body key, to retrieve the message text from your app's Localizable.strings file. The value must contain the name of a key in your strings file.
apn.ttlNoNumberIn seconds
Min: 0
Max: 2.419.200 :question_mark:
Default: Same as Firebase (current: 2.419.200)
webNoObjectDevice-specific parameters (web).
web.iconUrlNoStringURL that should begin with https://
web.targetUrlNoStringURL that should begin with https://
dataNoObjectThis parameter specifies the custom key-value pairs of the message's payload.
For example, with data:{"score":"3x1"}:
On Apple platforms, if the message is sent via APNs, it represents the custom data fields. If it is sent via FCM, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.
On Android, this would result in an intent extra named score with the string value 3x1.
The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm").
Values should be string type.
data.keyNoStringNot Blank.
data.valueNoStringNot Blank
callbackUrlNoStringURL that should begin with https://

Extra Validations
Only one should be filled from the below fields (however they can be all null at the same time):

  • android
  • apn
  • web
  • We cannot have mismatching deviceToken type and config (example : if type is ANDROID, we must not have json “web” or “apn” – we can have either “android” or null.
  • The maps of both, title and text, should contain an entry with forceLocale as their key.

Expected Response

Here is the expected response for Web, android and IOS.


NameMandatoryTypeNotes & Validation Checks
trackingDetailsYesMapThe Map which stores information about the tracking IDs of push notifications sent to different device types.
trackingDetails.androidYesListThe List of tracking IDs of android devices.
trackingDetails.webYesListThe List of tracking IDs of web devices.
trackingDetails.iosYesListThe List of tracking IDs of iosdevices.

Example Android Response

200 OK
{
  "trackingDetails": {
    "android": ["6c531a0c-e921,6c531a0c-e921-4636-86b5-dd73f6e5d6c1",
                "6c531a0c-e921,6c531a0c-e921-4636-86b5-dd73f6e5d6c2"],
  }
}

Example Web Response

200 OK
{
  "trackingDetails": {
    "web":     ["6c531a0c-e921,6c531a0c-e921-4636-86b5-dd73f6e5d6c3"],
  }
}

Example IOS Response

200 OK
{
  "trackingDetails": {
    "ios":     ["6c531a0c-e921,6c531a0c-e921-4636-86b5-dd73f6e5d6c3"]
  }
}

Expected Errors


Error StatusError CodeWhenError message
4000101Insufficient Balance"Insufficient balance"
400-"implementationId": empty"implementationId: must not be blank"
4040000"implementationId" : Invalid or doesn't exisit"No implementation found."
4040001"ImplementationId" without credential"Credential with type: FCM does not exist for given implementation"
400-"ttl": less than 0"apn.ttl: must be greater than or equal to 0"
400-"ttl": more than 2419200"android.ttl: must be less than or equal to 2419200"
400-"ttl": Invalid value"android.ttl: invalid value"
400-"deviceToken": "token": empty or null"deviceToken.token: must not be blank"
400-"deviceToken": "type": empty or null"deviceToken.type: invalid value"
400-"data": Value : empty"data[key1].: must not be blank"
400-"data": Empty"data: invalid value"
400-"callbackUrl" invalid"callback.url: must be a valid URL"
400-"body.title.key" Empty or null"body.title[en].: must not be blank"