User API helps add or update users and user properties in MoEngage. You can do the following:
- Create a new user
- Create new user property
- Update existing user properties of users
API Endpoint
POST https://api-0X.moengage.com/v1/customer/<APP_ID>
The 'X' in the API Endpoint URL refers to the MoEngage Data Center (DC). MoEngage hosts each customer in a different DC. You can find your DC number (value of X) and replace the value of 'X' in the URL by referring to the DC and API endpoint mapping here.
APP_IDThe APP_ID for your MoEngage account is available on the MoEngage Dashboard in Settings > App Settings > Account Settings > APP ID. |
Request Body
A sample request body is described for the user with the unique id john@example.com.
{
"type" : "customer",
"customer_id": "john@example.com",
"attributes": {
"name":"John",
"platforms" : [{"platform":"ANDROID", "active":"true"}]
}
}
Request Body Fields
Key | Datatype | Mandatory Field | Description |
---|---|---|---|
type | String | Yes | This is used to identify the type of request. |
customer_id | String | Yes | The unique identifier is used to identify/create a user in MoEngage. Please refer to this section for more information on customer_id. |
attributes | JSON Object | No | A dictionary containing user attributes to add / update in the user profile. |
platforms | List | No | List of dictionaries with the associated platforms out of ANDROID, iOS, and web and their status. |
unset_attributes | JSON Object | No |
A dictionary containing the user attributes to be unset. "unset_attributes": [ { "type": "<Add type operator here>", "attr": "<Add attribute name here>", "case_sensitive": false }]
|
Standard User Attributes
The following standard user attributes are tracked for User API in MoEngage.
Key | Attribute Name on Dashboard | Datatype | Description |
---|---|---|---|
name | Name | String | Full name of the user. |
first_name | First Name | String | First name of the user. |
last_name | Last Name | String | Last name of the user. |
String | Email Address of the user. For example, john@example.com | ||
age | Age | Numeric | Age of the user |
gender | Gender | String | Gender of the user |
mobile | Mobile Number | String | Mobile Number of the user. For example, 918888444411 |
moe_geo_location | Location | Array of [lat,lng] in double in the format {'lat': 12.11, 'lon': 123.122} | A sample value would be the location of the user. For example: {'lat': 12.11, 'lon': 123.122} |
source | Publisher Name | String | This is the Publisher Name of Install. For example, Google Ads |
created_time | First Seen | Date | The time when the user was created. Information in ISO 8601 format. For example: 2019-05-21T03:47:35Z |
last_seen | Last Seen | Date | Last Seen Time of the user. Information in ISO 8601 format. For example 2020-05-01T03:52:35Z |
transactions | Number of Conversions | Numeric | A total number of conversions made by the user in a lifetime. |
revenue | LTV | Numeric | Life Time Value of the user. |
moe_unsubscribe | Unsubscribe | Boolean | Email Unsubscribe Attribute. Emails are not sent to the user when the set value is true. |
platforms | Not visible on the dashboard. | List | Value is based on the active platforms of the user. For example: [{"platform":"ANDROID", "active":"true"},{"platform":"IOS", "active":"true"}] |
For other attributes that are not part of the list, use the key-value pairs that you intend to use.
Example Payload
For example, to track custom attributes of different data types like string, numeric, boolean, and date, pass the following payload where points are a number, expiry_date is a date type attribute, and super_user is a boolean attribute.
{
"type" : "customer",
"customer_id": "john@example.com",
"attributes": {
"points":20,
"expiry_date":"2020-05-31T03:47:35Z",
"super_user":true,
"user_persona":"browsers",
"platforms" : [{"platform":"ANDROID","active":"true"}]
}
}
To unset a previously set user attribute, pass the information in the unset_attributes JSON object. To unset an attribute, you have to send the type operator, attribute name, and whether the attribute is case-sensitive.
{
"type": "customer",
"customer_id": "john@example.com",
"unset_attributes": [
{
"type": "equals",
"attr": "my_int",
"case_sensitive": false
},
{
"type": "equals",
"attr": "my_string",
"case_sensitive": false
},
{
"type": "equals",
"attr": "my_custom_date",
"case_sensitive": false
}
]
}
Reserved keywords for the user attribute name"id", "_id", and "" keywords are blocked and not to be used as user attribute names. |