Skip to main content
Version: 10

Segmentation population API endpoints

Level: advanced
note

This functionality is available for Creatio 10.2 and later.

The Segmentation population API is part of the Segmentation Engine API. The Segmentation population API provides endpoints that manage the members of a segment whose population mode is "Direct list" through REST API calls. Such a segment has no entry or exit rules: an external system or a business process adds, removes, replaces, and clears its members. Learn more: Populate a segment through the API or a business process.

The AddMembers, RemoveMembers, ReplaceMembers, and ClearMembers endpoints are called membership endpoints. The membership endpoints work only for an active segment whose population mode is "Direct list." Creatio rejects calls for a segment that is not activated yet, is paused, or is populated by rules. A membership call never changes the population status or the segment status. The only exception is a call that finds the membership table of the segment missing: such a call sets the population status to "Error." Learn more: Error handling.

Each call runs synchronously on behalf of the authenticated user and applies all changes in a single transaction. Creatio applies calls on a segment one after another. A call that waits for another call on the same segment longer than the lock timeout is rejected with the "Busy" rejection. The "Segment membership lock timeout (seconds)" (SegmentMembershipLockTimeout code) system setting specifies the timeout. Out of the box, the value is set to "30" (seconds). If the setting is empty or set to "0," Creatio uses the out-of-the-box value.

To call the endpoints, the user needs permission to edit the "Segments" (SysDataSegment code) object and access to read and edit the segment record.

Add members to a segment​

Request string​

Request string
POST /0/rest/SegmentService/AddMembers

Add contacts to a segment whose population mode is "Direct list." Creatio processes the requested contacts as follows:

  • Adds contacts that are not segment members.
  • Restores contacts that were removed from the segment earlier and sets a new AddedOn date for them.
  • Leaves current members unchanged.

The call is idempotent. If you repeat it with the same data, Creatio returns the "NoChanges" outcome, and the alreadyInSegmentCount property is equal to the number of requested contacts, so a retry is safe. The "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies the maximum number of contacts per call. Out of the box, the value is set to "100000." If the setting is empty or set to "0," Creatio uses the out-of-the-box value. If the list of contacts exceeds the maximum number of contacts per call, split it into several calls and send them one after another. The end result is the same as for a single call.

Request headers​

Use either OAuth 2.0 authorization or cookie-based authentication. OAuth 2.0 authorization works only on a Creatio instance that uses the Identity Service. On an instance without it, use cookie-based authentication.

Header

Description

Content-Type

The media type of the request body. Set to "application/json."

Authorization

OAuth 2.0 authorization only. Bearer {access token}, where the Identity Service issues the access token to a registered integration. Do not send the Cookie and CRT_CSRF headers with it. Learn more: Authorize external requests using client credentials grant.

CRT_CSRF

Cookie-based authentication only. CSRF protection token. Set to the value of the CRT_CSRF cookie that the authentication request returned.

Cookie

Cookie-based authentication only. Every cookie that the AuthService.svc/Login authentication request returned, for example, the .ASPXAUTH and CRT_CSRF cookies. Send all of them: on .NET, the CSRF check also requires the CsrfToken cookie. Learn more: AuthService.svc web service.

Request body​

Parameter

Type

Required

Description

segmentId

Guid

Yes

The ID of the "Segments" (SysDataSegment code) object record whose members to change.

recordIds

array of Guid

Required, only if filterData is not defined

The IDs of the contacts to add. Creatio counts a duplicate ID once and ignores an empty ID (00000000-0000-0000-0000-000000000000). The "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies the maximum number of distinct IDs per call. Out of the box, the value is set to "100000." If the setting is empty or set to "0," Creatio uses the out-of-the-box value.

filterData

string

Required, only if recordIds is not defined

A filter that selects the contacts to add, serialized to a JSON string. Uses the same format as an entry filter. Learn more: Filter segments. The filter must contain at least one enabled condition. Creatio evaluates the filter on the "Contact" (Contact code) object with the access permissions of the user who calls the endpoint. Set the rootSchemaName property to "Contact" or omit it. Creatio compares the value case-insensitively and rejects a filter built on an object other than "Contact" (Contact code). The filter can select at most the number of contacts that the "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies. Out of the box, the value is set to "100000."

Send exactly one of the recordIds and filterData parameters. Creatio treats a parameter as sent when it is present and not "null," whatever its value, so an empty array or an empty string counts as sent. Creatio rejects the following request bodies with the "InvalidRequest" rejection:

  • both the recordIds and filterData parameters, even if one of the parameters is empty;
  • neither the recordIds nor the filterData parameter;
  • an empty recordIds parameter array, or an array that contains only empty IDs;
  • a filterData value that is blank, is not valid JSON, or has no enabled condition;
  • a filterData value whose rootSchemaName property specifies an object other than "Contact" (Contact code).

Response body​

Creatio returns enumeration values as names, for example, "Applied," not as numbers. The response also contains the removedCount and notInSegmentCount properties, which are "0" for this endpoint. The following table lists the properties of the response body.

Property

Type

Description

success

boolean

Indicates whether the call succeeded.

Available values

Value

Description

true

The outcome property is "Applied" or "NoChanges."

false

The outcome property is "Rejected" or "Failed."

segmentId

Guid

The requested segment ID.

outcome

string

The outcome of the call.

Available values

Value

Description

Applied

The members changed.

NoChanges

The call is valid, but there was nothing to change, for example, the same call was repeated.

Rejected

Creatio did not attempt the change. The rejection property names the reason.

Failed

A step of the call failed, and Creatio committed no change to the members.

rejection

string

The reason for the "Rejected" outcome, or "None." Learn more: Error handling.

Available values

Value

Description

None

Creatio did not reject the call.

InvalidRequest

The request body breaks the input rules.

SegmentNotFound

No segment has this ID, or the user cannot read the segment.

NotProcessDriven

The population mode of the segment is not "Direct list."

Paused

The segment is paused.

Draft

The segment is not activated yet.

AccessDenied

The user has no permission to edit the segment.

Busy

Another membership call is changing the same segment.

TooManyRecords

The request exceeds the maximum number of contacts per call.

message

string

The description of the rejection or failure, or a warning about a successful call. Creatio returns the property only when there is something to report. The text can change between versions, so check the rejection property instead of parsing the message.

requestedCount

integer

The number of distinct IDs in the request, or the number of contacts that the filter selected. If the filter selects more contacts than the limit, the value is the limit plus one.

insertedCount

integer

The number of contacts added as new members.

restoredCount

integer

The number of contacts that were removed earlier and restored with a new AddedOn date.

alreadyInSegmentCount

integer

The number of requested contacts that already were current members.

notFoundCount

integer

The number of IDs that do not match a contact the user can read. Creatio does not distinguish an unknown ID from a contact the user cannot read.

totalActiveMembers

integer

The number of active members after the call. Creatio copies the value to the "Current contacts" (RecordCount code) column of the "Segments" (SysDataSegment code) object. The value is valid only when the success property is "true" and the response contains no message property. If the response contains the member count warning, the value can be "0."

startedOn

string

The date and time when the call started, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

completedOn

string

The date and time when the call completed, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

Usage example​

The following example adds the contacts whose IDs are "22222222-2222-2222-2222-222222222222" and "33333333-3333-3333-3333-333333333333" to the segment whose ID is "11111111-1111-1111-1111-111111111111" using OAuth 2.0 authorization.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/AddMembers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access token}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111",
"recordIds": [
"22222222-2222-2222-2222-222222222222",
"33333333-3333-3333-3333-333333333333"
]
}'

The following example adds the contacts whose IDs are "22222222-2222-2222-2222-222222222222" and "33333333-3333-3333-3333-333333333333" to the segment whose ID is "11111111-1111-1111-1111-111111111111" using cookie-based authentication. Replace {login cookies} with every cookie that the authentication request returned, in the name=value; name=value format, and {csrf token} with the value of the CRT_CSRF cookie.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/AddMembers" \
-H "Content-Type: application/json" \
-H "CRT_CSRF: {csrf token}" \
-H "Cookie: {login cookies}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111",
"recordIds": [
"22222222-2222-2222-2222-222222222222",
"33333333-3333-3333-3333-333333333333"
]
}'

Remove members from a segment​

Request string​

Request string
POST /0/rest/SegmentService/RemoveMembers

Remove members from a segment whose population mode is "Direct list." Creatio marks the members as removed by setting the RemovedOn date and keeps their membership history. A later add or replace call restores them. Creatio skips requested contacts that are not current members and counts them in the notInSegmentCount property.

The call is idempotent. If you repeat it with the same data, Creatio returns the "NoChanges" outcome, and the notInSegmentCount property is equal to the number of requested contacts, so a retry is safe. If the list of members exceeds the maximum number of contacts per call, split it into several calls and send them one after another. The end result is the same as for a single call.

Request headers​

Use either OAuth 2.0 authorization or cookie-based authentication. OAuth 2.0 authorization works only on a Creatio instance that uses the Identity Service. On an instance without it, use cookie-based authentication.

Header

Description

Content-Type

The media type of the request body. Set to "application/json."

Authorization

OAuth 2.0 authorization only. Bearer {access token}, where the Identity Service issues the access token to a registered integration. Do not send the Cookie and CRT_CSRF headers with it. Learn more: Authorize external requests using client credentials grant.

CRT_CSRF

Cookie-based authentication only. CSRF protection token. Set to the value of the CRT_CSRF cookie that the authentication request returned.

Cookie

Cookie-based authentication only. Every cookie that the AuthService.svc/Login authentication request returned, for example, the .ASPXAUTH and CRT_CSRF cookies. Send all of them: on .NET, the CSRF check also requires the CsrfToken cookie. Learn more: AuthService.svc web service.

Request body​

Parameter

Type

Required

Description

segmentId

Guid

Yes

The ID of the "Segments" (SysDataSegment code) object record whose members to remove.

recordIds

array of Guid

Required, only if filterData is not defined

The IDs of the members to remove. Creatio counts a duplicate ID once and ignores an empty ID (00000000-0000-0000-0000-000000000000). The "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies the maximum number of distinct IDs per call. Out of the box, the value is set to "100000." If the setting is empty or set to "0," Creatio uses the out-of-the-box value.

filterData

string

Required, only if recordIds is not defined

A filter that selects the members to remove, serialized to a JSON string. Uses the same format as an entry filter. Learn more: Filter segments. The filter must contain at least one enabled condition. Creatio evaluates the filter on the "Contact" (Contact code) object with the access permissions of the user who calls the endpoint. Set the rootSchemaName property to "Contact" or omit it. Creatio compares the value case-insensitively and rejects a filter built on an object other than "Contact" (Contact code). The filter can select at most the number of contacts that the "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies. Out of the box, the value is set to "100000."

Send exactly one of the recordIds and filterData parameters. Creatio treats a parameter as sent when it is present and not "null," whatever its value, so an empty array or an empty string counts as sent. Creatio rejects the following request bodies with the "InvalidRequest" rejection:

  • both the recordIds and filterData parameters, even if one of the parameters is empty;
  • neither the recordIds nor the filterData parameter;
  • an empty recordIds parameter array, or an array that contains only empty IDs;
  • a filterData value that is blank, is not valid JSON, or has no enabled condition;
  • a filterData value whose rootSchemaName property specifies an object other than "Contact" (Contact code).

When the call passes IDs, Creatio removes the listed members whether or not the user can read the contact records. When the call passes a filter, Creatio evaluates the filter with the access permissions of the user, so the call removes only members that the user can read.

Response body​

Creatio returns enumeration values as names, for example, "Applied," not as numbers. The response also contains the insertedCount, restoredCount, alreadyInSegmentCount, and notFoundCount properties, which are "0" for this endpoint. The following table lists the properties of the response body.

Property

Type

Description

success

boolean

Indicates whether the call succeeded.

Available values

Value

Description

true

The outcome property is "Applied" or "NoChanges."

false

The outcome property is "Rejected" or "Failed."

segmentId

Guid

The requested segment ID.

outcome

string

The outcome of the call.

Available values

Value

Description

Applied

The members changed.

NoChanges

The call is valid, but there was nothing to change, for example, the same call was repeated.

Rejected

Creatio did not attempt the change. The rejection property names the reason.

Failed

A step of the call failed, and Creatio committed no change to the members.

rejection

string

The reason for the "Rejected" outcome, or "None." Learn more: Error handling.

Available values

Value

Description

None

Creatio did not reject the call.

InvalidRequest

The request body breaks the input rules.

SegmentNotFound

No segment has this ID, or the user cannot read the segment.

NotProcessDriven

The population mode of the segment is not "Direct list."

Paused

The segment is paused.

Draft

The segment is not activated yet.

AccessDenied

The user has no permission to edit the segment.

Busy

Another membership call is changing the same segment.

TooManyRecords

The request exceeds the maximum number of contacts per call.

message

string

The description of the rejection or failure, or a warning about a successful call. Creatio returns the property only when there is something to report. The text can change between versions, so check the rejection property instead of parsing the message.

requestedCount

integer

The number of distinct IDs in the request, or the number of contacts that the filter selected. If the filter selects more contacts than the limit, the value is the limit plus one.

removedCount

integer

The number of removed members.

notInSegmentCount

integer

The number of requested contacts that were not current members.

totalActiveMembers

integer

The number of active members after the call. Creatio copies the value to the "Current contacts" (RecordCount code) column of the "Segments" (SysDataSegment code) object. The value is valid only when the success property is "true" and the response contains no message property. If the response contains the member count warning, the value can be "0."

startedOn

string

The date and time when the call started, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

completedOn

string

The date and time when the call completed, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

Usage example​

The following example removes the "22222222-2222-2222-2222-222222222222" member and the "44444444-4444-4444-4444-444444444444" contact, which is not a member, from the segment whose ID is "11111111-1111-1111-1111-111111111111" using OAuth 2.0 authorization.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/RemoveMembers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access token}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111",
"recordIds": [
"22222222-2222-2222-2222-222222222222",
"44444444-4444-4444-4444-444444444444"
]
}'

The following example removes the "22222222-2222-2222-2222-222222222222" member and the "44444444-4444-4444-4444-444444444444" contact, which is not a member, from the segment whose ID is "11111111-1111-1111-1111-111111111111" using cookie-based authentication. Replace {login cookies} with every cookie that the authentication request returned, in the name=value; name=value format, and {csrf token} with the value of the CRT_CSRF cookie.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/RemoveMembers" \
-H "Content-Type: application/json" \
-H "CRT_CSRF: {csrf token}" \
-H "Cookie: {login cookies}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111",
"recordIds": [
"22222222-2222-2222-2222-222222222222",
"44444444-4444-4444-4444-444444444444"
]
}'

Replace segment members​

Request string​

Request string
POST /0/rest/SegmentService/ReplaceMembers

Make the active members of a segment whose population mode is "Direct list" equal to the given list of contacts. In a single transaction, Creatio removes the current members that are not in the list and adds the contacts of the list that are not members. Members that stay keep their AddedOn date. Users and queries that read the segment never see it empty or partially replaced.

The call is idempotent. If you repeat it with the same data, Creatio returns the "NoChanges" outcome, and the alreadyInSegmentCount property is equal to the number of requested contacts that the user can read, so a retry is safe.

Request headers​

Use either OAuth 2.0 authorization or cookie-based authentication. OAuth 2.0 authorization works only on a Creatio instance that uses the Identity Service. On an instance without it, use cookie-based authentication.

Header

Description

Content-Type

The media type of the request body. Set to "application/json."

Authorization

OAuth 2.0 authorization only. Bearer {access token}, where the Identity Service issues the access token to a registered integration. Do not send the Cookie and CRT_CSRF headers with it. Learn more: Authorize external requests using client credentials grant.

CRT_CSRF

Cookie-based authentication only. CSRF protection token. Set to the value of the CRT_CSRF cookie that the authentication request returned.

Cookie

Cookie-based authentication only. Every cookie that the AuthService.svc/Login authentication request returned, for example, the .ASPXAUTH and CRT_CSRF cookies. Send all of them: on .NET, the CSRF check also requires the CsrfToken cookie. Learn more: AuthService.svc web service.

Request body​

You cannot split a replace call into several calls, since each call makes the segment equal to its own list. If the list exceeds the maximum number of contacts per call, clear the segment and add the contacts in several calls. Between these calls, the segment is partially filled, and campaigns and filters that use it see that state. If the external system stores the list it sent previously, send only the difference instead: call the RemoveMembers endpoint for the contacts that left the list and the AddMembers endpoint for the contacts that joined it.

Parameter

Type

Required

Description

segmentId

Guid

Yes

The ID of the "Segments" (SysDataSegment code) object record whose members to replace.

recordIds

array of Guid

Required, only if filterData is not defined

The IDs of the contacts that the segment must contain after the call. Creatio counts a duplicate ID once and ignores an empty ID (00000000-0000-0000-0000-000000000000). The "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies the maximum number of distinct IDs per call. Out of the box, the value is set to "100000." If the setting is empty or set to "0," Creatio uses the out-of-the-box value.

filterData

string

Required, only if recordIds is not defined

A filter that selects the contacts that the segment must contain after the call, serialized to a JSON string. Uses the same format as an entry filter. Learn more: Filter segments. The filter must contain at least one enabled condition. Creatio evaluates the filter on the "Contact" (Contact code) object with the access permissions of the user who calls the endpoint. Set the rootSchemaName property to "Contact" or omit it. Creatio compares the value case-insensitively and rejects a filter built on an object other than "Contact" (Contact code). The filter can select at most the number of contacts that the "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies. Out of the box, the value is set to "100000."

Send exactly one of the recordIds and filterData parameters. Creatio treats a parameter as sent when it is present and not "null," whatever its value, so an empty array or an empty string counts as sent. Creatio rejects the following request bodies with the "InvalidRequest" rejection:

  • both the recordIds and filterData parameters, even if one of the parameters is empty;
  • neither the recordIds nor the filterData parameter;
  • an empty recordIds parameter array, or an array that contains only empty IDs;
  • a filterData value that is blank, is not valid JSON, or has no enabled condition;
  • a filterData value whose rootSchemaName property specifies an object other than "Contact" (Contact code).

Response body​

Creatio returns enumeration values as names, for example, "Applied," not as numbers. The response also contains the notInSegmentCount property, which is "0" for this endpoint. The following table lists the properties of the response body.

Property

Type

Description

success

boolean

Indicates whether the call succeeded.

Available values

Value

Description

true

The outcome property is "Applied" or "NoChanges."

false

The outcome property is "Rejected" or "Failed."

segmentId

Guid

The requested segment ID.

outcome

string

The outcome of the call.

Available values

Value

Description

Applied

The members changed.

NoChanges

The call is valid, but there was nothing to change, for example, the same call was repeated.

Rejected

Creatio did not attempt the change. The rejection property names the reason.

Failed

A step of the call failed, and Creatio committed no change to the members.

rejection

string

The reason for the "Rejected" outcome, or "None." Learn more: Error handling.

Available values

Value

Description

None

Creatio did not reject the call.

InvalidRequest

The request body breaks the input rules.

SegmentNotFound

No segment has this ID, or the user cannot read the segment.

NotProcessDriven

The population mode of the segment is not "Direct list."

Paused

The segment is paused.

Draft

The segment is not activated yet.

AccessDenied

The user has no permission to edit the segment.

Busy

Another membership call is changing the same segment.

TooManyRecords

The request exceeds the maximum number of contacts per call.

message

string

The description of the rejection or failure, or a warning about a successful call. Creatio returns the property only when there is something to report. The text can change between versions, so check the rejection property instead of parsing the message.

requestedCount

integer

The number of distinct IDs in the request, or the number of contacts that the filter selected. If the filter selects more contacts than the limit, the value is the limit plus one.

insertedCount

integer

The number of contacts added as new members.

restoredCount

integer

The number of contacts that were removed earlier and restored with a new AddedOn date.

alreadyInSegmentCount

integer

The number of requested contacts that already were current members.

notFoundCount

integer

The number of IDs that do not match a contact the user can read. Creatio does not distinguish an unknown ID from a contact the user cannot read.

removedCount

integer

The number of removed members.

totalActiveMembers

integer

The number of active members after the call. Creatio copies the value to the "Current contacts" (RecordCount code) column of the "Segments" (SysDataSegment code) object. The value is valid only when the success property is "true" and the response contains no message property. If the response contains the member count warning, the value can be "0."

startedOn

string

The date and time when the call started, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

completedOn

string

The date and time when the call completed, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

Creatio handles the result of a replace call as follows:

  • The segment becomes equal to the part of the list that the user can read. Creatio counts the IDs of contacts that the user cannot read in the notFoundCount property and removes the current members that are not in that part.
  • Creatio rejects with the "InvalidRequest" rejection a call that selects no contact the user can read: an empty array, IDs that are all unknown or not readable, or a filter that selects nothing. Nothing changes, so an empty or outdated source never empties the segment. To remove every member, use the ClearMembers endpoint.

Usage example​

The following example makes the segment whose ID is "11111111-1111-1111-1111-111111111111" contain only the contacts whose email contains "@creatio.com" using OAuth 2.0 authorization. The example passes the following filter in the filterData parameter.

Filter that selects contacts by email
{
"rootSchemaName": "Contact",
"filterType": 6,
"logicalOperation": 0,
"isEnabled": true,
"items": {
"EmailContainsCreatio": {
"filterType": 1,
"comparisonType": 11,
"isEnabled": true,
"leftExpression": {
"expressionType": 0,
"columnPath": "Email"
},
"rightExpression": {
"expressionType": 2,
"parameter": {
"dataValueType": 1,
"value": "@creatio.com"
}
}
}
}
}

Serialize the filter to a JSON string and pass the string in the filterData parameter.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/ReplaceMembers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access token}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111",
"filterData": "{\"rootSchemaName\":\"Contact\",\"filterType\":6,\"logicalOperation\":0,\"isEnabled\":true,\"items\":{\"EmailContainsCreatio\":{\"filterType\":1,\"comparisonType\":11,\"isEnabled\":true,\"leftExpression\":{\"expressionType\":0,\"columnPath\":\"Email\"},\"rightExpression\":{\"expressionType\":2,\"parameter\":{\"dataValueType\":1,\"value\":\"@creatio.com\"}}}}}"
}'

The following example makes the segment whose ID is "11111111-1111-1111-1111-111111111111" contain only the contacts whose email contains "@creatio.com" using cookie-based authentication. Replace {login cookies} with every cookie that the authentication request returned, in the name=value; name=value format, and {csrf token} with the value of the CRT_CSRF cookie.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/ReplaceMembers" \
-H "Content-Type: application/json" \
-H "CRT_CSRF: {csrf token}" \
-H "Cookie: {login cookies}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111",
"filterData": "{\"rootSchemaName\":\"Contact\",\"filterType\":6,\"logicalOperation\":0,\"isEnabled\":true,\"items\":{\"EmailContainsCreatio\":{\"filterType\":1,\"comparisonType\":11,\"isEnabled\":true,\"leftExpression\":{\"expressionType\":0,\"columnPath\":\"Email\"},\"rightExpression\":{\"expressionType\":2,\"parameter\":{\"dataValueType\":1,\"value\":\"@creatio.com\"}}}}}"
}'

Clear segment members​

Request string​

Request string
POST /0/rest/SegmentService/ClearMembers

Remove every current member of a segment whose population mode is "Direct list." Creatio marks the members as removed by setting the RemovedOn date. Unlike the Truncate endpoint, which deletes the membership rows and resets the population status to "Draft," clearing keeps the membership history and both statuses. Clearing a segment that has no members returns the "NoChanges" outcome.

The call is idempotent. If you repeat it, Creatio returns the "NoChanges" outcome, and the removedCount property is "0," so a retry is safe.

Request headers​

Use either OAuth 2.0 authorization or cookie-based authentication. OAuth 2.0 authorization works only on a Creatio instance that uses the Identity Service. On an instance without it, use cookie-based authentication.

Header

Description

Content-Type

The media type of the request body. Set to "application/json."

Authorization

OAuth 2.0 authorization only. Bearer {access token}, where the Identity Service issues the access token to a registered integration. Do not send the Cookie and CRT_CSRF headers with it. Learn more: Authorize external requests using client credentials grant.

CRT_CSRF

Cookie-based authentication only. CSRF protection token. Set to the value of the CRT_CSRF cookie that the authentication request returned.

Cookie

Cookie-based authentication only. Every cookie that the AuthService.svc/Login authentication request returned, for example, the .ASPXAUTH and CRT_CSRF cookies. Send all of them: on .NET, the CSRF check also requires the CsrfToken cookie. Learn more: AuthService.svc web service.

Request body​

Parameter

Type

Required

Description

segmentId

Guid

Yes

The ID of the "Segments" (SysDataSegment code) object record to clear.

Response body​

Creatio returns enumeration values as names, for example, "Applied," not as numbers. The response also contains the requestedCount, insertedCount, restoredCount, alreadyInSegmentCount, notFoundCount, and notInSegmentCount properties, which are "0" for this endpoint. The following table lists the properties of the response body.

Property

Type

Description

success

boolean

Indicates whether the call succeeded.

Available values

Value

Description

true

The outcome property is "Applied" or "NoChanges."

false

The outcome property is "Rejected" or "Failed."

segmentId

Guid

The requested segment ID.

outcome

string

The outcome of the call.

Available values

Value

Description

Applied

The members changed.

NoChanges

The call is valid, but there was nothing to change, for example, the same call was repeated.

Rejected

Creatio did not attempt the change. The rejection property names the reason.

Failed

A step of the call failed, and Creatio committed no change to the members.

rejection

string

The reason for the "Rejected" outcome, or "None." Learn more: Error handling.

Available values

Value

Description

None

Creatio did not reject the call.

InvalidRequest

The request body breaks the input rules.

SegmentNotFound

No segment has this ID, or the user cannot read the segment.

NotProcessDriven

The population mode of the segment is not "Direct list."

Paused

The segment is paused.

Draft

The segment is not activated yet.

AccessDenied

The user has no permission to edit the segment.

Busy

Another membership call is changing the same segment.

TooManyRecords

The request exceeds the maximum number of contacts per call.

message

string

The description of the rejection or failure, or a warning about a successful call. Creatio returns the property only when there is something to report. The text can change between versions, so check the rejection property instead of parsing the message.

removedCount

integer

The number of removed members.

totalActiveMembers

integer

The number of active members after the call. Creatio copies the value to the "Current contacts" (RecordCount code) column of the "Segments" (SysDataSegment code) object. The value is valid only when the success property is "true" and the response contains no message property. If the response contains the member count warning, the value can be "0."

startedOn

string

The date and time when the call started, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

completedOn

string

The date and time when the call completed, in UTC using the ISO 8601 format. Omitted when the call failed before Creatio processed it.

After a successful call, the totalActiveMembers property is "0." Creatio rejects a request body that contains the recordIds or filterData parameter with the "InvalidRequest" rejection instead of ignoring it, even if the value is an empty array or an empty string.

Usage example​

The following example clears the segment whose ID is "11111111-1111-1111-1111-111111111111" using OAuth 2.0 authorization.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/ClearMembers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer {access token}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111"
}'

The following example clears the segment whose ID is "11111111-1111-1111-1111-111111111111" using cookie-based authentication. Replace {login cookies} with every cookie that the authentication request returned, in the name=value; name=value format, and {csrf token} with the value of the CRT_CSRF cookie.

curl -s -X POST "{Creatio URL}/0/rest/SegmentService/ClearMembers" \
-H "Content-Type: application/json" \
-H "CRT_CSRF: {csrf token}" \
-H "Cookie: {login cookies}" \
-d '{
"segmentId": "11111111-1111-1111-1111-111111111111"
}'

Error handling​

Creatio returns the 200 OK HTTP status code for errors related to the request data. Check the success property of the response body instead of the HTTP status code to detect such errors. The membership endpoints name the reason in the rejection property and describe it in the message property. Check the rejection property, since the message text can change. When Creatio rejects a call, it changes nothing in the segment. Find the cause of an error and its solution by the HTTP status code or the value of the rejection property in the following table.

HTTP status code or rejection

Description

Solution

HTTP status codes

200 OK

Creatio returns this status for successful calls and for errors related to the request data.

Check the success property.

400 Bad Request

Creatio returns this status in the following cases:

  • On .NET Framework, the request body is not valid JSON or an ID is not a GUID.
  • On .NET Framework, the request body exceeds the request size limit of the web server, which is 10485760 bytes (10 MB).

On .NET, Creatio returns the 200 OK HTTP status code and the "InvalidRequest" rejection for a body that is not valid JSON or an ID that is not a GUID. The message property of such a response can refer to the segment ID even if another parameter is wrong.

Fix the request body. Do not retry the call without fixing it. Split a request that is too large. 100000 IDs make about 4 MB of JSON, which fits the limit.

401 Unauthorized,
302 Found

The session or the access token is missing or invalid. If the request has the X-Requested-With: XMLHttpRequest header, Creatio returns the 401 Unauthorized HTTP status code. Without the header, Creatio on .NET can redirect to the login page with the 302 Found HTTP status code.

Authenticate again.

403 Forbidden

A request that uses cookie-based authentication lacks the CRT_CSRF header or, on .NET, the CsrfToken cookie, or the CRT_CSRF header is invalid. For example, on .NET a request that sends only the .ASPXAUTH and CRT_CSRF cookies gets this status.

Send every cookie that the authentication request returned and the CRT_CSRF header in every POST request.

404 Not Found,
405 Method Not Allowed

The endpoint name is wrong (404 Not Found on both runtimes), or the HTTP method is not POST (405 Method Not Allowed on .NET Framework, 404 Not Found on .NET).

Check the request string. Use POST.

413 Payload Too Large

The request body exceeds the request size limit of the web server on .NET, which is 30000000 bytes (about 30 MB). On .NET Framework, Creatio returns the 400 Bad Request HTTP status code instead.

Split the request.

5xx server error

A server-side error outside the endpoint.

Retry the call later. If the error persists, contact your system administrator.

Rejections

Failed outcome

The outcome property is "Failed" and the rejection property is "None": a step of the call failed. Creatio committed no change to the members. If the call set the population status of the segment to "Error," the membership table of the segment is missing, and no retry succeeds.

Retry the call after a short delay. If the population status of the segment is "Error," re-create the segment and use the ID of the new segment instead of the old ID in API calls, business processes, and campaigns. If the call keeps failing for another reason, contact your system administrator: the details are in the application log.

InvalidRequest

The request body breaks the input rules:

  • neither or both of the recordIds and filterData parameters;
  • an empty or invalid recordIds parameter array;
  • a blank or invalid filter, or a filter without an enabled condition;
  • a filter whose rootSchemaName property specifies an object other than "Contact" (Contact code);
  • a clear call with the recordIds or filterData parameter;
  • a replace call that selects no contact the user can read.

Fix the request body. Do not retry the call without fixing it.

SegmentNotFound

No segment has this ID, or the user cannot read the segment. Creatio returns the same rejection in both cases.

Verify the ID and the access of the user to the segment.

NotProcessDriven

The population mode of the segment is "Scheduled" or "Static list."

Use the Actualize endpoint, or call the endpoint for a segment whose population mode is "Direct list."

Paused

The segment is paused.

Resume the segment, then retry the call.

Draft

The segment is not activated yet.

Activate the segment, then retry the call.

AccessDenied

The user has no permission to edit the "Segments" (SysDataSegment code) object, or can read the segment but not edit it.

Grant the permission, or call the endpoint on behalf of a user who has it.

Busy

Another membership call is changing the same segment and did not finish within the lock timeout. The "Segment membership lock timeout (seconds)" (SegmentMembershipLockTimeout code) system setting specifies the timeout. On .NET Framework, cookie-based calls that share a session wait for each other instead, however long it takes, and are not rejected with "Busy." Separate logins of the same user can share a session.

Retry the call after a short delay.

TooManyRecords

The request contains more distinct IDs than the limit, or the filter selects more contacts than the limit. The "Segment membership max records per call" (SegmentMembershipMaxRecords code) system setting specifies the limit. Out of the box, the value is set to "100000."

Split an add or remove call into several calls. For a replace call, clear the segment and add the contacts in several calls.

For example, a call for a segment that is not activated yet returns the following response.

Response
{
"success": false,
"segmentId": "11111111-1111-1111-1111-111111111111",
"outcome": "Rejected",
"rejection": "Draft",
"message": "Segment 'Loyalty program members' is a draft. Activate it to change its members.",
"requestedCount": 1,
"insertedCount": 0,
"restoredCount": 0,
"alreadyInSegmentCount": 0,
"notFoundCount": 0,
"removedCount": 0,
"notInSegmentCount": 0,
"totalActiveMembers": 0,
"startedOn": "2026-11-11T15:35:39.697Z",
"completedOn": "2026-11-11T15:35:40.026Z"
}

A response whose success property is "true" can contain a warning in the message property that Creatio changed the members but could not update the "Current contacts" (RecordCount code) column. The change is committed, but the totalActiveMembers value in such a response can be "0" and does not reflect the members.


See also​

Populate a segment through the API or a business process

Segmentation Engine API endpoints

Manage segments using Segmentation Engine API

Authorize external requests using client credentials grant

AuthService.svc web service