Test Push notifications before sending

These methods allow you to verify the destination address for Push notification messages. You can also use these methods to identify the number of subscribers that will be targeted according to the provided parameters.

Sending Push messages is usually a simple task but it can get more complicated when working with complex destination addresses or targeting users in multiple segments through a single API call.

In order to avoid sending a notification to the wrong segment we have created a method where you can simulate a Push notification send request and observe the affected number of recipient devices in the response without sending an actual notification. If the result is satisfactory you can proceed to sending actual notifications, knowing exactly what to expect.

NOTE

You can implement this method in your system to show a preview of the target audience number, raise an alarm, or activate a fail-safe mechanism if the number greatly exceeds the average notification volumes.

Methods:

Simple Push notifications

Use this method to verify your requests while sending PUSH messages.

Request format

Parameter Type Description
from string Push Application Code you are using to send messages.
to object Recipient destination address.
text string Text of the message that will be sent.
sendAt datetime Used to send PUSH notifications at scheduled time.
customPayload object Additional JSON data that can be delivered with the PUSH message.
notificationOptions object JSON object that contains notification options.

Request example:

POST /push/2/message/single/test HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
    "from": "d417d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
    "to": {
        "externalUserId": "customer_21234"
    },
    "text": "This Message was sent by targeting exact externalUserId.",
    "notificationOptions": {
      "soundEnabled": false,
      "badge": "1"
    },
    "customPayload":{
      "targetUrl": "www.someDomain.com",
      "someData": "someData"
   }
}	
  

Response:

{
  "bulks": [
    {
      "to": {
         "externalUserId": "customer_21234"
      },
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 26,
        "name": "PENDING_ACCEPTED",
        "description": "Message accepted, pending for delivery"
      },
      "messageCount": 2
    }
  ]
}	
  

If successful, response header HTTP status code will be 200 OK.

If you try to send the message without authorization, you will receive an 401 Unauthorized error.

If the request is incorrectly formatted the HTTP status code will be 400 Bad Request.

Response format

Parameter Type Description
to object Recipient destination address.
status object Message status.
messageCount integer Number of recipients for targeted segment.

Status:

Parameter Type Description
groupId int Status group ID.
groupName String Status group name.
id int Status ID.
name String Status name.
description String Human-readable description of the status.

Bulk Push notifications

Use this method to verify your requests while sending bulk Push messages.

Request format

Parameter Type Description
messages object Collection of Push notifications. Each message in the collection is completely independent. Different values may be used for each notification, such as “sender application” or “message text”.

Messages:

Parameter Type Description
from string PushApplication Code you are using to send messages.
to object Recipient destination address.|.
text string Text of the message that will be sent.
sendAt datetime Used to send Push notifications at scheduled time.
customPayload object Additional JSON data that can be delivered with the Push message.
notificationOptions object JSON object that contains notification options..

Request example:

POST /push/2/message/multi/test HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
Accept: application/json

{
	"messages": [
		{
    		"from": "d417d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
    		"to": {
        		"externalUserId": "customer_21234"
    		},
    		"text": "This message can be one of many in this message collection.",
    		"notificationOptions": {
    			"soundEnabled": false,
    			"badge": "1"
    		},
	  		"customPaylod":{
  				"targetUrl": "www.someDomain.com",
	 				"someData": "someData"
	 		}
		},
		{
		    "from": "c297d38814740a23f50b5c876e226445-0f700564-abbf-4b5b-beae-86a4ef410904",
		    "to": {
        		"externalUserId": "customer_113456"
		    },
		    "text": "This is the second message in this collection.",
		    "notificationOptions": {
		    	"soundEnabled": false
		    }
		}
	]
}	
  

Response:

{
  "bulks": [
    {
      "to": {
        "externalUserId": "customer_21234"
      },
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 26,
        "name": "PENDING_ACCEPTED",
        "description": "Message accepted, pending for delivery"
      },
      "messageCount": 2
    },
    {
      "to": {
        "externalUserId": "customer_113456"
      },
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 26,
        "name": "PENDING_ACCEPTED",
        "description": "Message accepted, pending for delivery"
      },
      "messageCount": 2
    }
  ]
}	
  

If successful, the response header HTTP status code will be 200 OK. If you try to send the message without authorization, you will receive a 401 Unauthorized error. If the request is incorrectly formatted the HTTP status code will be 400 Bad Request.

Response format

Parameter Type Description
bulks object Collection of bulks of sent messages.

Bulk:

Parameter Type Description
to object Recipient destination address.
status object Message status.
messageCount integer Number of recipients for targeted segment.

Status:

Parameter Type Description
groupId int Status group ID.
groupName String Status group name.
id int Status ID.
name String Status name.
description String Human-readable description of the status.