MoEngage Docs

Data APIs

Data APIs are used to send user data (user properties and events) from your servers to MoEngage.

List of APIs

See the below table for a list of MoEngage APIs.

For our customers in EU Region, please navigate to this table - List of EU APIs.

API Name
Details
Endpoint

User

Use this API to send user properties.

Event

Use this API to send events.

Device

Use this API to send device properties.

Bulk Import

User this API to import data in bulk.

The <APP ID> for your moengage account is available here: (Settings > App Settings > Account Settings > APP ID).

Note: We have updated the List of APIs on 4th December 2018 but we are continuing to support the older APIs as of now. The older APIs listed below will be deprecated soon. We strongly recommend all MoEngage users to migrate to the new APIs listed in the previous table.

API Name
Details
Endpoint

User

Use this API to send user properties.

Event

Use this API to send events.

Device

Use this API to send device properties.

Bulk Import

User this API to import data in bulk.

If you are using the older APIs, app_id is a required param
app_id: Get the APP ID from the MoEngage dashboard under following path: (Settings > App Settings > Account Settings > APP ID).

List of APIs for EU Region

The below table lists the APIs available for EU Region -

API Name
Details
Endpoint

User

Use this API to send user properties.

Event

Use this API to send events.

Device

Use this API to send device properties.

Bulk Import

User this API to import data in bulk.

If you are using the APIs for EU Region, please ensure that you are passing app_id as a parameter.
app_id: Get the APP ID from the MoEngage dashboard under following path: (Settings > App Settings > Account Settings > APP ID).

Required Headers

Authentication

Data APIs use Basic authentication to control access to your data.

Basic authentication sends a Base64-encoded string that contains a username and password for your API requests. username and password are available under following path: (Settings > APIs > DATA API Settings) as shown below.

For first time, hit the Generate Key and then save on Data APIs settings page.
User name - DATA API ID
Password - DATA API KEY

Basic Authentication encodes a 'username:password' using base64 and prepends it with the string 'Basic '. This is passed in the authorization header as follows
{"Authorization": "Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}

To send a request using a client (as Postman), Authentication can be done in following way:

Content-Type Header

To send data to Data APIs, Content-Type header must be set to 'application/json' as follows
{"Content-Type": "application/json"}

MOE-APPKEY Header

To send data via Data APIs, MOE-APPKEY header must be set to <APP ID> which is available here: (Settings > App Settings > Account Settings > APP ID).

Request body

There is a max limit of 100kb per request.

Response

Response will be a json object, on a sucessful call you will receive response as

{"status":"success"}

on failure, response will be

{
  "status":"fail", 
  "error":{ 
    "type": "TypeError", 
    "attribute": "customer_id",
    "message":"expected string"
  }
}

API Limits

The MoEngage Data Import API is designed to handle high volumes of data across our customer base. We enforce API limits to ensure responsible use of the API.

Recommended rate limits of the Data Import APIs are as below -

Events - A single API request (Event / Bulk Import API) can contain one or more than one events. You should maintain a rate limit of 10000 events per minute.

Users - A single API request (User / Bulk Import API) can contain one or more than one user updates. You should maintain a rate limit of 1000 user updates per minute.

Please note that on exceeding the recommended rate limits, there is a possibility that your data processing may get delayed or your account may get blocked.

If you need to exceed the recommended limits or have any questions on the API limits, please contact your Customer Success Manager or send an email to our Support Team at support@moengage.com.

Add/Modify User Information

API to use - User API
This API allows you to create a new user profile (or) update profile data of existing user. It includes customer_id (Unique Identifier of User) and other User Attributes(ex: name, age etc.. ). customer_id will be used to Map Actions and Devices to User.

NOTE: customer_id is essentially the Unique Identifier which is set and passed on from MoEngage SDK as USER_ATTRIBUTE_UNIQUE_ID

customer_id in customer payload is mandatory to identify a user profile.

Signature for a user API request looks like:

POST https://api.moengage.com/v1/customer/<APP ID>

To set name as John for a user with unique id john@example.com and platform android, pass the following payload

{
"type" : "customer",
"customer_id": "john@example.com",
"attributes": {
    "name":"John",
    "platforms" : [{"platform":"ANDROID", "active":"true"}]
    }
}

User attributes list is mentioned below:

  • name (string) - name of the user
  • first_name (string) - first name of the user
  • last_name (string) - last name of the user
  • email (string) - email of the user
  • age (numeric) - age of the user
  • gender (string) - "male" or "female" - case sensitive
  • mobile (string) - phone number of the user
  • geo (array of lat,lng in double) - location of the user for eg. [23.3,37.3]
  • source (string) - acquisition source of the user
  • created_time (numeric - epoch time in seconds) - user created time
  • last_seen (numeric - epoch time in seconds) - user last seen time
  • transactions (numeric) - no.of transactions done by the user
  • revenue (numeric) - LTV of the user
  • platforms (array) - platforms on which the user has interacted with the system. for eg.[{"platform":"ANDROID", "active":"true"},{"platform":"WINDOWS", "active":"true"},{"platform":"IOS", "active":"true"}]

To pass other attributes which are not part of the list, use the key value pairs that you intend to use. for ex. to set the points attribute for the user to 20

{
"type" : "customer",
"customer_id": "john@example.com",
"attributes": {
    "points":20,
    "platforms" : [{"platform":"ANDROID", "active":"true"}]
    }
}

The following keywords are blocked and should not be used as attribute names - "id", "_id", ""

Mandatory fields: customer_id.

Add/Modify Device Information

API to use - Device API
This API allows you to create a new device profile (or) update profile data of existing device. It includes customer_id (Identifier of User), device_id (Identifier of Device) and other Device Attributes(ex: model, brand, os version etc.. ).

NOTE: customer_id is essentially the Unique Identifier which is set and passed on from MoEngage SDK as USER_ATTRIBUTE_UNIQUE_ID

customer_id in device payload is mandatory to map device to user.
platform in device attributes is mandatory to run platform level campaigns.
device_id in device payload is optional and default value is customer_id value. It will be used to update specific device in future.

Signature for a device API request looks like:

POST https://api.moengage.com/v1/device/<APP ID>
{
  "type": "device",
  "customer_id": "john@example.com",
  "device_id" : "96bd03b6-defc-4203-83d3-dc1c73080232",
  "attributes": {
    "model": "iPhone",
    "platform" : "iOS",
    "push_preference" : "true",
    "push_id" : "irBMohQPf_k2QrwP8iRzK3A/0CdLEzAoVGdF65HhH_I",
    "app_version" : "10.1",
    "os_version" : "2.5.4",
    "active" : "true",
    "created_time" : 143383676
  }
}

We defined reserved keywords for some of Device Attributes.

"model"  (string):  Model of Device
"platform" (string): os (ex: iOS)
"push_preference"  (string): is Push Enabled for Device ("true" or "false") 
"push_id" (string): Push Id or Push Token of Device. 
"app_version" : App Version
"os_version" : Os Version
"active" :   Installed status of device ("true" or "false")     
"created_time" : Created Time of Device (Epoch time in seconds)

To pass other attributes which aren't part of the list, use the key value pairs that you intend to use. for ex. to set the brand attribute for the device to Apple

{
  "type": "device",
  "customer_id": "john@example.com",
  "device_id" : "96bd03b6-defc-4203-83d3-dc1c73080232",
  "attributes": {
    "brand": "Apple",
    "platform": "iOS",
    "push_id": "irBMohQPf_k2QrwP8iRzK3A/0CdLEzAoVGdF65HhH_I"
  }
}

The following keywords are blocked and should not be used as attribute names - "id", "_id", ""
Mandatory fields: customer_id, platform and push_id.

User Events Information

API to use - Event API
This API allows you to track actions of a user.

customer_id in event payload is mandatory to map event to user.
device_id in event payload is optional and default value is customer_id value. It will be used to map event to specific device.
platform in event payload is Not Mandatory If you do not pass platform in the event payload, we will set it as unknown on our side automatically.
Please note that you can send the platform value as Android, iOS or web based on the platform on which this event was generated.
If you are unsure about the platform on which this event happened, please send the value as unknown or do not send the value at all. Incorrect platform value will lead to inconsistencies in platform level campaigns.

Signature for event API request looks like:

POST https://api.moengage.com/v1/event/<APP ID>
{
	"type": "event",
	"customer_id": "john@example.com",
	"device_id": "96bd03b6-defc-4203-83d3-dc1c73080232",
	"actions": [{
			"action": "Added to Cart",
			"attributes": {
				"product": "Mobile",
				"color": "white",
				"Brand": "Apple"
			},
			"platform": "iOS",
			"app_version": "1.2.3",
			"current_time": 1433837969,
			"user_time_zone_offset": 19800
		},
		{
			"action": "Purchase",
			"attributes": {
				"product": "MacBook Air",
				"Brand": "Apple"
			},
			"platform": "web",
			"app_version": "1.2.3",
			"current_time": 1433837969,
			"user_time_zone_offset": 19800
		}
	]
}

Please note that we were accepting current_time and user_time earlier and the difference between user_time and current_time was used to calculate the timezone in which the even happened.

Currently, we are supporting 3 combinations - user_time and user_time_zone_offset, current_time and user_time_zone_offset and user_time and current_time to calculate the timezone of the event.

user_time_zone_offset should have a value in seconds which can be between -54000 to 54000. For example, for IST (UTC+0530), "user_time_zone_offset" will be 19800

We defined reserved keywords for Event Name and Event Attributes.

"actions" (array) : Array of Actions or events
"action"  (string): Name of Action or Event
"attributes" (json object) - Event Attributes
"platform" (string) - os 
"app_version" (string or numeric) - App Version
"user_time" (Epoch Time in seconds) - User Time
"current_time" (Epoch Time in seconds) - GMT time of User Time
"user_time_zone_offset" (integer in seconds) - offset to determine the timezone in which the event was performed

The following keywords are blocked and should not be used as event attribute names - "id", "_id", ""

Mandatory fields: customer_id and action.

Bulk Import

API to use - Transition API
This API allows you to import “user , device and event requests” in a single batch.

Signature for transition API request looks like:

POST https://api.moengage.com/v1/transition/<APP ID>
{
	"type": "transition",
	"elements": [{
			"type": "customer",
			"customer_id": "john@example.com",
			"attributes": {
				"name": "John",
				"platforms": [{
					"platform": "ANDROID",
					"active": "true"
				}]
			}
		},
		{
			"type": "device",
			"customer_id": "john@example.com",
			"device_id": "96bd03b6-defc-4203-83d3-dc1c73080232",
			"attributes": {
				"brand": "Apple",
				"platform": "iOS",
				"push_id": "irBMohQPf_k2QrwP8iRzK3A/0CdLEzAoVGdF65HhH_I"
			}
		},
		{
			"type": "event",
			"customer_id": "john@example.com",
			"device_id": "96bd03b6-defc-4203-83d3-dc1c73080232",
			"actions": [{
					"action": "Added to Cart",
					"attributes": {
						"product": "Mobile",
						"color": "white",
						"Brand": "Apple"
					},
					"platform": "iOS",
					"app_version": "1.2.3",
					"current_time": 1433837969,
					"user_time_zone_offset": 19800
				},
				{
					"action": "Purchase",
					"attributes": {
						"product": "MacBook Air",
						"Brand": "Apple"
					},
					"platform": "iOS",
					"app_version": "1.2.3",
					"current_time": 1433837969,
					"user_time_zone_offset": 19800
				}
			]
		}
	]
}

Data APIs


Data APIs are used to send user data (user properties and events) from your servers to MoEngage.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.