POST /api/list.php
This endpoint is used to create or update a user-made segment of an organization’s subscribers.
Request parameters
Parameter | Value |
id | Segment ID.Note! Only specify this parameter when updating a segment. |
name | Name of the segment. Required. |
filter_type | Parameter to specify the inclusion of conditions. Possible values: ALL - subscriber data must conform to all the segmentation rules;ANY - subscriber data must conform with at least one of the specified segmentation rules.Required. |
filter_data | List of segmentation rules. See “Structure of a segmentation rule” for more information. Required. |
Response parameters
All possible response codes and their descriptions can be found in the “Response codes” page.
Parameter | Value |
code | Response code. |
message | Human-readable response message. |
id | Created or updated segment ID. |
Structure of a segmentation rule
[field, [operator, value]]
For example: ["email", ["EndsWith", "@domain.tld"]]
Possible operators – Equal
, NotEqual
, BeginsWith
, Contains
, DoesNotContain
, EndsWith
, LessThan
, LessThanEqual
, GreaterThanEqual
and GreaterThan
.
Examples
Create a segment
$ curl -X POST -u "${USERNAME}:${PASSWORD}" \ -H "Content-Type: application/json" \ -d '{"name": "Women", "filter_type": "ALL", "filter_data": [["gender", ["Equal", "women"]]]}' \ "https://${SUBDOMAIN}.sendsmaily.net/api/list.php"
(JavaScript/JSON)
{ "code": 101, "message": "OK", "id": 1, }
Update a segment
$ curl -X POST -u "${USERNAME}:${PASSWORD}" \ -H "Content-Type: application/json" \ -d '{"id": 2, "name": "Men 40+", "filter_type": "ALL", "filter_data": [["gender", ["Equal", "men"]], ["age", ["GreaterThanEqual", "40"]]]}' \ "https://${SUBDOMAIN}.sendsmaily.net/api/list.php"
(JavaScript/JSON)
{ "code": 101, "message": "OK", "id": 2, }