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
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 Base64_ENCODED_WORKSPACEID_APIKEY="}
You can obtain the username and password details from the MoEngage Dashboard.
- Navigate to Settings -> Account -> APIs.
- 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.
- 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 Base64_ENCODED_WORKSPACEID_APIKEY=} | 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:
|
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 --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.