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": [
    "user1@example.com"
  ]
}
'
{
  "message": "File-segment user-replace request accepted",
  "success": true,
  "cs_name": "custom_segment_unique_name"
}
  • 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

Basic Authentication using your Workspace ID (as username) and Data API Key (as password) from the MoEngage Dashboard.

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.