Search Business Event API

Overview

This API allows you to search for business events by specifying their event IDs.

API Endpoint

API Endpoint
POST https://api-0X.moengage.com/v1.0/business_event/search

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.

  1. Navigate to Settings -> Account -> APIs.
  2. 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.
  3. 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 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_ids No Array of Strings

This field contains the list of event ids associated with the business events that need to be fetched.

Structure:

"event_ids":  ["event_id1","event_id2","event_id3"]

event_id: The event id is the unique identifier for a business event and is generated by MoEngage at the time of business event creation. You must store and use this value while looking up a business event using the search API.

event_names No Array of Strings

This field contains the list of event names associated with the business events that need to be fetched.

Structure:

"event_names":  ["event_name1","event_name2","event_name3"]

event_name: The event name is the name associated with the Business Event that is provided during the creation of the event.

Response

Key Data Type Description
data JSON Object

This field contains the business events being looked up in the request. This field is present in the response only for successful requests.

Structure of data object:

"data": {

    "db_name": "<name of the DB>",

    "event_id": "<unique identifier of the business event>",

    "event_name": "<name of the business event>",

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

        },...{}

   ],

 “last_updated”: “<timestamp of when the Business Event was last updated>”,

 “created_at”: “<Timestamp of when the Business Event was created>”,

 “total_trigger”: “<Number of times the Business event has been triggered>”,

 “total_sent_message”: “<Number of campaign messages sent for the Business Event>”,

 “usage_count”: “<Usage Count>”,

 “created_by”: “<Information about the creator of the Business Event>”,

 “last_received_time”: “<Information about when the latest trigger was received for the Business Event>”

}

}

For more information, refer to Response Payload.

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

The rate limit is 100 RPM.

Sample cURL

curl --location 'https://api-0X.moengage.com/v1.0/business_event/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic Base64_ENCODED_APPID_APISECRET==' \
--data '{"event_ids": ["6447b078712cd8c650074840"]}'

Sample Response

200 400 401429 500
Sample Response for a successful request
{
    "data": [
    {
        "db_name": "Sample_App",
        "event_id": "647597767459c85d7d6d6dfd",
        "event_name": "NewMovies",
        "event_attributes": [
          {
           "attribute_name": "MovieName",
           "attribute_data_type": "array"
          },
          {
           "attribute_name": "rating",
           "attribute_data_type": "string"
          }
        ],
       "created_at": "2023-05-29T18:36:52.390000",
       "total_trigger": 0,
       "users_in_segment": 0,
       "usage_count": 0,
       "created_by": "john.doe@moengage.com",
       "last_received_time": "2023-05-30T06:28:06.498000",
       "_id": "64a54500633fda13b6681163"
    }
    ]
}

Postman Collections

We have made it easy for you to test the APIs. Click here to view it in Postman.

Previous

Next

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

How can we improve this article?