Skip to main content
PUT
/
v2
/
custom-segments
/
file-segment
/
replace
Replace users from File Segment
curl --request PUT \
  --url https://api-{dc}.moengage.com/v2/custom-segments/file-segment/replace \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "name": "custom_segment_unique_name",
  "attribute_name": "unique_identifier",
  "attribute_type": "string",
  "file_url": "https://s3.amazonaws.com/Sample_GAIDs_replace.csv",
  "callback_url": "http://example.com/moengage-callback",
  "emails": [
    "[email protected]"
  ]
}
'
{
  "message": "File-segment user-replace request accepted",
  "success": true,
  "cs_name": "custom_segment_unique_name"
}
Notes:
  • This API drops all existing users from the custom segment and adds the new users provided in the File URL.
  • Only the newly added users are counted towards the daily file segment user limit.

Authorizations

Authorization
string
header
required

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

Content-Type
enum<string>
default:text/csv
required

Select the file content type.

Available options:
text/csv,
application/csv,
application/vnd.ms-excel,
text/plain,
application/octet-stream,
binary/octet-stream
Database
string

Set the database from which the data is available (MOE-DBNAME).

Body

application/json

Details of the segment to update and the file URL of users to replace with.

Schema for updating an existing file segment (add, remove, replace users).

name
string
required

Name of the custom segment. Must be unique for creation.

attribute_name
string
required

Name of the user attribute to use as an identifier (e.g., 'ID', 'email').

attribute_type
enum<string>
required

The data type of the attribute_name.

Available options:
string,
double
file_url
string<uri>
required

A public, downloadable URL to a single-column CSV file.

callback_url
string<uri>

Callback URL to receive the result of segment processing.

emails
string<email>[]

List of email IDs to receive segment processing response.

Response

Request accepted for processing.

message
string

The status message of the request.

success
boolean

Indicates if the request was accepted.

Example:

true

cs_name
string

The unique name of the custom segment being processed.