User Segments REST API
Create manually updated list-based segments and override, append, or remove members by segment ID.
General
- Requests and responses use JSON encoded in UTF-8.
- The full endpoint URL is the data center Base URL plus the API path. See REST API Overview for how to obtain the Base URL and API Key / API Secret.
- Use HTTP Basic Authentication:
Authorization: Basic ${base64(api_key:api_secret)}. The API data source bound to the API Key determines the project; callers do not pass a project ID in the request body. - Successful responses share a common structure:
code0means success,messagedescribes the result, anddatacarries the payload. Batch handling for member writes depends on the operation:OVERRIDEruns only after all batches are received; each batch ofAPPENDandREMOVEis applied independently.data.statusanddata.completein the response indicate processing state.
Create a list-based segment
Creates a segment with manual update mode and list upload as the creation method. The segment has no members after creation; use Update segment members to upload the list.
Endpoint
POST /v1/segments
Request example
curl -X POST 'https://ma-api.engagelab.com/v1/segments' \
-H 'Authorization: Basic {base64(api_key:api_secret)}' \
-H 'Content-Type: application/json' \
-d '{
"name": "High-value users",
"description": "High-value user list synced from the order system"
}'
Request parameters
| Field | Type | Required | Description |
|---|---|---|---|
name |
String | Yes | Segment name. Cannot be empty, up to 50 characters; must be unique within the project. Leading and trailing spaces are trimmed. |
description |
String | No | Segment description, up to 200 characters. |
Response example
{
"code": 0,
"message": "success",
"data": {
"segmentId": 123456789,
"name": "High-value users",
"generation": "generation-1"
}
}
| Field | Type | Description |
|---|---|---|
segmentId |
Long | ID of the new segment, used for subsequent list uploads. |
name |
String | Segment name. |
generation |
String | Current member generation identifier. A newly created segment has no members. |
Update segment members
A single endpoint overrides, appends, or removes list members. Only segments in the current project that were created via list upload, use manual update, and are active are accepted. User identifiers must match existing active users in the project; the API does not create user assets. When the segment does not qualify, errors 55210–55214 are returned (see Error responses).
Endpoint
POST /v1/segments/{segmentId}/members
Request example
The following example splits one OVERRIDE operation into two batches. Each batchId represents one list operation; all batches must use the same batchId, operation, and batchCount. OVERRIDE applies the list change only after all batches are received. APPEND and REMOVE take effect as soon as each batch request succeeds.
curl -X POST 'https://ma-api.engagelab.com/v1/segments/123456789/members' \
-H 'Authorization: Basic {base64(api_key:api_secret)}' \
-H 'Content-Type: application/json' \
-d '{
"batchId": "crm-sync-20260915-001",
"operation": "OVERRIDE",
"batchIndex": 0,
"batchCount": 2,
"members": [
{"euid": "100001"},
{"identityName": "user_id", "identityValue": "user-002"}
]
}'
When the first OVERRIDE batch is received, status in the response is RECEIVING and complete is false. Submit the remaining batch with the same batchId and set batchIndex to 1.
Request parameters
| Field | Type | Required | Description |
|---|---|---|---|
segmentId |
Long | Yes | Path parameter: target segment ID. |
batchId |
String | Yes | Batch ID for one complete list operation, up to 128 characters, letters, digits, dots, underscores, colons, and hyphens only. Used as an idempotency key per project and segment within 24 hours. |
operation |
String | Yes | List operation: OVERRIDE (replace), APPEND (add), REMOVE (remove). |
batchIndex |
Integer | Yes | Index of the current batch, starting at 0, and must be less than batchCount. |
batchCount |
Integer | Yes | Total number of batches for this operation, 1–10. All batches combined may include at most 10,000 member identifiers. |
members |
Array<Object> |
Yes | Member identifiers in the current batch. Cannot be empty; up to 1,000 per batch. Each element uses one of the formats in the table below. |
members elements support the following two formats; euid cannot be sent together with identityName / identityValue:
| Field | Type | Description |
|---|---|---|
euid |
String | Project EUID; must be a positive integer string, e.g. "100001". |
identityName |
String | Configured user identity name in the project. Cannot be empty, up to 128 characters. |
identityValue |
String | Identity value. Cannot be empty, up to 256 characters; used with identityName. Values over 256 characters do not fail the whole request; the row is counted in invalidCount. |
List operations
| Operation | Description |
|---|---|
OVERRIDE |
After all batches are received, replace the current list with users matched in this submission. If no active users are matched, the request is rejected with 55214 and the existing list is unchanged. |
APPEND |
After the current batch succeeds, add matched users to the list; users already in the segment are not duplicated. Other batches are not waited on. |
REMOVE |
After the current batch succeeds, remove matched users from the list; users not in the segment cause no extra change. Other batches are not waited on. |
Retries with the same batchId must use the same operation, batchCount, and batch content; the same batchId and batchIndex cannot carry different content. Idempotent results are kept for 24 hours.
OVERRIDE batches are held until all are received, then applied; held data expires after a 24-hour TTL, and the list is not changed if batches are incomplete before expiry. Each APPEND and REMOVE batch applies independently; batchCount and batchIndex still identify batches, support idempotency, and track progress without blocking the current batch.
Each successful list change is recorded in segment update history with source REST API. OVERRIDE is logged per completed batch; APPEND and REMOVE per successful batch. Audit records do not include samples of unmatched or invalid identifiers.
Response examples
Batch not yet complete:
{
"code": 0,
"message": "success",
"data": {
"batchId": "crm-sync-20260915-001",
"operation": "OVERRIDE",
"status": "RECEIVING",
"complete": false,
"expectedBatchCount": 2,
"receivedBatchCount": 1,
"inputCount": 2,
"matchedCount": 2,
"unmatchedCount": 0,
"unmatchedSamples": [],
"unmatchedSamplesTruncated": false,
"invalidCount": 0,
"invalidSamples": [],
"invalidSamplesTruncated": false,
"enterCount": 0,
"exitCount": 0
}
}
OVERRIDE batch completed:
{
"code": 0,
"message": "success",
"data": {
"batchId": "crm-sync-20260915-001",
"operation": "OVERRIDE",
"status": "COMPLETED",
"complete": true,
"expectedBatchCount": 2,
"receivedBatchCount": 2,
"inputCount": 3,
"matchedCount": 2,
"unmatchedCount": 1,
"unmatchedSamples": [
{"identityName": "user_id", "identityValue": "user-not-found"}
],
"unmatchedSamplesTruncated": false,
"invalidCount": 1,
"invalidSamples": [
{"identityName": "not_configured", "identityValue": "example"}
],
"invalidSamplesTruncated": false,
"enterCount": 2,
"exitCount": 1
}
}
When an APPEND or REMOVE batch succeeds, the current batch applies immediately and returns complete: true even if batchCount is greater than the number of batches received so far. For example, with batchCount 2 and only the first batch received, receivedBatchCount is 1 and status is COMPLETED.
{
"code": 0,
"message": "success",
"data": {
"batchId": "crm-sync-20260915-append",
"operation": "APPEND",
"status": "COMPLETED",
"complete": true,
"expectedBatchCount": 2,
"receivedBatchCount": 1,
"inputCount": 2,
"matchedCount": 1,
"unmatchedCount": 1,
"unmatchedSamples": [
{"identityName": "user_id", "identityValue": "user-not-found"}
],
"unmatchedSamplesTruncated": false,
"invalidCount": 0,
"invalidSamples": [],
"invalidSamplesTruncated": false,
"enterCount": 1,
"exitCount": 0
}
}
| Field | Type | Description |
|---|---|---|
batchId |
String | Batch ID for this list operation. |
operation |
String | List operation for this request. |
status |
String | RECEIVING: OVERRIDE waiting for batches; PROCESSING: waiting for list change lock; COMPLETED: current operation finished. |
complete |
Boolean | For OVERRIDE, all batches applied; for APPEND/REMOVE, current batch applied—not all batches necessarily submitted. |
expectedBatchCount |
Integer | Expected total batch count. |
receivedBatchCount |
Integer | Count of distinct batch indices received; for APPEND/REMOVE, used for statistics only and does not block the current batch. |
inputCount |
Integer | Valid input rows = matchedCount + unmatchedCount, excluding invalid identifiers. OVERRIDE counts received batches (full batch when complete); APPEND/REMOVE count the current batch. |
matchedCount |
Integer | Identifiers matched to active users. |
unmatchedCount |
Integer | Identifiers not matched to active users. |
unmatchedSamples |
Array<Object> |
Sample unmatched identifiers, same structure as request members, up to 100. |
unmatchedSamplesTruncated |
Boolean | Whether unmatched samples were truncated at 100. |
invalidCount |
Integer | Invalid identifiers, not included in inputCount. Includes: non-positive-integer euid, euid sent with identity fields, empty or mismatched identityName/identityValue, identityName over 128 characters, identityValue over 256 characters, identity name not configured, one identity matching multiple active users. |
invalidSamples |
Array<Object> |
Sample invalid identifiers, same structure as request members, up to 100. |
invalidSamplesTruncated |
Boolean | Whether invalid samples were truncated at 100. |
enterCount |
Integer | Users actually added to the segment in this execution. |
exitCount |
Integer | Users actually removed from the segment in this execution. |
Samples follow the member identifier object structure from the request and may include the submitted identityValue. The server stores samples only in the 24-hour idempotency cache, not in audit records; handle responses and logs per your data compliance requirements.
If the response is PROCESSING, retry with the same batchId, batchIndex, and original batch content for an idempotent result. There is no separate batch progress query API.
Error responses
Errors use code and message; see HTTP Status Codes for HTTP status codes and general return codes.
| HTTP status | Code | Description |
|---|---|---|
| 401 | 40050 |
API Key / API Secret authentication failed, or the API data source is disabled. |
| 400 | 40026 |
A user segment with the same name already exists in the project (create path, Metadata passthrough). |
| 400 | 40032 |
User segment count limit reached (create path, Metadata passthrough). |
| 400 | 55201 |
User segment does not exist (list upload path). |
| 400 | 55210 |
Segment creation method does not support REST API list upload: target segment was not created via list upload (e.g. rule-based segment). |
| 400 | 55211 |
Segment update mode does not support REST API list upload: target segment is not manually updated. |
| 400 | 55212 |
Segment lifecycle state does not support REST API list upload: target segment is not active. |
| 400 | 55213 |
Segment has no available member generation; REST API list upload is not supported temporarily. |
| 400 | 55214 |
Empty list override not allowed: after all OVERRIDE batches, no active users were matched. |
| 400 | 55004 |
Request fields or list batch parameters are invalid. |
| 503 | 55207 |
Segment metadata temporarily unavailable. |
| 500 | 55000 |
Internal server error. |
When creating a segment, business error codes and message from Metadata are passed through to the caller, e.g. duplicate name 40026, limit 40032. On the list upload path, “segment does not exist” returns 55201 instead of 40027.
Unmatched or invalid member identifiers do not fail the whole list operation (except
OVERRIDEwhen no users match; see55214). The response returns counts and up to 100 identifier samples. Samples may includeidentityValue; protect response data accordingly.










