Personalized Preview

You can use the Personalized Preview API to preview the personalized content for a specific user in MoEngage. This API can retrieve the Personalized message content.

API Endpoint

API Endpoint
POST https://api-0X.moengage.com/core-services/v1/personalization/preview

Each customer is hosted on a different data center; you can find your data center number (value of X) by checking the data center and API endpoint mapping page.

Authentication

The API request will be authenticated through Basic Authentication. Basic Authentication sends a Base64-encoded string containing your username and password with every API request. It encodes a 'username:password' string in Base64 and appends the encoded string with 'Basic '. This string is included in the authorization header as shown below:

{"Authorization":"Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}

You can obtain the username and password details from the MoEngage Dashboard.

  1. Navigate to Settings -> Account -> APIs.
  2. Copy the following details:
    • Username: Under Workspace ID (earlier app id), click the copy icon to copy the username.
    • Password: In the API keys section, click the copy icon in the Campaign report/Business events/Custom templates tile to copy the API key.
  3. Use these details to authenticate the API requests.

Request Headers

Key Required Sample Values Description

Content-Type

Required

{"Content-Type": "application/json"}

Set the Content-Type header to application/json.

Authorization

Required

{"Authorization": "Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="}

This authentication parameter, used for access control, must be passed in the request. To generate the authentication header, refer to Authentication.

MOE-APPKEY Required

{“MOE-APPKEY”: “Workspace ID”}

This is the workspace ID (earlier APP ID) of your MoEngage workspace. The MOE-APPKEY has to be passed in the request. You can find your MoEngage Workspace ID in the MoEngage Dashboard:

Settings -> Account -> APIs -> Workspace ID (earlier app id)

For more information, refer to Authentication.

Data-compression Optional
  • true
  • false
This parameter is used to pass the payload in compressed format.

Request Body

Key Required Values Description
request_id Required String This field denotes the request ID for which the personalized preview is accessed.
personalization_content Required JSON Object This object contains the personalization content details. For more information, refer to Personalization Content.
user_details Optional JSON Object This object contains the user details. For more information, refer to User Details.
personalization_details Required JSON Object This object contains the personalization details. For more information, refer to Personalization Details.

Personalization Content

Key Required Values Description
payload Optional JSON Object This field denotes the data being transferred within the API request or response. The field values can contain any name and number of keys, providing flexibility to include all necessary information such as user data, event details, or other parameters required for processing.
Custom template data Optional JSON Object This object contains the custom template details. For more information, refer to Custom Template Data.
info

Information

Either payload or custom template data object should have a value.

User Details

Key Required Values Description
identifier Required string This field denotes the unique key used to specify a particular user or entity. This could be an ID, email, or phone number that uniquely identifies the user within the system.
identifier_value Required string This field denotes the corresponding value of the selected identifier. It represents the specific user or entity being targeted. For example, if the identifier is "email," the identifier value could be "user@example.com".
info

Information

If you are using user details in request_body, then identifier and identifier_value field values are mandatory.

Personalization Details

Key Required Values Description
event_name Optional string This field denotes the event name for which the personalization details of the personalization preview is accessed. This is required if an event attribute is present in the payload.
channel Required string This field denotes the channel for which the personalization details of the personalization preview is accessed. 
user_attributes Optional JSON Object This field denotes key-value pairs that represent specific user characteristics or properties. The field values can contain any name and number of keys, allowing you to include various user-specific details.
event_attributes Optional JSON Object This field denotes the key-value pairs that describe the properties of a particular event. The field values can contain any name and number of keys, enabling you to include details like event type, time, or associated metadata.
info

Information

  • When you pass personalization details in the personalization_details object of this API, MoEngage uses those details to personalize the user attributes or event attributes present in the content instead of the attributes present in the user profile.
  • You can personalize content APIs using the event attribute when the same event is used for the campaign.

  • If you’re personalizing content or sending personalized content in the payload using user attributes, event attributes, product sets, or content APIs, ensure that the attribute is available within the MoEngage dashboard.

Custom Template Data

Key Required Values Description
template_id Required string This field denotes the template ID for which the custom template data for personalization preview is accessed.
version Required string This field denotes the version for which the custom template data for personalization preview is accessed.
info

Information

If you are using custom template data in personalization_content, then template ID and version field values are mandatory.

 

Rate Limit

You can create 10000 requests per minute.

Response Codes

Status Code Request State Description

200

Success

This response is returned when the request is processed successfully. 

400

Bad Request

This response is returned when the required parameters are missing from the request, when the provided parameters are invalid, or when the custom template ID and version don't exist in the dashboard .

401

Unauthorized

The request does not have valid authentication credentials.

429

Too Many Requests

Too Many requests, there won't be any response body for this.

500

Internal Server Error

This response is returned when the system runs into an unexpected error.

Sample cURL Request

User Attribute Event Attribute Custom Template Content Block Content API Product Set
curl --location 'https://api-0X.moengage.com/core-services/v1/personalization/preview' \
--header 'content-type: application/json' \
--header 'MOE-APPKEY: {{Workspace_ID or APP_ID}}' \
--header 'Authorization: Basic {{Authorization_Key}}' \
--data '{
      "request_id": "2",
      "personalization_details": {
      "event_name": "MOE_USER_PROFILE_UPDATED",
      "channel": "EMAIL",
      "user_attributes": {
      "Gender": "Female"
      }
      },
      "personalization_content": {
      "payload": {
      "user_attribute_personalization": "<!DOCTYPE html>\n<html>\n<head>\n<title>User Profile Update Example</title>\n</head>\n<body>\n<p>Hi {{UserAttribute['\''First Name'\'']}},\n Your profile has been updated successfully.\n</p>\n<p>Here are your updated details:\n First Name: {{UserAttribute['\''First Name'\'']}}\n Last Name: {{UserAttribute['\''Last Name'\'']}}\n Email: {{UserAttribute['\''Email'\'']}}\n Mobile: {{UserAttribute['\''Mobile Number (Standard)'\'']}}\n Gender: {{UserAttribute['\''Gender'\'']}}\n</p>\n</body>\n</html>"
      }
      },
      "user_details": {
      "identifier": "ID",
      "identifier_value": "JOHN012"
}
}'

Sample Response

User Attributes Event Attributes Custom Template Content Block Content API Product Set
{
      "personalized_content": {
      "payload": {
      "user_attribute_personalization": "<!DOCTYPE html>\n<html>\n<head>\n<title>User Profile Update Example</title>\n</head>\n<body>\n<p>Hi ,\n Your profile has been updated successfully.\n</p>\n<p>Here are your updated details:\n First Name: \n Last Name: \n Email: \n Mobile: \n Gender: Female\n</p>\n</body>\n</html>"
      }
      }
      }

Response Code Structure

201 400 401 429 500
{
      "personalized_content": {
      "payload": {
      "First Name": "User1"
      }
      }
}

Postman Collections

We have made it easy for you to test the APIs. Click here to view it in Postman. 

FAQs

arrow_drop_down Can I use a custom template in the Personalization Preview? If yes, what will the output be?

Yes, you can use custom templates with the Personalization Preview. The API will personalize the content within the template based on the user identifier provided and return the personalized HTML as a response.

arrow_drop_down Can I use an event to personalize content in the Personalization Preview?

Yes, you can pass event details as input to the API. Ensure the event name matches the one in your workspace.

Previous

Next

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?