curl --request PUT \
--url https://api-{dc}.moengage.com/v2/custom-segments/file-segment/add-users \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "custom_segment_unique_name",
"cs_id": "<unique cs id>",
"attribute_name": "unique_identifier",
"attribute_type": "string",
"file_url": "https://s3.amazonaws.com/Sample_GAIDs_add.csv",
"callback_url": "http://example.com/moengage-callback",
"emails": [
"user1@example.com"
]
}
'{
"message": "File-segment user-add request accepted",
"success": true,
"cs_name": "custom_segment_unique_name",
"cs_id": "<unique cs id>"
}{
"title": "Invalid Request",
"description": "<message>"
}{
"title": "Authentication required",
"description": "<message>"
}{
"title": "Entity Not Found",
"description": "Segment not found with the given name: <custom_segment_unique_name>"
}{
"title": "Too Many Requests",
"description": "<appropriate message>"
}{
"title": "Internal Server Error"
}Add Users to File Segment
This API adds a list of users from a CSV file to an existing file segment.
curl --request PUT \
--url https://api-{dc}.moengage.com/v2/custom-segments/file-segment/add-users \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: <content-type>' \
--data '
{
"name": "custom_segment_unique_name",
"cs_id": "<unique cs id>",
"attribute_name": "unique_identifier",
"attribute_type": "string",
"file_url": "https://s3.amazonaws.com/Sample_GAIDs_add.csv",
"callback_url": "http://example.com/moengage-callback",
"emails": [
"user1@example.com"
]
}
'{
"message": "File-segment user-add request accepted",
"success": true,
"cs_name": "custom_segment_unique_name",
"cs_id": "<unique cs id>"
}{
"title": "Invalid Request",
"description": "<message>"
}{
"title": "Authentication required",
"description": "<message>"
}{
"title": "Entity Not Found",
"description": "Segment not found with the given name: <custom_segment_unique_name>"
}{
"title": "Too Many Requests",
"description": "<appropriate message>"
}{
"title": "Internal Server Error"
}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
Details of the segment to update and the file URL of users to add.
Schema for updating an existing file segment (add, remove, replace users).
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.
Callback URL to receive the result of segment processing.
List of email IDs to receive segment processing response.
Unique identifier corresponding to the target segment. When both cs_id and name are populated, the system prioritizes cs_id.
Was this page helpful?