Prerequisites
Function
The Campaign API allows an external application to trigger a push notification for all subscribers or a segment of subscribers for a single website.
Note: The Campaign API is intended to send to many subscribers at one time. Please see Transactional API Documentation to send a notification to a single subscriber.
Endpoint
POST https://api.pushnami.com/api/push/v2/campaign
Requirements
Parameter | Required? | Description | Sample |
---|---|---|---|
headers.authorization |
Yes | API Token | eyJ2... |
payload.website |
Yes | Your Website URL as it appears on your Pushnami “All Websites” Page (string ) |
https://yourdomain.com |
payload.title |
Yes | Notification Title (string ) |
Sample-Title |
payload.message |
Yes | Notification Message (string ) |
Sample-Message |
payload.link |
Yes | Notification Link(url ) |
https://pushnami.com |
payload.icon |
No | Accessible image URL for the Notification Icon (url ) |
https://yourdomain.com/yourimage.png |
payload.schedule |
No | JavaScript date string (ex: ISOString) or timestamp to schedule the campaign (date ) |
2017-08-04T20:14:33.862Z |
payload.external |
No | External API address to retrieve campaign payload (string ) |
https://yourdomain.com/external-payload |
payload.externalerrors |
No | When payload.external is set and payload.externalerrors is true, this endpoint will send the notification as-is in the case of external push failure. (boolean ) |
true |
payload.ndelay |
No | Segment only subscribers who subscribed at least n minutes ago. (number ) |
2200 |
payload.segment |
No | An array of segmentation rules which use AND logic (array ) |
See Segmentation Rules |
payload.subwaterfall |
No | Definition for a subcampaign object (object ) |
See SubWaterfall Options |
Segmentation Rules
Parameter | Required? | Description | Sample |
---|---|---|---|
variable |
Yes | Subscriber variable name to segment by (string ) |
dcountry |
operator |
Yes | Operator to check, (string ) Valid values: "different", "!=", "<", "<=", "before", ">", "before n min ago", "after n min ago", ">=", "after", "same day", "same hour", "exists", "not exists", "contains", "equals", "==" |
different |
value |
Yes | Value to check subscriber variable against (string ) |
GB |
Subwaterfall Options
Parameter | Required? | Description | Sample |
---|---|---|---|
interval |
Yes | Number of minutes after campaign before sending subcampaign(number ) |
5 |
enabled |
Yes | Determines if subcampaign is enabled, (boolean ) |
true |
title |
Yes | Notification title (string ) |
Sub-Title |
Message |
Yes | Notification Message (string ) |
Sub-Message |
destinationLink |
Yes | Notification Link (url ) |
https://pushnami.com |
extIcon |
No | Accessible image URL for the Notification Icon (url ) |
https://yourdomain.com/yourimage.png |
externalpush |
No | External API address to retrieve campaign payload (string ) |
https://yourdomain.com/external-payload |
externalpusherrors |
No | When externalpush is set and externalpusherrors is true, this endpoint will send the notification as-is in the case of external push failure. (boolean ) |
true |
qsegment |
No | Optional segment rule array (array ) |
See Segmentation Rules |
Sample Request - Basic Request
curl -X POST \
https://api.pushnami.com/api/push/v2/campaign \
-H 'authorization: <Your API Token>' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"website": "<Your Website Url>",
"title": "Sample Title",
"message": "Sample Message",
"link": "https://pushnami.com",
"icon": "https://media.licdn.com/mpr/mpr/shrink_200_200/AAEAAQAAAAAAAAxIAAAAJGMzYjhkOGY5LTFlZTgtNGNlOC04NzM1LTgyNGNjNWU4NTVlOA.png"
}'
Sample Request - Scheduled Request
curl -X POST \
https://api.pushnami.com/api/push/v2/campaign \
-H 'authorization: <Your API Token>' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"website": "<Your Website Url>",
"title": "Sample Title",
"message": "Sample Message",
"link": "https://pushnami.com",
"icon": "https://media.licdn.com/mpr/mpr/shrink_200_200/AAEAAQAAAAAAAAxIAAAAJGMzYjhkOGY5LTFlZTgtNGNlOC04NzM1LTgyNGNjNWU4NTVlOA.png",
"schedule": "2017-08-04T20:49:16.983Z"
}'
Sample Request - Sub Campaign Request
curl -X POST \
https://api.pushnami.com/api/push/v2/campaign \
-H 'authorization: <Your API Token>' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"website": "<Your Website Url>",
"title": "Sample Title",
"message": "Sample Message",
"link": "https://pushnami.com",
"icon": "https://media.licdn.com/mpr/mpr/shrink_200_200/AAEAAQAAAAAAAAxIAAAAJGMzYjhkOGY5LTFlZTgtNGNlOC04NzM1LTgyNGNjNWU4NTVlOA.png",
"subwaterfall": {
"interval": 0,
"enabled": true,
"title": "Test Sub Campaign",
"message": "Test Sub Campaign Message",
"destinationLink": "https://pushnami.com"
}
}'
Response Codes
Response | Indication |
---|---|
Code: 200 <br>OK |
Request was received successfully |
Code: 400 {"statusCode": 400,"error": "Bad Request","message": "Invalid request payload JSON format"} |
Request payload format incorrect, check that the JSON payload is valid |
Code: 401 {"statusCode": 401,"error": "Unauthorized","message": "invalid token"} |
Request not processed, check that the API token provided is valid and belongs to the account and that the website url is provided as it appears on the Pushnami “All Websites” page. |