Overview
This API allows you to search for business events by specifying their event IDs.
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 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 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:
|
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
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"
}
]
}
Sample Response for when additional fields are present in the request
"error": {
"code": "400 Bad Request",
"message": "Additional fields are not allowed document schema for class BusinessEventSearchRequest:event_name",
"details": [
{
"code": "InvalidValue",
"target": "event_name",
"message": "Additional fields are not allowed document schema for class BusinessEventSearchRequest:event_name"
}
],
"request_id": "64a54e62633fda13b6681431"
}
}
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.