MoEngage Docs

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Push API (V1)

Push API can be used to send push to your users individually, like targeting based on the activity they did in the past or targeting based on the unique attributes of the user like a unique user Id or email or mobile number. If you would like to target multiple users, you can use the campaigns feature provided on the dashboard, if not you can target the audience with General Push Campaigns through this api.

How to make the API call

API call is a POST method, and the end URL is mentioned below.

https://pushapi.moengage.com/v1/transaction/sendpush

Headers for the call

'Content-Type':'application/json'

Response from API call

Response will be a json object. On the successful call you will receive response as below. Success response only signifies that your campaign request was valid and has been accepted. It does not represent that the campaign is sent successfully.

{"status":"success","msg":""}

and if failed then response will be

{"status":"fail","msg":"reason why it failed"}

Parameters necessary for the API call should be passed as JSON object string as part of request body.

Required parameters

App Id : APP ID provided by MoEngage to identify the app, you can find it under Settings -> Transactional Push Settings on MoEngage Dashboard.

Campaign Name : Used to view the campaign statistics on MoEngage dashboard. Campaign name has to be unique as per the below mentioned scenarios:

  • All users - Unique
  • Custom Segments - Unique
  • User Level - Unique if all the API requests belong to different campaign type; Same if they belong to same campaign type for eg. All the push messages related to billing can have a campaign name as “Billing Campaign” and all the push messages related to order delivery can have the campaign name as “Orders Campaign”. As a result one would be able to see aggregated stats for one campaign type under one campaign name.

NOTE : API automatically creates campaign with given name, do not create campaign from dashboard and then use while hitting API.

Signature : To verify the authenticity of the caller.This will be combination of Campaign Name,Appid and SecretKey.

Signature = sha256(AppId+’|’+Campaign Name +'|’+MOE_SECRET_KEY)
Contact MoEngage for secret key.
Example in Python code ( each app have different secret key):

appId = "MAZW51234N1IMMSH5HKBHB" (Please refer to Required parameters section.)

CampaignName = "TEST"

MOE_SECRET_KEY = "S3pVzjBF9use" (This is the sample key, production key will be provided by MoEngage Team)

Signature = sha256(appId+'|'+CampaignName+'|'+MOE_SECRET_KEY).hexdigest()

Generated Signature: 
7008233eb3f0149a9327c5a32bfe41e2c334dc87571179a2528110618ca11279

Target Audience : Target segment for the campaign. It can have one of the following values

All Users
Custom Segment : these are the set of users who are part of the predefined segments mentioned on the dashboard. Please use the dashboard to manage custom segments. Also please make sure the name matches the name in the dashboard
User - target is just one single user.

Custom Segment Name : ( Mandatory if Target Audience is Custom Segment else optional ) Name of the custom segment as per defined on the dashboard.

Target User Attributes : In case the target audience is User, send the following parameters to find the user

Attribute : name of the unique attribute
for unique id use - USER_ATTRIBUTE_UNIQUE_ID
for email use  - USER_ATTRIBUTE_USER_EMAIL
for mobile number use - USER_ATTRIBUTE_USER_MOBILE
for Google Advertising identifier - MOE_GAID
for iOS Identifier for advertising - ADVERTISING_IDENTIFIER
for device push token - PUSH_ID ( same key is used for android gcmId, iOS push token and windows channel uri)

Comparison Parameter : 'is' // currently we support only this as Comparison Parameter

Attribute Value : value of the attribute

Ignore FC : Flag to ignore Frequency cap settings on dashboard for Transaction API .

"1" or "0"
"1" Means it will bypass Frequency capping set using dashboard and will sent transaction push all the time.
"0" Means it will apply the Frequency cap set on dashboard and will not send the notification once limit is reached.

Note: While testing your API, ensure that you set this flag as "1" else you might not receive few notifications.

Campaign Type : Campaign Type can have the following values

1.General Push

Campaign SubType : General campaign can have the following sub types and can be one of the following values

1.General
2.Image
3.Coupon
4.Rich Landing - available only in Android

Resource : resources that are necessary to define the look and feel of the campaign

Image Url : url for the image that should be shown as part of the push notification - Available only in Android

Coupon Code : coupon code that is part of the campaign/push

Message Title : Title for the push notification [Android/Windows Only]

Message Body : Message for the push notification

Screen Name : screen to which the user should be navigated to after clicking on the push notification. Each platform handles different ways of communicating the screen names. Each OS can have the following params.

Please Note : Append .xaml to ScreenName for Windows for eg. /Views/HomePage.xaml

Name - Unique Name to identify screen for different platform.

Action - Specify if you want to take user to some url or particular screen, it can have one of the 2 values

Deep Link - use this to take the user to a deep linking url

Screen - use this to take the user to a screen in the app

Deep Linking Url - url that the user has to be taken to, could be rich landing page url too

Key Value Pairs -  Extra key value pairs that are needed to navigate to the right screen.

Conversion Goal - Conversion goal is used to measure the performance of the campaign, It is based on an event tracked in the application.

Goal - Event/Action name

Attrs - Goal attributes. For ex. goal is ‘Purchase’ and Attr can be like ‘Product is Samsung S4’

Name - Name of attribute

Filter - is / contains / starts with

Value - Value of attribute

Type - String/Numeric

Schedule Time : In order to trigger campaign at specific time in future,please provide GMT epoch time in seconds. for eg. to send push on - 6th May 2015 12:43:48 GMT , pass the value as 1430916228. Don’t use this parameter if the push has to be sent immediately. Applicable only for campaigns targeting All Users & Custom Segments.

TTL(Time To Live) : Push Services(GCM/APNS/MPNS) will retry for ttl (seconds) until message is delivered to user, send ‘0’ if not applicable or 86400 for 24 hours . After TTL has expired, push notification will not be shown to the user.

Sample Json Strucure

{
     "App Id":"", (compulsory )
     "Campaign Name":"Unique Campaign Name", (compulsory)
     "Target Audience":"All Users / Custom Segment / User", (compulsory)
     "Signature":"Signature to Verify Authenticity of App" ( Compulsory)
     "Target User Attributes":{ ( optional)
             "Attribute":"",
             "Comparison Parameter":"",
             "Attribute Value":""
     },
     "Campaign Type":"General Push"/"In App"/ ( Compulsory )
     "Campaign SubType":"General/Coupon/Image/Rich Landing", ( Compulsory )
     "Resources":{
             "Image Url":"", ( optional )
             "Coupon Code":"", ( optional )
             "Coupon Code Type":"", (generic CouponCode/ unique Coupon Code) (default generic)(optional)
             "Message Title":"", ( optional, ideally should be passed, would be shown in notification, by default we will show your app name)
             "Message Body":"", ( compulsory)
             "Screen Name":{
                     "iOS":{ ( Compulsory,if you want to target iOS user)
                             
                            "Action":"", (‘Screen’ or ‘Deep Link’ as value depending upon your navigation type)
       "Name":"", ( use when choosing 'Screen' as Action , optional if you are providing ‘Deep Link’as Action)
                             "Deep Linking Url":"", ( use when choosing 'Deep Link' as Action , optional if you are providing ‘Screen’ as Action)
                             "Key Value Pairs":{
                                     "k1":"v1",
                                     "k2":"v2"
                             }
                     },
                     "Android":{ ( Compulsory,if you want to target Android user)
                             
                             "Action":"",(‘Screen’ or ‘Deep Link’ as value)
                              "Name":"", ( use when choosing 'Screen' as Action , optional if you are providing ‘Deep Link’as Action)  
                             "Deep Linking Url":"",( use when choosing 'Deep Link' as Action , optional if you are providing ‘Screen’ as Action)
                             "Key Value Pairs":{
                                     "k1":"v1",
                                     "k2":"v2"
                             }
                     },
                     "Windows":{ (Compulsory,if you want to target windows user as well)
                             
                             "Action":"", (‘Screen’ or ‘Deep Link’ as value)
                             "Name":"", ( use when choosing 'Screen' as Action , optional if you are providing ‘Deep Link’as Action)  
                             "Deep Linking Url":"",( use when choosing 'Deep Link' as Action , optional if you are providing ‘Screen’ as Action)
                             "Key Value Pairs":{
                                     "k1":"v1",
                                     "k2":"v2"
                             }
                     }
             }
     },
     "Conversion Goal":{ ( compulsory)
             "Goal":"", ( compulsory)
             "Attrs":{ ( optional) [can be sent only selected values]
                     "Name":"",
                     "Filter":"",
                     "Value":""
                     "type":""
             }
     },
     "TTL": ( optional, default no ttl )
     }

Sample Json for targeting all users with General Push Campaign

{
 "Campaign Type": "General Push",
 "App Id": "MAZW5N1IMMSH5H67C3T9KBHB",
 "TTL": 86400,
 "Schedule Time": "",
 "Campaign SubType": "General",
 "Campaign Name": "Push Campaign Test Case",
 "Conversion Goal": {
     "Goal": "AddedToCart",
     "Attrs": {
         "Filter": "is",
         "Name": "Payment",
         "Value": "Cash"
     }
 },
 "Signature": "3c9cba5d313e0c529147a473061a2ac062bed3d3596c52bc394adc044a4da4f6",
 "Target Audience": "All Users",
 "Resources": {
     "Message Body": "Transaction API campaign creation from test case",
     "Message Title": "Offer",
     "Screen Name": {
         "Windows": {
             "Action": "Screen",
             "Name": "HomePage.xaml",
             "Deep Linking Url": "",
             "Key Value Pairs": {
                 "k2": "v2",
                 "k1": "v1"
             }
            
         },
         "Android": {
             "Action": "Screen",
             "Name": "com.moengage.demoapp.ConfigActivity",
             "Deep Linking Url": "",
             "Key Value Pairs": {
                 "k2": "v2",
                 "k1": "v1"
             }
             
         },
         "iOS": {
             "Action": "Screen",
              "Name": "HomePage",
             "Deep Linking Url": "",
             "Key Value Pairs": {
                 "k2": "v2",
                 "k1": "v1"
             }
             
         }
     }
 }
 }

Sample Json for Push Message with Coupon Code

{
    "App Id": "MAZW5N1IMMSHs5H67C3T9KBHB",
    "Signature": "1bfb0bf188s96c45d8c0a4706de709c0b56232f30aeb7ec6cb9ac9cd6b8ce3adc",
    "Campaign Name": "API_Test_3",
    "Target Audience": "All Users",
    "Campaign Type": "General Push",
    "Campaign SubType": "Coupon",
    "Resources": {
        "Coupon Code": "HappyShopping",
        "Message Title": "Happy Shopping",
        "Message Body": "Sale.Hurry!",
        "Screen Name": {
            "iOS": {
                "Name": "Product Page",
                "Action": "Screen",
                "Deep Linking Url": "",
                "Key Value Pairs": {
                    "k1": "v1",
                    "k2": "v2"
                }
            },
            "Android": {
                "Name": "com.moengage.demoapp.ConfigActivity",
                "Action": "Screen",
                "Deep Linking Url": "",
                "Key Value Pairs": {
                    "k1": "v1",
                    "k2": "v2"
                }
            },
            "Windows": {
                "Name": "ProductPage.xaml",
                "Action": "Screen",
                "Deep Linking Url": "",
                "Key Value Pairs": {
                    "k1": "v1",
                    "k2": "v2"
                }
            }
        }
    },
    "Conversion Goal": {
        "Goal": "AddToCart",
        "Attrs": {
            "Name": "Product",
            "Filter": "contains",
            "Value": "Mobile"
        }
    }
}

Sample Json for Push Message with Image

{
  "App Id": "MAZW5N1IMMSH5H67C3sT9KBHB",
  "Campaign Name": "API_Test_2",
  "Target Audience": "All Users",
  "Signature": "5d90aa8524c1f65f8see221368ebe3a1ff5a942ec330e5647d46726507e2da495",
  "Campaign Type": "General Push",
  "Campaign SubType": "Image",
  "Resources": {
      "Image Url": "http://www.moengage.com//static/img/segmentation_with_ipad.png",
      "Message Title": "Limited Offer",
      "Message Body": "Hurry",
      "Screen Name": {
          "iOS": {
              "Name": "HomePage",
              "Action": "Screen",
              "Deep Linking Url": "",
              "Key Value Pairs": {
                  "k1": "v1",
                  "k2": "v2"
              }
          },
          "Android": {
              "Name": "com.moengage.demoapp.ConfigActivity",
              "Action": "Screen",
              "Deep Linking Url": "",
              "Key Value Pairs": {
                  "k1": "v1",
                  "k2": "v2"
              }
          },
          "Windows": {
              "Name": "HomePage.xaml",
              "Action": "Screen",
              "Deep Linking Url": "",
              "Key Value Pairs": {
                  "k1": "v1",
                  "k2": "v2"
              }
          }
      }
  },
  "Conversion Goal": {
      "Goal": "AddedToCart",
      "Attrs": {
          "Name": "",
          "Filter": "",
          "Value": ""
      }
  }
  }

Sample Json for Push Message with Rich Landing Page

{
 "App Id": "MAZW5N1IMMsSH5H67C3T9KBHB",
 "Campaign Name": "API_Test_1",
 "Target Audience": "All Users",
 "Signature": "6bfee704de29acf823a0138c51e25ffcsssse3ff145921a10c99a76373f8604211c4",
 "Campaign Type": "General Push",
 "Campaign SubType": "Rich Landing",
 "Resources": {
     "Message Title": "Hi",
     "Message Body": "Hello",
     "Screen Name": {
         "iOS": {
             "Name": "",
             "Action": "Deep Link",
             "Deep Linking Url": "http://www.moengage.com",
             "Key Value Pairs": {
                 "k1": "v1",
                 "k2": "v2"
             }
         },
         "Android": {
             "Name": "",
             "Action": "Deep Link",
             "Deep Linking Url": "http://www.moengage.com",
             "Key Value Pairs": {
                 "k1": "v1",
                 "k2": "v2"
             }
         },
         "Windows": {
             "Name": "",
             "Action": "Deep Link",
             "Deep Linking Url": "http://www.moengage.com",
             "Key Value Pairs": {
                 "k1": "v1",
                 "k2": "v2"
             }
         }
     }
 },
 "Conversion Goal": {
     "Goal": "AddedToCart",
     "Attrs": {
         "Name": "",
         "Filter": "",
         "Value": ""
     }
 }
 }

Sample Json to target specfic User with Push Message

{
 "App Id": "MAZW5N1IMMSH5H67C3T9KBHB",
 "Campaign Name": "Api_Test",
 "Target Audience": "User",
 "Signature": "9e2412c37531fe305ea1cc2df9ebssaeadd444816b79418bf4f147e0e5cb552691faf2",
 "Target User Attributes": {
     "Attribute": "USER_ATTRIBUTE_UNIQUE_ID",
     "Comparison Parameter": "is",
     "Attribute Value": "MKskysKsh=="
 },
 "Campaign Type": "General Push",
 "Campaign SubType": "General",
 "Resources": {
     "Message Title": "Test For API",
     "Message Body": "Test For API",
     "Screen Name": {
         "iOS": {
             "Name": "HomePage",
             "Action": "Screen",
             "Deep Linking Url": "",
             "Key Value Pairs": {
                 "k1": "v1",
                 "k2": "v2"
             }
         },
         "Android": {
             "Name": "com.moengage.addon.ubox.UnifiedInboxActivity",
             "Action": "Screen",
             "Deep Linking Url": "",
             "Key Value Pairs": {
                 "k1": "v1",
                 "k2": "v2"
             }
         },
         "Windows": {
             "Name": "/View/HomeScreen.xaml",
             "Action": "Screen",
             "Deep Linking Url": "",
             "Key Value Pairs": {
                 "k1": "v1",
                 "k2": "v2"
             }
         }
     }
 },
 "Conversion Goal": {
     "Goal": "AddedToCart",
     "Attrs": {
         "Name": "",
         "Filter": "",
         "Value": "",
         "type": ""
     }
 },
 "TTL": 86400
 }

Push API (V1)