Send Push Notification
This API creates and sends a push notification campaign. You can use this API to create campaigns (targeting all users or a group of users) to send notifications, target a single user using a unique user attribute, and personalize payload for each user.
Rate Limit
The rate limit is 10,000 requests per minute.Authentication
A signature is required to verify whether the client is authorized to make the API call. It is generated from a hash of the campaign name, app ID, and API key. MoEngage uses the SHA 256 method to generate this hash. Python code is used to generate the signature for your test account, and use your account’s app_id.- On the left navigation menu in the MoEngage dashboard, go to Settings > Account > APIs.
- Copy the following details:
- app_id: Under Workspace ID (earlier app_id), click the copy icon to copy the app-id.
- api_key: In the API keys section, click the copy icon in the Push tile to copy the API key.
- campaign_name: Ensure the campaign name matches the one used in the request body.
Generating Signature
Python code to generate the signature for your test account, use the app_id that is appropriate for your account.- Python 3.XX
- Python 2.XX
Body
The complete configuration for the push campaign.
This is the Workspace ID of your MoEngage account that must be passed with the request. You can find it in the MoEngage dashboard at Settings > Account > APIs > Workspace ID (earlier app id). MoEngage recommends that you test API integration in the Test Environment. The App ID for TEST ACCOUNT is suffixed with _DEBUG.
This field denotes the campaign name. The campaign name should be unique for All Users and Custom Segment campaigns. Note:
- API automatically creates a campaign with the given name. You need not create a campaign from the dashboard to use the name.
- For User type targetAudience API requests, reuse this campaign name for requests that should be clubbed in the same campaign.
5This field denotes the signature that is required to verify whether the client is authorized to make the API call. For more information, refer to Generate Authentication Signature.
This field denotes the platform devices that are targeted by your campaign. The Push API allows you to target users on Android, iOS, and Web platforms. You can target one or more platforms. If you want to send Web (Chrome) push notifications through the API, you should choose Web as the platform.
ANDROID, IOS, WEB This field denotes the target segment for the campaign. Supported values are:
- All Users: Pass this value to target all users of your App/Website.
- Custom Segment: Pass this value to target pre-created user segments. Custom segments can be created using the MoEngage dashboard or custom segment API. Note that the custom segment name should exactly match the name of the target segment.
- User: Pass this value to target a user with an attribute. It will target a maximum of 100 users of the associated targetUserAttributes definition.
All Users, Custom Segment, User This field helps decide when the campaign should be sent.
ASAP
// send campaign asap
"campaignDelivery": {
"type": "soon"
}Schedule Later
"campaignDelivery": {
"type": "later",
"date": "11/07/2016",
"time": "04:33 PM"
}Recurring Campaigns
"campaignDelivery": {
"type": "periodic",
"endDate": "11/07/2016",
"time": "04:55 PM",
"timezone": "Asia/Calcutta",
"repeatAfter": "1" // campaign will be recurring sent after every 1 day.
}Used to add more context to campaigns. Context can be descriptive names or campaign themes such as onboarding, retention, country, and all users. Tags can also be used to filter campaigns or identify the behaviors of users who received these campaigns. The list of tags should be passed in this field.
For example,
“campaignTags“ : [“Transactional“, “Accounts“]The value of this key is used to indicate the intention of an API request. The default value is push.
Required if targetAudience is 'Custom Segment'.
This object contains the target user attribute details. Note:
- This value is required when the targetAudience value is User.
- For API requests where the target audience is a specific user, if a campaign with the given name already exists, existing campaign data corresponding to the given name will be used to send notifications.
- Any edits in other parts of campaign data except payload within the API request parameters will be ignored.
- If any changes are required in the campaign data, change the campaign name in the API request to create a new campaign.
This object contains the conversion goals details. This field denotes the event attribute filters. It contains the following elements:
- name: Event attribute name. This is mandatory.
- filter: Event attribute filter operator. This is mandatory.
- value: Event attribute filter value.
- type: Event attribute data type. This is mandatory.
Single Conversion Goal
"conversionGoals": [
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "is",
"value": "10089712",
"type": "string"
}
}
]Multiple Conversion Goals
"conversionGoals": [
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "is",
"value": "10089712",
"type": "string"
}
},
{
"name": "Order Placed",
"eventName": "OrderSuccess",
"attrs": {
"name": "product_price",
"filter": "is equal to",
"value": 999,
"type": "numeric"
}
}
]Without Event Attribute Filter
{
"name": "Added To Cart",
"eventName": "AddedTocart"
}With String Event Attribute Filter
With "is" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "is",
"value": "10089712",
"type": "string"
}
}With "is not" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "is not",
"value": "10089712",
"type": "string"
}
}With "contains" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "contains",
"value": "10089712",
"type": "string"
}
}With "does not contain" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "does not contain",
"value": "10089712",
"type": "string"
}
}With "starts with" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "starts with",
"value": "10089712",
"type": "string"
}
}With "does not start with" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "does not start with",
"value": "10089712",
"type": "string"
}
}With "ends with" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "ends with",
"value": "10089712",
"type": "string"
}
}With "does not end with" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "does not end with",
"value": "10089712",
"type": "string"
}
}With "in the following" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "in the following",
"value": ["10089711", "10089712", "10089713"],
"type": "string"
}
}With "not in the following" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "not in the following",
"value": ["10089711", "10089712", "10089713"],
"type": "string"
}
}With "exists" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "exists",
"type": "string"
}
}With "does not exist" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_sku",
"filter": "does not exist",
"type": "string"
}
}With Numeric/Double Event Attribute Filter
With "is equal to" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "is equal to",
"value": 999,
"type": "numeric"
}
}With "is not equal to" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "is not equal to",
"value": 999,
"type": "numeric"
}
}With "is between" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "is between",
"value": "899,999",
"type": "numeric"
}
}With "is not between" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "is not between",
"value": "899,999",
"type": "numeric"
}
}With "is greater than" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "is greater than",
"value": 999,
"type": "numeric"
}
}With "is less than" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "is less than",
"value": 999,
"type": "numeric"
}
}With "exists" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "exists",
"type": "numeric"
}
}With "does not exist" operator:
{
"name": "Added To Cart",
"eventName": "AddedTocart",
"attrs": {
"name": "product_price",
"filter": "does not exist",
"type": "numeric"
}
}5This object contains information about advanced settings. For more information, refer to Advanced Settings.
Response
Request received. The status in the response body indicates whether it was successfully processed or failed. Possible failures include:
- Invalid Request Type
- Invalid appId / appId not present
- Campaign Name too short (must be >= 5 chars) / Campaign name missing
- Request limit exceeded
- Signature missing or not verified
- Duplicate campaign name
- Key not of Type List or Value not allowed
- Error parsing parameters