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.
To generate the Basic Authentication header:
- Navigate to Settings > APIs >General Settings > DATA API Settings
- Copy the DATA API ID and DATA API KEY
- Generate the Authentication Header String
Basic Authentication encodes a 'username:password' using base64 and prepends it with the string 'Basic '. To generate the Auth header:
-
- Add a colon after the user name (DATA API ID) and concatenate it with the password (DATA API KEY).
- Encode the concatenated string using base64 encoding.
- Pass the encoded string in the HTTP authorization header as follows: {"Authorization":" Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="}
Request Headers
Key | Sample Values | Description |
---|---|---|
MOE-APPKEY |
{"MOE-APPKEY": "APP ID"} |
This is your MoEngage account's APP ID that has to be passed along with the request. You can find your MoEngage APP ID in the MoEngage Dashboard API Settings. Navigation: Settings -> API -> General Settings -> DATA API section. For more information, refer to Authentication. Note: You can also fetch the APP ID from the following navigation: Settings -> App -> General Settings. |
Authorization |
{"Authorization": "Basic bmF2ZWVua3VtYXI6bW9lbmdhZ2U=="} |
This is the authentication parameter for access control and needs to be passed along with the request. The APP KEY and API SECRET need to be picked up from the DATA API Settings in the MoEngage Dashboard, and a Basic Authorization header needs to be created and set in the header. Navigation: Settings -> API -> General Settings -> DATA API section. For more information, 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, when the rate limit (one request in five minutes) is breached, this response is returned. |
401 |
Authorization Errors |
This response is returned when the APP Key is invalid or missing, the password is incorrect, and other such authorization-related errors in the request. |
403 |
Account Blocked |
This response is returned when your MoEngage account has been blocked or suspended. |
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. If this is exceeded, a Bad request response (400) response will be sent.
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": "Trigger Import Successful",
}
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 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 schedule of the imports?
No, the schedule still remains the same as originally set up in the MoEngage Dashboard.