Create File Segment
This API creates a new file segment from a CSV file URL.
- If your file is private, you should whitelist these IPs to provide access only to MoEngage for the file.
- This API endpoint does not currently support Team-level scoping. All segments generated using this call will be assigned to the Default Team automatically.
Rate Limits
- Breaching the limits will reject the request.
- Per hour and per day limits will consider the calculation based on the last hour and last 24 hrs respectively.
- The limit of 1000 active segments is calculated across all types of ‘active segments’. Most of our customers utilise only 30-40% of this limit at any given point.
CSV File Requirements
- The attribute names should be separated by new lines.
- CSV should be a single column and less than 150MB.
- Values should not end with a comma (e.g.,
abcdnotabcd,). - Values should not have duplicates or special characters (e.g.,
abcdnot"abcd"ora#bc). - File should not have empty rows or columns.
- A user attribute value must uniquely identify a single user.
- Sample File Link
Segment Processing and Availability
As soon as the request is received at the MoEngage system, MoEngage creates a segment with zero users. After this, the file is downloaded, processed, and users are added to the segment. If the segment is queried during processing, it will show zero or partial user count. There is no fixed processing timeout. If the initial file download fails, MoEngage automatically retries before reporting a failure via the callback.Callback Payload
When file processing completes, MoEngage sends aPOST request to your callback_url. Your server must return an HTTP 200 to acknowledge receipt.
The payload structure depends on the processing outcome.
Success (status: 201)
Authorizations
Authentication is done via Basic Auth. This requires a base64-encoded string of your credentials in the format 'username:password'.
- Username: Use your MoEngage workspace ID (also known as the App ID). You can find it in the MoEngage dashboard at Settings > Account > APIs > Workspace ID (earlier app id).
- Password: Use your API Key, which you can find within the Data tile.
For more information on authentication and getting your credentials, refer here.
Headers
Select the file content type.
text/csv, application/csv, application/vnd.ms-excel, text/plain, application/octet-stream, binary/octet-stream Set the database from which the data is available (MOE-DBNAME).
Body
Configuration for the new file segment.
Schema for creating a new file segment.
Name of the segment. Must be unique for creation.
Name of the user attribute to use as an identifier (e.g., 'ID', 'email').
The data type of the attribute_name.
string, double A public, downloadable URL to a single-column CSV file.
Segment expiry time in days. The segment is archived after this time.
Callback URL to receive the result of segment processing.
List of email IDs to receive segment processing response.
Callbacks
POST{$request.body#/callback_url}segmentCreationCallback
Body
Result of the segment processing job.
The payload sent to the callback URL. The structure depends on the processing status.
The database name.
"test_db"
The name of the segment.
"test_segment_name"
The unique ID of the request.
"d5a263c4ef1198ae3d8496c0460f570f"
The HTTP status code indicating the outcome (e.g., 201 for success, 400/500 for failure).
201
(Success only) Number of rows present in the uploaded file.
(Success only) Number of values processed from values_found. Values with corrupted or empty data are skipped.
(Success only) Number of users found in MoEngage from the processed values and added to the segment.
(Failure only) A description of the error.
Response
OK. Acknowledges receipt of the callback. Your endpoint should return this.
Response
Everything worked as expected.