The Sample Moe Developer Hub

Welcome to the Sample Moe developer hub. You'll find comprehensive guides and documentation to help you start working with Sample Moe as quickly as possible, as well as support if you get stuck. Let's jump right in!

Data API

Data API allow you to send data from an unsupported platform, or if you need to track information that comes from outside your mobile app.

List of APIs

Required Parameters

*DATA API ID* : Unique Id provided by MoEngage to identify the app. Replace <DATA API ID> with DATA API ID found under settings -> APIs on MoEngage dashboard.

Authentication

Authentication: Basic Authentication - username and password required for basic authentication are available under Settings - DATA API Settings as shown below. For first time, hit the Generate Key and then save.
User name - Data API ID
Password - Data API Key

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

Request Body

Request Body is JSON, content of the request varies with API and the kind of data transition. There is a 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"
	}
}

Add/Modify User Information

API to use - User API
This API is used to set Unique Identifier of User (customer_id) and other User Attributes(ex: name, age etc.. ). ‘customer_id’ and 'platform' in attributes is mandatory and 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

Signature for a user API request looks like:

POST https://api.moengage.com/v1/customer?app_id=<DATA API ID>

To set name as John for a user with unique id 12345 and platform android, pass the following payload

{
"type" : "customer",
"customer_id": "12345",
"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": "12345",
"attributes": {
    "points":20,
  	"platforms" : [{"platform":"ANDROID", "active":"true"}]
    }
}

Mandatory Attributes: customer_id and platforms.

Add/Modify Device Information

API to use - Device API
This API is used to Define Unique Identifier of Device (default device_id is customer_id) and Device Attributes (ex: push_id, platform etc..).

Signature for a device API request looks like:

POST https://api.moengage.com/v1/device?app_id=<DATA API ID>
{
	"type": "device",
 	"customer_id": "525689553535239acbfe",
 	"device_id" : "12345",
 	"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": "525689553535239acbfe",
 	"device_id" : "12345",
 	"attributes": {
  	"brand": "Apple",
    "platform": "iOS",
    "push_id": "irBMohQPf_k2QrwP8iRzK3A/0CdLEzAoVGdF65HhH_I"
  }
}

Mandatory Attributes: customer_id, platform and push_id.

User Events Information

API to use - Event API
This API is used to track Actions of a User.

Signature for event API request looks like:

POST https://api.moengage.com/v1/event?app_id=<DATA API ID>
{
    "type": "event",
    "customer_id": "525689553535239acbfe",
    "device_id" : "12345",
    "actions" : [
          {
              "action": "Added to Cart",
              "attributes": {
                "product"  : "Mobile",
                "color"  : "white",
                "Brand"  : "Apple"
              },
              "platform" : "iOS",
              "app_version" : "1.2.3",
              "user_time" : 1433836769,
              "current_time" : 1433836769
          },
          {
              "action": "Purchase",
              "attributes": {
                "product"  : "MacBook Air",
                "Brand"  : "Apple"
              },
              "platform" : "web",
              "app_version" : "1.2.3",
              "user_time" : 1433837969,
              "current_time" : 1433837969
          }
     ]
}

We defined reserved keywords for some of Device 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

Mandatory Attributes: customer_id, action and platform.

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=<DATA API ID>
{
    "type" : "transition",
    "elements":[
        {
            "type" : "customer",
            "customer_id": "12345",
            "attributes": {
                "name":"John"
            }
        },
        {
            "type": "device",
            "customer_id": "525689553535239acbfe",
            "device_id" : "12345",
            "attributes": {
                "brand": "Apple",
                "platform": "iOS",
                "push_id": "irBMohQPf_k2QrwP8iRzK3A/0CdLEzAoVGdF65HhH_I"
            }
        },
        {
            "type": "event",
            "customer_id": "525689553535239acbfe",
            "device_id" : "12345",
            "actions" : [
                {
                    "action": "Added to Cart",
                    "attributes": {
                        "product"  : "Mobile",
                        "color"  : "white",
                        "Brand"  : "Apple"
                    },
                    "platform" : "iOS",
                    "app_version" : "1.2.3",
                    "user_time" : 1433836769,
                    "current_time" : 1433836769
                },
                {
                    "action": "Purchase",
                    "attributes": {
                        "product"  : "MacBook Air",
                        "Brand"  : "Apple"
                    },
                    "platform" : "iOS",
                    "app_version" : "1.2.3",
                    "user_time" : 1433837969,
                    "current_time" : 1433837969
                }
            ]
        }            	
   	]
}

Change User Id

API to use - Customer Substitute API
This API is used to Update Unique Id of User (customer_id).

Signature for user substitute API request looks like:

POST https://api.moengage.com/v1/customer/substitute
{
	"type": "customer_substitute",
	"old_customer_id": "525689553535239acbfe",
	"customer_id": "123456789"
}
old_customer_id (string) : Old unique identifier for the User.
customer_id (string) : New unique identifier for the User.

Change Device Id

API to use - Device Substitute API
This API is used to Update Unique Id of Device (device_id).

Signature for device substitute API request looks like:

POST https://api.moengage.com/v1/device/substitute?app_id=<DATA API ID>
{
	"type": "device_substitute",
	"old_device_id": "12345",
	"device_id": "54321"
}
old_device_id (string) : Old unique identifier for the Device.
device_id (string) : New unique identifier for the Device.

GET User Attributes

API to retrieve user attributes based on the Unique ID that you have set for the user.

POST - https://api.moengage.com/v1/customer/export?app_id=<DATA API ID>

Basic Authentication is required

Request Body should contain the unique id details of the users for whom you need the profiles attributes.

{
    "customer_ids" : ["id1", "id2"]
}

A sample response is given below -

{
  "customers": [
    {
      "id1": {
        "USER_ATTRIBUTE_ANDROID_ID": "android id",
        "USER_ATTRIBUTE_ADVERTISING_IDENTIFIER" : "Advertising Identifer iOS",
        "USER_ATTRIBUTE_USER_GENDER": "Male",
        "custom attribute that you track": "value of the custom attribute",
        "moe_dtzo": 330,
        "USER_ATTRIBUTE_LAST_KNOWN_STATE": "Ontario",
        "USER_ATTRIBUTE_NUM_SESSIONS": 2,
        "USER_ATTRIBUTE_LAST_KNOWN_COUNTRY": "Canada",
        "USER_ATTRIBUTE_USER_FIRST_NAME": "Deepakk",
        "USER_ATTRIBUTE_UNINSTALL_TIME": 1483420331,
        "USER_ATTRIBUTE_LAST_KNOWN_CITY": "Ottawa",
        "USER_ATTRIBUTE_USER_NAME": "John Cahill",
        "MOE_ISLAT": "0",
        "USER_ATTRIBUTE_USER_LAST_NAME": "John",
        "USER_ATTRIBUTE_USER_EMAIL": "joh@mail.com",
        "USER_ATTRIBUTE_ANDROID_GAID": "Advertising Identifier Android",
        "USER_ATTRIBUTE_UNIQUE_ID": "id1",
        "USER_ATTRIBUTE_USER_MOBILE": "12345678910",
        "USER_ATTRIBUTE_SIGNED_UP": 1483412907,
        "USER_ATTRIBUTE_LAST_SEEN": 1483414966,
        "USER_ATTRIBUTE_PLATFORMS": [
          {
            "active": true,
            "uninstall_time": 1483420331,
            "platform": "ANDROID"
          }
        ],
        "custom attribute like Personas":["Business Traveller", "Hotel Booker", "Music Listener"]
      }
    }
  ],
  "invalid_customer_ids": ["id2"]
}

Understanding Response -

'invalid_customer_ids' - List of unique ids, that don't match with any user in our system. User details contains all the custom attributes you track and also the default attributes which our system tracks. A list of default attributes and description is given below.

User Attribute
Description

USER_ATTRIBUTE_ANDROID_ID

android id for the user device.

USER_ATTRIBUTE_ADVERTISING_IDENTIFIER

iOS Advertising Identifier

USER_ATTRIBUTE_ANDROID_GAID

Android Advertising Identifier

MOE_ISLAT

Limited tracking enabled -> 0 - enabled. 1 - Disabled.

USER_ATTRIBUTE_LAST_KNOWN_COUNTRY

Last known country of the user.

USER_ATTRIBUTE_LAST_KNOWN_STATE

Last known state of the user.

USER_ATTRIBUTE_LAST_KNOWN_CITY

Last known city of the user.

moe_dtzo

user time zone offset in minutes.

USER_ATTRIBUTE_UNINSTALL_TIME

Uninstall time of the user (epoch time)

USER_ATTRIBUTE_NUM_SESSIONS

Number of sessions of the user.

USER_ATTRIBUTE_USER_NAME

Name of the user

USER_ATTRIBUTE_USER_FIRST_NAME

First name of the user.

USER_ATTRIBUTE_USER_LAST_NAME

Last name of the user

USER_ATTRIBUTE_USER_EMAIL

Email of the user

USER_ATTRIBUTE_USER_GENDER

Gender of the user - Male/Female

USER_ATTRIBUTE_USER_MOBILE

Mobile number of the user

USER_ATTRIBUTE_SIGNED_UP

First seen time of the user (epoch time)

USER_ATTRIBUTE_LAST_SEEN

Last seen time of the user (epoch time)

USER_ATTRIBUTE_PLATFORMS

list of platforms on which the user was active at least once in his lifetime.

Data API

Data API allow you to send data from an unsupported platform, or if you need to track information that comes from outside your mobile app.