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
SegmentOperatorStringYesLogical operator for combining rules: and or or
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
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\"}]}"
  }'
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)
SegmentOperatorStringNoLogical operator for combining rules: and or or
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
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"
  }'
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

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.