Fetch Experience
Use the Fetch endpoint to receive data on active personalization experiences. You can fetch data for one or more server-side experiences by using the experience-key field. MoEngage will evaluate targeting rules and in-session attributes automatically and return the correct variation for the user. Typically, you would make this call as part of your larger page and content rendering pipeline.
Regenerate API SECRET
The API SECRET can be regenerated on the MoEngage Dashboard in the Personalize API Settings section discussed above.Authorizations
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="}
The username and password details can be obtained from the MoEngage Dashboard.
- Navigate to Settings -> Account -> APIs.
- Click the Copy icon in the Personalize tile in the API Keys section to copy the API Key.
- Use the Workspace ID as the username and the Personalize API Key as the password to generate the authentication header.
Headers
This is the Workspace ID of your MoEngage account and needs to be passed along with the request. You can find your MoEngage Workspace ID in the MoEngage Dashboard API Settings. For more information, refer to Authentication.
"Workspace ID"
This authentication parameter, used for access control, must be passed along with the request. To generate the authentication header, refer to Authentication.
"Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="
Set the Content-Type header to application/JSON for using the Personalize API.
application/json Body
This field uniquely identifies each server-side experience created using MoEngage Personalize. You can pass multiple values in a single request and receive the personalized content defined for each experience in the response.
To fetch the payload for a single experience:
experience_key: ["experience-1"]
To fetch payload for multiple experiences in a single call:
experience_key: ["experience-1", "experience-2"]
If no experience_key is specified, API will return:
- all experiences for the specified customer_id OR
- all experiences configured for all users if customer_id is not part of the request
This field is must contain the same value that has been used to identify users using the In-session attribute Query Parameter.
For example, if you want to target users who have opened the app after clicking on a link in an e-mail campaign and you have specified the parameter name as utm_medium,
utm_medium:"email"
This field must contain the day of the week for evaluating IN-session attribute-based experiences. Example:
DAY_OF_THE_WEEK:"Sunday"
This field must contain the time of the day for evaluating IN-session attribute-based experiences.
Example: For a time interval between 7 PM - 8 PM, the input for this field should be
TIME_OF_THE_DAY: "00"
This field must contain the user’s IP address to fetch experiences for audiences segmented basis geo-location.
This field must contain the USER-AGENT HTTP header. This is useful to delivering experiences personalized based on in-session attributes like Device Type.
Response
Success This response is returned when the request is submitted to MoEngage.