Create Business Event API

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

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

  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 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:

      • attribute_name - This field contains the name of the attribute being defined for the business event. The attribute_name is a String.

Example: "attribute_name": "season"

      • attribute_data_type - This field contains the data type of the attribute being defined for the business event. The attribute_data_type is a String. Allowed Values: "string", "int", “float", “array", "date"

Example:

      • "attribute_data_type": "string"
      • "attribute_data_type": "date"
      • "attribute_data_type": "int"
      • attribute_data_type": "array"
      • "attribute_data_type": "float"
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:

      • 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.
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
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

200 400 401 500
Sample Response for a successful request
{
   "message": "The business event has been created",
   "_id": "64a40cff5547a6b2c5b14404"
}

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.

Previous

Next

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

How can we improve this article?