Overview
This API allows you to create Business Events in MoEngage. You can use these events to execute campaigns every time the event is triggered. For example, you can create business events when new episodes are available in an OTT series when there is a flight delay or price drop on a cart item. You can create event-triggered campaigns for these events in MoEngage to notify users about new episodes being available in an OTT series, flight delays, or price drops in an item they’ve viewed/wished for/added to the cart.
API Endpoint
POST https://api-0X.moengage.com/v1.0/business_event
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
- Navigate to Settings -> Account -> APIs.
- Click the Copy icon in the Campaign report/Business events/Custom templates tile in the API Keys section to copy the API Key.
- Use the App ID as the username and the Push API Key as the password to generate the authentication header.
Old UI
- Navigate to Settings -> APIs -> TRANSACTION PUSH/REPORT Settings.
- Click on the Click here to show APP Secret link to view the API SECRET.
- 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 bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="} | 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. Example: "event_name": "NameOfOTTSeries" |
event_attributes | Yes | Array of JSON Objects |
This field contains the event attributes of the business event being created. Structure: "event_attributes": [ { "attribute_name": "<name of attribute 1>", "attribute_data_type": "<data type of attribute 1>" }, { "attribute_name": "<name of attribute 2>", "attribute_data_type": "<data type of attribute 2>" },...{} ] Every attribute contains the following information:
Example: "attribute_name": "season"
Example:
|
created_by | Yes | String |
This field contains the email id of the creator of the business event. Example: "created_by": "john.doe@example.com" |
Response
Key | Data Type | Description |
---|---|---|
event_id | String |
This field contains the unique identifier for a Business Event and is returned only in the case when a request is successful. This is generated by MoEngage upon the successful creation of a Business Event. You must store this value and use it when searching for an event using the search API. Example: "event_id": "6447b078712cd8c650074840" |
message | String |
This field contains information about whether the request was successful or not. Example: "message": "The business event has been created" |
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. |
500 | Internal Server Error | This response is returned when the system runs into an unexpected error. |
Rate Limit
The rate limits are at the app level, and a maximum of 50 business events can be created per DB.
Sample cURL
curl --location 'https://api-{{0X}}.moengage.com/v1.0/business_event' \
--header 'Content-Type: application/json' \
--header 'Authorization Basic Base64_ENCODED_APPID_APISECRET==' \
--data '{
"event_name": "NameOfOTTSeries",
"event_attributes": [
{
"attribute_name": "season",
"attribute_data_type": "string"
},
{
"attribute_name": "episodes",
"attribute_data_type": "int"
},
{
"attribute_name": "cast",
"attribute_data_type": "array"
},
{
"attribute_name": "released_on",
"attribute_data_type": "date"
},
{
"attribute_name": "budget",
"attribute_data_type": "float"
}
],
"created_by": "john.doe@example.com"
}'
Sample Response
Sample Response for a successful request
{
"message": "The business event has been created",
"_id": "64a40cff5547a6b2c5b14404"
}
Sample Response for when an additional field in sent in the request
{
"error": {
"code": "400 Bad Request",
"message": "Additional fields are not allowed document schema for class BusinessEventCreateRequest:event_attribute",
"details": [
{
"code": "InvalidValue",
"target": "event_attribute",
"message": "Additional fields are not allowed document schema for class BusinessEventCreateRequest:event_attribute"
}
],
"request_id": "64a54b4b633fda13b668125d"
}
}
Sample Response for when a mandatory field is missing in the request
{
"error": {
"code": "400 Bad Request",
"message": "Bad request",
"details": [
{
"code": "MissingValue",
"target": "created_by",
"message": "created_by - Field is required but value is None : None"
}
],
"request_id": "64a54b0f633fda13b6681259"
}
}
Sample Response for when an incorrect datatype is passed for an attribute in the request
{
"error": {
"code": "400 Bad Request",
"message": "Bad request",
"details": [
{
"code": "MissingValue",
"target": [
"brand"
],
"message": "['brand'] - Wrong Attribute data type is passed : 'String'"
}
],
"request_id": "64a54b6c633fda13b668125e"
}
}
Sample Response for missing authentication 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": "64a54b9d633fda13b6681261"
}
}
Sample Response for when the APP ID is invalid
{
"error": {
"code": "401 Authentication error",
"message": "Authentication required",
"details": [
{
"code": "InvalidValue",
"target": "APP_ID",
"message": [
{
"code": "InvalidValue",
"target": "APP_ID",
"message": "Invalid APP_ID is provided."
}
]
}
],
"request_id": "64a54bfa633fda13b6681262"
}
}
Sample Response for when the APP Secret Key is invalid
{
"error": {
"code": "401 Authentication error",
"message": "Authentication required",
"details": [
{
"code": "InvalidValue",
"target": "APP_SECRET_KEY",
"message": [
{
"code": "InvalidValue",
"target": "APP_SECRET_KEY",
"message": "Invalid APP_SECRET_KEY is provided."
}
]
}
],
"request_id": "64a54c25633fda13b6681318"
}
}
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
-
What are the different data types supported in the creation of a Business event?
The different data types supported are integer, float, string, date, and array. -
Can I create two business events with the same name and different attributes?
Business Event names should be unique. Two business events cannot be created with the same name. -
How can I see the list of all the created Business events in MoEngage?
You can see all the business events created in MoEngage using the Search API. For more information, refer to Search Business Event API.