Create a new segment for a mailinglist
SOAP Action: CreateSegment
SOAP Return Object: CreateSegmentResp
The following table describes the parameters used for calling the CreateSegment service.
Parameter | Mandatory | Type | Description |
---|---|---|---|
header | Y | APIRequestHeader | Header for authentication |
parentListId | Y | Integer | Id of the parent list |
name | / | String | Name for the new segment |
language | / | String | Language of the new segment mailing list: English: EN French: FR Dutch: NL |
ruleSet | Y | RuleSetType | RuleSet to apply |
unsubscribeListId | / | Integer | ID of a list or segment on which the contact should be unsubscribed (defaults to created segment) |
optInFormId | / | Integer | ID of an opt-in form contacts will see when managing their settings (default: null) |
preferenceIds | / | Array | Array of preference IDs that will be applied when a contact is assigned to this segment. |
The following table describes the parameters returned from the CreateSegment service.
Parameter | Mandatory | Type | Description |
---|---|---|---|
header | / | APIResponseHeader | Header containing authentication information |
errorCode | / | Integer | Numerical value of the error |
errorMessage | / | String | Short literal description of the error |
referenceListId | / | Integer | ID of the new reference list that was created by the segment |
0 | No error |
---|---|
220 | Authentication error, see header object for detailed information |
221 | List ID is mandatory |
222 | List name is mandatory |
223 | List language is mandatory |
223 | List language is an invalid value |
224 | Ruleset is mandatory |
225 | Invalid ruleset |
230 | Invalid list name |
231 | Duplicate list name |
232 | Internal error on list creation |
233 | Invalid source |
500 | Internal server error |
234 | Opt-in Form ID needs to be a valid form ID |
235 | The preference module is not activated for this account |
236 | Preference ID needs to be a valid preference ID |
237 | Unsubscribe level ID needs to be a valid list ID |
238 | Invalid parent list ID |
Create a new segment with 2 rules, email must end on flexmail.be or flexmail.eu
<?php $header->userId = USER_ID; $header->userToken = USER_TOKEN; $request->header = $header; // Set the mailing list information $request->parentListId = 1; $request->name = "my new segment"; $request->language = "NL"; $ruleSet = new stdClass(); $ruleSet->rules = []; $ruleSet->ruleSets = []; // rule 1 $rule = new stdClass(); $rule->operator = ""; $rule->function = "ends with"; $rule->field = "emailAddress"; $rule->value = "flexmail.be"; $ruleSet->rules[] = $rule; // rule 2 $rule = new stdClass(); $rule->operator = "OR"; $rule->function = "ends with"; $rule->field = "emailAddress"; $rule->value = "flexmail.eu"; $ruleSet->rules[] = $rule; // assign ruleSet $request->ruleSet = $ruleSet; $response = $SoapClient->__soapCall("CreateSegment", array($request)); if ($response->errorCode == 0) { echo "Segment created"; } else { echo "Segment not created: " . $response->errorMessage; } ?>