Skip to content

Segment API Documentation

Segment management endpoints for creating, updating, and managing subscriber segments within email lists.

Create a Segment

POST /api.php

API Usage Notes

  • Authentication required: User API Key
  • Required permissions: Segment.Create
  • Legacy endpoint access via /api.php only (no v1 REST alias configured)

Request Body Parameters:

ParameterTypeRequiredDescription
CommandStringYesAPI command: segment.create
SessionIDStringNoSession ID obtained from login
APIKeyStringNoAPI key for authentication
SubscriberListIDIntegerYesID of the subscriber list
SegmentNameStringYesName of the segment
SegmentOperatorStringYesConnector between top-level rule groups: and or or. It is not applied uniformly to every rule — the connector alternates with nesting depth (see the note below).
SegmentRuleFieldArrayNoArray of rule field names (old style)
SegmentRuleOperatorArrayNoArray of rule operators (old style)
SegmentRuleFilterArrayNoArray of rule filter values (old style)
RulesJsonStringNoSegment rules in JSON format
RandomnessBooleanNoPick a random audience matching the segment rules. Accepts true/false/yes/no/1/0. Defaults to false. Persisted as the Randomness key inside the segment's Options JSON blob (round-trips via Segments.Get).
RandomnessAudienceSizeIntegerNoMaximum number of subscribers to pick when Randomness is enabled. Non-numeric values silently coerce to 0. Defaults to 0. Persisted as the RandomnessAudienceSize key inside the segment's Options JSON blob.

SegmentOperator alternates with nesting depth

SegmentOperator sets the connector between top-level groups in RulesJson. It is not applied to every rule uniformly — the connector flips at each level of nesting:

SegmentOperatorBetween groupsInside one groupInside a sub-group
andANDORAND
orORANDOR

So SegmentOperator: "or" with several rules in a single RulesJson group ANDs those rules together. To OR a set of rules, put each one in its own group. The structure of RulesJson — not SegmentOperator alone — determines the resolved audience.

Only three levels are evaluated (groups, sub-groups, and their rules); anything nested deeper is ignored by the segment engine. Changing SegmentOperator on an existing segment re-resolves its audience in both directions, since the within-group connector flips as well.

bash
curl -X POST https://example.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "Command": "segment.create",
    "SessionID": "your-session-id",
    "SubscriberListID": 123,
    "SegmentName": "Active Subscribers",
    "SegmentOperator": "and",
    "RulesJson": "{\"rules\":[{\"field\":\"status\",\"operator\":\"equals\",\"value\":\"active\"}]}",
    "Randomness": true,
    "RandomnessAudienceSize": 500
  }'
json
{
  "Success": true,
  "ErrorCode": 0,
  "ErrorText": "",
  "SegmentID": 456
}
json
{
  "Success": false,
  "ErrorCode": [1, 2, 3],
  "ErrorText": ["Missing subscriber list id", "Missing segment name", "Missing segment operator"]
}
txt
0: Success
1: Missing subscriber list id
2: Missing segment name
3: Missing segment operator
4: List not found or doesn't belong to user

Update a Segment

POST /api.php

API Usage Notes

  • Authentication required: User API Key
  • Required permissions: Segment.Update
  • Legacy endpoint access via /api.php only (no v1 REST alias configured)

Request Body Parameters:

ParameterTypeRequiredDescription
CommandStringYesAPI command: segment.update
SessionIDStringNoSession ID obtained from login
APIKeyStringNoAPI key for authentication
SegmentIDIntegerYesID of the segment to update
SegmentNameStringYesName of the segment
SubscriberListIDIntegerNoID of the subscriber list (to move segment). Must be a numeric ID of a list owned by the authenticated user — otherwise the update aborts with error code 6. Non-numeric values (e.g. 12abc, 0) are silently ignored and the segment keeps its current list.
SegmentOperatorStringNoConnector between top-level rule groups: and or or. It is not applied uniformly to every rule — the connector alternates with nesting depth (see the note under segment.create). Changing it re-resolves the segment's audience, because the connector inside each group flips too.
SegmentRuleFieldArrayNoArray of rule field names (old style)
SegmentRuleOperatorArrayNoArray of rule operators (old style)
SegmentRuleFilterArrayNoArray of rule filter values (old style)
RulesJsonStringNoSegment rules in JSON format
RandomnessBooleanNoPick a random audience matching the segment rules. Accepts true/false/yes/no/1/0. When this parameter is omitted (or sent as an empty string) along with RandomnessAudienceSize, the segment's existing Options value is preserved as-is. When at least one of the two randomness params is provided, the missing one is read from the segment's existing Options blob (no silent reset to defaults).
RandomnessAudienceSizeIntegerNoMaximum number of subscribers to pick when Randomness is enabled. Non-numeric values silently coerce to 0. When this parameter is omitted (or sent as an empty string) along with Randomness, the segment's existing Options value is preserved as-is. When at least one of the two randomness params is provided, the missing one is read from the segment's existing Options blob.
bash
curl -X POST https://example.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "Command": "segment.update",
    "SessionID": "your-session-id",
    "SegmentID": 456,
    "SegmentName": "Updated Active Subscribers",
    "SegmentOperator": "or",
    "Randomness": true,
    "RandomnessAudienceSize": 500
  }'
json
{
  "Success": true,
  "ErrorCode": 0,
  "ErrorText": ""
}
json
{
  "Success": false,
  "ErrorCode": [1, 2, 4],
  "ErrorText": ["Missing segment id", "Missing segment name", "Invalid segment id"]
}
txt
0: Success
1: Missing segment id
2: Missing segment name
4: Invalid segment id
5: Invalid segment operator
6: Invalid subscriber list id

SubscriberListID ownership

When SubscriberListID is supplied, the target list is looked up scoped to the authenticated user. A list belonging to another account is therefore indistinguishable from one that does not exist — both return Success: false with ErrorCode: [6] and ErrorText: ["Invalid subscriber list id"], and the update aborts before any change is written.

This response is returned with HTTP 200, like every other error from this legacy endpoint — always branch on the Success / ErrorCode fields in the body, not on the HTTP status.

Non-numeric values ("12abc", "0") fail the numeric guard and are silently ignored: no error is raised and the segment keeps its existing list. Ownership of the segment itself is checked separately and reports error code 4 (Invalid segment id).

Copy Segments

POST /api.php

API Usage Notes

  • Authentication required: User API Key
  • Required permissions: Segment.Create
  • Legacy endpoint access via /api.php only (no v1 REST alias configured)

Request Body Parameters:

ParameterTypeRequiredDescription
CommandStringYesAPI command: segments.copy
SessionIDStringNoSession ID obtained from login
APIKeyStringNoAPI key for authentication
SourceListIDIntegerYesID of the source subscriber list
TargetListIDIntegerYesID of the target subscriber list
bash
curl -X POST https://example.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "Command": "segments.copy",
    "SessionID": "your-session-id",
    "SourceListID": 123,
    "TargetListID": 789
  }'
json
{
  "Success": true,
  "ErrorCode": 0,
  "ErrorText": ""
}
json
{
  "Success": false,
  "ErrorCode": [1, 2, 4],
  "ErrorText": ["Missing required field"]
}
txt
0: Success
1: Missing sourcelistid
2: Missing targetlistid
4: Invalid source subscriber id or Invalid target subscriber id

Delete Segments

POST /api.php

API Usage Notes

  • Authentication required: User API Key
  • Required permissions: Segments.Delete
  • Legacy endpoint access via /api.php only (no v1 REST alias configured)

Request Body Parameters:

ParameterTypeRequiredDescription
CommandStringYesAPI command: segments.delete
SessionIDStringNoSession ID obtained from login
APIKeyStringNoAPI key for authentication
SegmentsStringYesComma-separated list of segment IDs to delete
bash
curl -X POST https://example.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "Command": "segments.delete",
    "SessionID": "your-session-id",
    "Segments": "456,457,458"
  }'
json
{
  "Success": true,
  "ErrorCode": 0,
  "ErrorText": ""
}
json
{
  "Success": false,
  "ErrorCode": [1],
  "ErrorText": ["Segment ids are missing"]
}
txt
0: Success
1: Segment ids are missing

Get Segments

POST /api.php

API Usage Notes

  • Authentication required: User API Key
  • Required permissions: Segments.Get
  • Legacy endpoint access via /api.php only (no v1 REST alias configured)

Request Body Parameters:

ParameterTypeRequiredDescription
CommandStringYesAPI command: segments.get
SessionIDStringNoSession ID obtained from login
APIKeyStringNoAPI key for authentication
SubscriberListIDIntegerYesID of the subscriber list
SegmentIDIntegerNoID of specific segment to retrieve
IncludeTotalsBooleanNoInclude total counts (default: true)
OrderFieldStringNoField to order by: SegmentName, SegmentID, SegmentOperator, SubscriberCount, SubscriberCountLastCalculatedOn (default: SegmentName)
OrderTypeStringNoSort order: ASC or DESC (default: DESC)
bash
curl -X POST https://example.com/api.php \
  -H "Content-Type: application/json" \
  -d '{
    "Command": "segments.get",
    "SessionID": "your-session-id",
    "SubscriberListID": 123,
    "OrderField": "SegmentName",
    "OrderType": "ASC"
  }'
json
{
  "Success": true,
  "ErrorCode": 0,
  "ErrorText": "",
  "TotalSegmentCount": 5,
  "Segments": [
    {
      "SegmentID": 456,
      "SegmentName": "Active Subscribers",
      "SegmentOperator": "and",
      "SubscriberCount": 1250,
      "SegmentRules": "...",
      "SegmentRulesJson": "{...}"
    }
  ]
}
json
{
  "Success": false,
  "ErrorCode": [1],
  "ErrorText": "Missing subscriber list id"
}
txt
0: Success
1: Missing subscriber list id

Any questions? Contact us.