This API can be used to trigger scheduled file imports. Periodic imports can be triggered to run using this API if the import has not expired and is in any of the following states: Scheduled, Successful, Partially Successful, and Failed.
API Endpoint
https://fileimports-data-api-0X.moengage.com/v1.0/data/fileimports/trigger/{schedule_id}
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.
SCHEDULE_ID
Key | Required | Data Type | Description |
---|---|---|---|
SCHEDULE_ID |
Yes |
String |
This field specifies the Import ID(the unique identifier for the import) of the import that needs to be triggered. You can find the Import ID in the MoEngage Dashboard on the Imports History page. Click on Actions → View import to view the Import Details. You can also view the Import ID in the email notification received once the import has been set up. |
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_APPKEY_APIKEY=="}
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 Generate Key in the Data tile in the API Keys section, and click Save.
- Use the Workspace ID as the username and the Data API Key as the password to generate the authentication header.
Old UI
- Navigate to Settings -> APIs -> DATA API Settings.
- Click Generate Key.
- Click Save on the Data APIs settings section.
- Use the DATA API ID as the username and the DATA API KEY as the password to generate the authentication header.
Request Headers
Key | Sample Values | Description |
---|---|---|
MOE-APPKEY |
{"MOE-APPKEY": "WORKSPACE ID"} |
This is your MoEngage account's WORKSPACE ID that has to be passed along with the request. You can find your MoEngage WORKSPACE ID in the following navigation on the Dashboard: Revamped UI: Settings -> Account -> APIs -> WORKSPACE ID Old UI: Settings -> API -> General Settings -> DATA API |
Authorization |
{"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. |
Response
Key | Data Type | Description |
---|---|---|
status |
String |
This field contains the status of the request and specifies whether the request was successful. Supported Values: success, failure Example: "status": "success" |
message |
String |
This field contains information about whether the request was successful or not. Example: "message": "Trigger Import Successful" |
error_type
|
String |
This field is present in the response when the Import/Schedule ID in the request is not found in the system (either because it is invalid or has been deleted). |
type |
String |
This field is present in the response in the case of 403 errors and contains the error type. |
request_id |
String |
This field is present in the response in the case of 403 errors and contains the request-id. |
title |
String |
This field is present in the response in the case of errors and contains the type of error. |
description |
String |
This field is present in the response in the case of errors and contains the error description. |
code |
String |
This field is present in the response in the case of 5xx errors and contains the error code. |
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 Import ID/Schedule ID is missing from the request or when the provided parameters are invalid. Also, this response is returned when the rate limit (one request in five minutes) is breached. |
401 |
Authorization Errors |
This response is returned when the APP Key is invalid or missing, the password is incorrect, or there are other such authorization-related errors in the request. |
403 |
Account Blocked |
This response is returned when your MoEngage account has been blocked or suspended. |
404 |
Not Found |
This response is returned when the request contains the incorrect URL (when you try to access a resource that is not present). |
405 |
Method Not Allowed |
This response is returned when the request contains an unsupported method. For example, if you were to use the GET method instead of POST for this request, you would result in a 405 error. |
5xx |
Internal Server Error |
This response is returned when the system runs into an unexpected error. |
Rate Limit
This API can be triggered once in every five minutes for a specific schedule_id. A Bad request response (400) response will be sent if this is exceeded.
Sample cURL Request
curl --location --request POST 'https://fileimports-data-api-0X.moengage.com/v1.0/data/fileimports/trigger/{YOUR_IMPORT_ID_HERE}' \
--header 'MOE-APPKEY: YOUR_APP_KEY_HERE' \
--header 'Authorization Basic Base64_ENCODED_APPID_APISECRET==' \
Sample Response
Success Response
{
"status": "success",
"message": "Triggered Import Successfully",
}
Sample Response for When the Import ID (Schedule ID) in the Request is Invalid
{
"status": "FAILURE",
"error_type": "NOT_FOUND",
"message": "This import is either deleted or expired."
}
Sample Response for When the Number of Users Exceeds the Allowed Limit in the Request
{
"status": "FAILURE",
"error_type": "ALREADY_EXISTS",
"message": "Import has run in the last 5 min."
}
Sample Response for Incorrect Password in the Header
{
"title": "AuthenticationInvalid",
"description": "Password (APP_KEY) doesn't match the one available on the dashboard. Kindly ensure the same APP_KEY available on the dashboard is used."
}
Sample Response for Missing Authorization Key in the Header
{
"title": "HeaderMissing",
"description": "MOE-APPKEY is missing in Header"
}
Sample Response for APP Key Mismatch in the Header
{
"title": "HeaderMismatch",
"description": "MOE_APPKEY doesn't match the Username (APP_KEY) used in Basic Auth authorization."
}
Sample Response for When Your Account is Blocked
{
"status": "fail",
"error": {
"message": "Your account is suspended. Please contact MoEngage team.",
"type": "BlockedClient",
"request_id": "ofHUEaEQ"
}
}
Sample Response for Resource Not Found Error
{
"status": "fail",
"message": "Resource not found",
}
Sample Response for Method Not Allowed Error
{
"status": "fail",
"message": "Method not allowed",
}
Sample Response for Unknown Errors
{
"title": "Server Error",
"description": "An unexpected error was encountered while processing this request. Please contact MoEngage Team",
"code": "GlQhUzvM"
}
Postman Collections
We have made it easy for you to test the APIs. Click here to view it in Postman.
FAQs
-
Does the trigger API change the import schedule?
No, the schedule still remains the same as originally set up in the MoEngage Dashboard.