Trigger Business Event API

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

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

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. We've revamped the settings UI in the Dashboard. If you're using the API for the first time, follow these steps for the revamped and old UIs:

Revamped UI

  1. Navigate to Settings -> Account -> APIs.
  2. Click the Copy icon in the Campaign report/Business events/Custom templates tile in the API Keys section to copy the API Key.
  3. Use the App ID as the username and the Push API Key as the password to generate the authentication header.

Old UI

  1. Navigate to Settings -> APIs -> TRANSACTION PUSH/REPORT Settings.
  2. Click on the Click here to show APP Secret link to view the API SECRET.
  3. Use the APP ID as the username and the API SECRET as the password to generate the authentication header.

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 authentication parameter, used for access control, must be passed along with the request. To generate the authentication header, 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:

      • code - This field contains the error code.
      • message - This field contains the error message.
      • details - This array contains the specifics and describes the error in detail.
      • request_id - This field contains the request id of the failed request.

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

You can send 200 triggers in a day, and 50 in each hour. 

Sample cURL

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

200 400 401429 500
Sample Response for a successful request
{
   "message": "The business event has been triggered"
}

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.

Previous

Next

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

How can we improve this article?