Overview
This API allows you to trigger a business event in MoEngage. You can set up campaigns to be executed when these events are triggered.
API Endpoint
POST https://api-0X.moengage.com/v1.0/business_event/trigger
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.
Authentication
Basic authentication sends a Base64-encoded string containing a username and password for all API requests. For example, Basic Authentication encodes a 'username:password' using base64 encoding and prepends it with the string 'Basic '. The string is passed in the authorization header as follows:
{"Authorization":"Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U="}
To fetch the username and password details :
- Navigate to Settings > APIs > TRANSACTION PUSH/REPORT Settings.
- Click on the link - Click here to show API Secret to view the API Secret key.
- User name - APP ID and Password - API SECRET
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 e3tEQVRBX0FQUF9JRH19Ont7REFUQV9BUElfS0VZfX0=} | This is the authentication parameter for access control and needs to be passed along with the request. The APP ID and API SECRET need to be picked up from the TRANSACTION PUSH API Settings in MoEngage Dashboard, and a Basic Authorization header needs to be created and set in the header. Navigation: Settings -> API -> General Settings -> TRANSACTION PUSH/REPORT SETTINGS section. For more information, refer to Authentication. |
Request Body
Key | Required | Values | Description |
---|---|---|---|
event_name | Yes | String |
This field contains the name of the business event to be triggered Example: "event_name": "NameOfOTTSeries" |
event_attributes | Yes | JSON Objects |
This field contains the event attributes with which the business event will be triggered. Structure: "event_attributes": { "attribute_name1": "<attribute value>", "attribute_name2": "<attribute value>", "attribute_name3": "<attribute value>", … } Every attribute contains the following information: attribute_name - This field contains the name of the business event attribute for which the value is being sent in the request. The attribute_name is a String. Example: "attribute_name": "season" |
triggered_by | No | String |
This field contains information about who triggered the business event. Example: "triggered_by": "john.doe@example.com" |
Response
Key | Data Type | Description |
---|---|---|
message | String |
This field contains information about whether the request was successful or not. Example: "message": "The business event has been triggered" |
error | JSON Object |
This field is present in the response only in case of an unsuccessful request and contains the following fields:
|
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 or when the provided parameters are invalid. |
401 |
Authorization Failure |
This response is returned when the authorization parameters are missing or incorrect in the HTTP Auth Header. |
429 |
Rate Limit Breach |
This response is returned when the number of requests has exceeded the rate limit. |
500 | Internal Server Error | This response is returned when the system runs into an unexpected error. |
Rate Limit
The rate limit is 100 RPM.
Sample cURL
curl --location 'https://api-0X.moengage.com/v1.0/business_event/trigger' \
--header 'Content-Type: application/json' \
--header 'Authorization Basic Base64_ENCODED_APPID_APISECRET==' \
--data '{
"event_name": "Series_Name",
"event_attributes": {
"season": "Season 1",
"episodes": 12,
"cast": ["John Doe", "Jane Doe"],
"date": "11/11/2023" },
"triggered_by": "john.doe@example.com"
}'
Sample Response
Sample Response for a successful request
{
"message": "The business event has been triggered"
}
Sample Response for when the business event does not exist
{
"error": {
"code": "400 Bad Request",
"message": "Business event does not exists",
"details": [
{
"code": "InvalidValue",
"target": "event_name",
"message": "Business event does not exist"
}
],
"request_id": "64a54cf9633fda13b668132f"
}
}
Sample Response for when a wrong business event attribute passed in api request
{
"error": {
"code": "400 Bad Request",
"message": "Wrong business event attribute passed in api request",
"details": [
{
"code": "InvalidValue",
"target": "rating1",
"message": "Wrong business event attribute passed in api request"
}
],
"request_id": "64a54b0f633fda13b6681259"
}
}
Sample Response for when there is no active campaign associated with the business event
{
"error": {
"code": "400 Bad Request",
"message": "No active campaign found for business event name",
"details": [
{
"code": "InvalidValue",
"target": "event_name",
"message": "No active campaign found for business event name"
}
],
"request_id": "64a54dbf633fda13b668142d"
}
}
Sample Response for when the triggered by field contains an invalid email id
{
"error": {
"code": "400 Bad Request",
"message": "Business event does not exists",
"details": [
{
"code": "MissingValue",
"target": "triggered_by",
"message": "triggered_by - Invalid email address : 'abc'"
}
],
"request_id": "64a54dec633fda13b668142f"
}
}
Sample Response for missing APP ID and API Secret in the auth header
{
"error": {
"code": "401 Authentication error",
"message": "Authentication required",
"details": [
{
"code": "InvalidValue",
"target": "Authorization",
"message": {
"code": "MissingValue",
"target": "Authorization",
"message": "APP_ID and APP_SECRET_KEY is missing in Authorization Header."
}
}
],
"request_id": "64a54e0e633fda13b6681430"
}
}
Sample Response for Rate Limit Breach
{
"status": "error",
"data": {
"code": 429,
"title": "rate limiter exception",
"description": "Exceeded rate limit for this app"
}
}
Sample Response for server side errors
{
"title": "Internal Server Error",
"message": "An unexpected error was encountered while processing this request. Please contact MoEngage Team"
}
Postman Collections
We have made it easy for you to test the APIs. Click here to view it in Postman.
FAQs
-
Do I need to pass the value for all event attributes while triggering the campaign?
No, it is not required to pass all the attributes while triggering the business event. -
How do I know if the campaign has been triggered successfully?
You can view the campaign analytics to see if the campaign for the business event has been triggered successfully. Navigate to Engage -> Campaigns on the MoEngage Dashboard and search for the campaign associated with the Business Event. You can see the child campaign's performance here with the details of all the campaigns that have run for the business event till now.