Segments
Create
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments
HTTP request method
POST
Content-Type
application/json; charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Body-Parameters
Parameter | Type | Required | Description |
---|---|---|---|
segment_name | string | true | Segment name (maximum 48 characters, does not support the following characters: ^,?,+,.,*,,[,],(,) ) |
type | integer | true | Segment type (0 or 1) 0. by field; 1. by campaign |
condition | object | true | Segment condition |
relation | string | true | Condition relation (and or or) |
items | object[] | true | Conditions (up to 10 filtering conditions supported, all conditions have the same relation, either all and or all or) |
campaign_id | integer | false | Campaign ID If field_name=campaign, this value is required, and the status of the corresponding campaign must be in progress or completed |
field_name | string | true | 1. If type=0 field_name is the filed name, value is the filed value; field_name is "tag", value=tag name 2. If type=1 field_name must be campaign, value is one of "sent","open","click","unopen","unclick","notsent", in this case campaign_id is required and corresponds to the ID of the campaign |
op | string | true | Operator (== , != , > , >= , < , <= , contain , does not contain) When field_name=campaign, op must be ==; When field_name is an attribute name or tag, please refer to filter conditions for available ops |
value | string | true | When fieldName is "tag", value=tagName; When fieldName is an filed name, please refer to filter conditions for the format; When fieldName = "campaign", value is one of sent, open, click, unopen, unclick, notsent |
Note:
- Please refer to the corresponding relationship between field_name and op filter conditions
Request-Example
curl -X POST -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments --data '{
"segment_name": "Hubei user",
"type": 0,
"condition": {
"relation": "and",
"items": [
{
"field_name": "Name",
"op": "contain",
"value": "Lei Li"
}
]
}
}'
Response example
Response-Success
HttpStatus: 200
{
"result": {
"segment_id": "6566f6392c16e71300b1b1e9",
"user_id": 104201,
"segment_name": "MyCustomField",
"type": 0,
"list_id": 96112,
"status": "2",
"create_time": "2023-11-29 16:28:41+0800",
"update_time": "2023-11-29 16:33:58+0800",
"member_total": 1,
"condition": {
"relation": "and",
"items": [
{
"field_name": "Name",
"op": "contain",
"value": "Lei li"
}
]
},
"process": {
"statusDesc": "segmentation completed",
"complete": true,
"percent": 100
}
}
}
Response-Error
{
"code": 30035,
"message": "[segment_name]:Special characters such as ^, ?, +, ., \\, [, ], (, ), cannot be used"
}
Delete
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}
HTTP request method
DELETE
Content-Type
application/x-www-form-urlencoded;charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Request-Example
curl -X DELETE -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/6566f12d1e9adc15e3efd4
Response example
Response-Success
HttpStatus: 200
{
"count": 1
}
Response-Error
{
"code": 30036,
"message": "not found"
}
Update
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}
HTTP request method
PUT
Content-Type
application/json; charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Body-Parameters
Parameter | Type | Required | Description |
---|---|---|---|
segment_name | string | false | Group name (up to 48 characters) |
type | integer | true | Group type (0 or 1) 0. by field (grouped by attribute); 1. by campaign (grouped by performance) |
condition | object | true | Group condition |
relation | string | true | Condition relation (and or or) |
items | object[] | true | Conditions (support up to 10 filtering conditions, all must have the same relation - either all and or all or) |
campaign_id | integer | false | Marketing task ID If field_name=campaign, this value is required, and the task status for the corresponding ID must be in progress or completed |
field_name | string | true | 1. If type=0 2. If type=1 field_name must be campaign, value can be "sent", "open", "click", "unopen", "unclick", "notsent", in this case, campaignId is required and should correspond to the ID of the campaign |
op | string | true | Operator (==, !=, >, >=, <, <=, contain, does not contain) When field_name=campaign, op must be ==; when field_name is an attribute name or tag, please refer to filter conditions for available options |
value | string | true | When field_name is "tag", value=tag name; When field_name is an attribute name, refer to filter conditions for the format; when field_name = "campaign", value must be one of sent, open, click, unopen, unclick, notsent |
Note
1.Please refer to the corresponding relationship between field_name and op filter conditions.
Request-Example
curl -X PUT -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/62849dc690d79d4947dd033d --data '{
"segment_name": "Age between 13 and 45",
"type": 0,
"condition": {
"relation": "and",
"items": [
{
"field_name": "Age",
"op": ">=",
"value": "13"
},
{
"field_name": "Age",
"op": "<=",
"value": "45"
}
]
}
}'
Response-Parameters
parameters | Type | Description |
---|---|---|
segment_id | string | Segment ID |
segment_name | string | Segment name |
list_id | integer | Associated list ID |
status | string | Segment status (-1: Failed, 1: Updating, 2: Update completed) |
create_time | string | Creation time (UTC+8) |
update_time | string | Update time (UTC+8) |
member_total | integer | Total number of members in the group |
type | integer | Segment type (0 or 1) - 0: by field (grouped by attribute), 1: by campaign (grouped by sending effectiveness) |
condition | object | Segment condition |
relation | string | Condition relationship (and, or) |
items | object[] | Conditions |
campaign_id | integer | Campaign ID |
field_name | string | Field name |
op | string | Operator |
value | string | Field value |
process | object | Group processing progress |
status_desc | string | Processing status description |
complete | Boolean | true: completed, false: not completed |
percent | integer | Percentage of completion |
Response example
Response-Success
HttpStatus: 200
{
"result": {
"segment_id": "6566f91fceac8f702f24dbba",
"user_id": 104201,
"segment_name": "Age between 13 and 45",
"type": 0,
"list_id": 96112,
"status": "2",
"create_time": "2023-11-29 16:41:03+0800",
"update_time": "2023-11-29 17:08:43+0800",
"member_total": 10,
"condition":{
"relation": "and",
"items":[
{
"campaign_id": null,
"field_name": "Age",
"op": ">=",
"value": "13"
},
{
"campaign_id": null,
"field_name": "Age",
"op": "<=",
"value": "45"
}
]
},
"process": {
"statusDesc": "segmentation completed",
"complete": true,
"percent": 100
}
}
}
Response-Error
{
"code": 30036,
"message": "not found"
}
Segment details
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}
HTTP request method
GET
Content-Type
application/x-www-form-urlencoded;charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Request-Example
curl -X GET -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/62849dc690d79d4947dd033d
Response-Parameters
parameters | Type | Description |
---|---|---|
segment_id | string | Segment ID |
segment_name | string | Segment name |
list_id | integer | Associated list ID |
status | string | Segment status (-1. Failed, 1. Updating, 2. Update completed) |
create_time | string | Creation time (UTC+8) |
update_time | string | Update time (UTC+8) |
member_total | integer | Total number of members in the group |
type | integer | Segment type (0 or 1) |
condition | object | Segment conditions |
relation | string | Condition relation (and, or) |
items | object[] | Conditions |
campaign_id | integer | Campaign ID |
field_name | string | Field name |
op | string | Operator |
value | string | Field value |
process | object | Segment processing progress |
status_desc | string | Processing status description |
complete | Boolean | true if completed, false if not completed |
percent | integer | Processing percentage |
Response example
Response-Success
HttpStatus:200
{
"result": {
"segment_id": "6566f6392c16e71300b1b1e9",
"user_id": 104201,
"segment_name": "MyCustomField",
"relation": "and",
"type": 0,
"list_id": 96112,
"status": "2",
"create_time": "2023-11-29 16:28:41+0800",
"update_time": "2023-11-29 16:33:58+0800",
"member_total": 1,
"condition": {
"relation": "and",
"items":[{
"campaign_id": null,
"field_name": "CustomField",
"op": "contain",
"value": "CustomField"
}
]
},
"process": {
"statusDesc": "segmentation completed",
"complete": true,
"percent": 100
}
}
}
Response-Error
{
"code": 30036,
"message": "not found"
}
Segment list
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments
HTTP request method
GET
Content-Type
application/x-www-form-urlencoded;charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Query-Parameters
Parameter | Type | Required | Description |
---|---|---|---|
segment_name | string | false | Segment name, supports fuzzy search |
type | integer | false | Segment type (0 or 1) 0. by field (group by field); 1. by campaign (group by performance) |
offset | integer | false | Query starting position, value range [0-], default is 0 |
limit | integer | false | Query count, value range [1-100], default is 10 |
Request-Example
curl -X GET -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments?offset=0&limit=10&segmentName=abc_by_name&type=0
Response-Parameters
Parameters | Type | Description |
---|---|---|
list | array | Member list |
segment_id | string | Segment ID |
segment_name | string | Segment name |
list_id | integer | List association ID |
status | string | Segment status (-1: Failed, 1: Updating, 2: Updated) |
create_time | string | Creation time (UTC+8) |
update_time | string | Update time (UTC+8) |
member_total | integer | Total number of members in the segment |
type | integer | Segment type (0 or 1) - 0: by field, 1: by campaign |
condition | object | Segment conditions |
relation | string | Condition relation (and, or) |
items | object[] | Conditions |
campaign_id | integer | Campaign ID |
field_name | string | Field name |
op | string | Operator |
value | string | Field value |
process | object | Segment processing progress |
status_desc | string | Processing status description |
complete | Boolean | true if completed, false if not completed |
percent | integer | Processing percentage |
total | integer | Total records |
count | integer | Number of resulting records |
Response example
Response-Success
HttpStatus: 200
{
"result": [
{
"segment_id": "6566f6392c16e71300b1b1e9",
"segment_name": "MyCustomField",
"type": 0,
"list_id": 96112,
"status": "2",
"create_time": "2023-11-29 16:28:41+0800",
"update_time": "2023-11-29 16:33:58+0800",
"member_total": 1,
"condition": {
"relation": "and",
"items": [
{
"campaign_id": null,
"field_name": "CustomField",
"op": "contain",
"value": "CustomField"
}
]
},
"process": {
"statusDesc": "segmentation completed",
"complete": true,
"percent": 100
}
},
{
"segment_id": "6566f2dd1e9adc15e3efd47e",
"segment_name": "Age>=20用户组",
"type": 0,
"list_id": 96112,
"status": "2",
"create_time": "2023-11-29 16:14:21+0800",
"update_time": "2023-11-29 16:14:23+0800",
"member_total": 10,
"condition": {
"relation": "and",
"items": [
{
"campaign_id": null,
"field_name": "Age",
"op": ">=",
"value": "20"
}
]
},
"process": {
"statusDesc": "segmentation completed",
"complete": true,
"percent": 100
}
}
],
"total": 4,
"count": 2
}
Response-Error
{
"code": 30035,
"message": "type only be 0 (by field) or 1 (by campaign)"
}
Query segment process
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}/process
HTTP request method
GET
Content-Type
application/x-www-form-urlencoded;charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Request-Example
curl -X GET -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/62849dc690d79d4947dd033d/process
Response example
Response-Success
HttpStatus: 200
{
"result": {
"percent": 68,
"complete": false,
"statusDesc": "is being segmented, please do not use this segment to send mail"
}
}
Response-Error
{
"code": 30036,
"message": "not found"
}
Segment member list
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}/members
HTTP request method
POST
Content-Type
application/json; charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Query-Parameters
Parameter | Type | Required | Description |
---|---|---|---|
offset | integer | false | Starting position of the query, valid range: [0-], default is 0 |
limit | integer | false | Number of entries to query, valid range: [1-100], default is 10 |
Body-Parameters
Parameter | Type | Required | Description |
---|---|---|---|
condition | object | false | Grouping condition |
relation | string | true | Condition relationship (and or or) |
items | object[] | true | Conditions (support up to 10 filtering conditions, all with either and or or relationship) |
field_name | string | true | field_name is the attribute name, value is the attribute value; when field_name is "tag", value=tag name |
op | string | true | Operator (==, !=, >, >=, <, <=, contain, does not contain) |
value | string | true | When field_name = "tag", value = tag name; When field_name is an attribute name, refer to filter conditions for the format |
Note:
1.Please refer to the corresponding relationship between field_name and op filter conditions
Request-Example
curl -X POST -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/62908150eb5e955d6d214da6/members?offset=0&limit=10 --data '{
"condition": {
"relation": "and",
"items": [
{
"field_name": "Email",
"op": "contain",
"value": "tw"
}
]
}
}'
Response-Parameters
parameters | Type | Description |
---|---|---|
list | array[object] | List array |
id | string | Member ID |
list_id | integer | List ID |
string | Email address | |
phone | string | Phone number |
name | string | Name |
create_time | string | Creation time (UTC+8) |
update_time | string | Subscription update time (UTC+8) |
unsubscribe_time | string | Unsubscription time (UTC+8) |
fields | object | Member fields |
tag_ids | string[] | Tag ID Set |
tag_names | string[] | Tag name Set |
total | integer | Total records |
Response example
Response-Succes
HttpStatus: 200
{
"result": [
{
"id": "629d6650490f33c5eef1caa6",
"list_id": 63486,
"email": "paulchen0518@yahoo.com.tw",
"phone": null,
"name": "shanshan",
"create_time": "2022-06-06T10:28:32+0800",
"update_time": "2022-06-06T10:28:32+0800",
"unsubscribe_time": null,
"fields": {
"Gender": "Female"
},
"tags": null,
"tag_names": []
},
{
"id": "629d665a490f33c5eef2932f",
"list_id": 63486,
"email": "q510518@yahoo.com.tw",
"phone": null,
"name": "",
"create_time": "2022-06-06T10:28:42+0800",
"update_time": "2022-06-06T10:28:42+0800",
"unsubscribe_time": null,
"fields": {
"Gender": ""
},
"tag_ids": null,
"tag_names": []
}
],
"total": 2
}
Response-Error
{
"code": 30000,
"message": "Authentication failed"
}
Delete segment members
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}/members
HTTP request method
DELETE
Content-Type
application/json; charset=utf-8
Request-Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Body-Parameters
Parameter | Type | Required | Description |
---|---|---|---|
member_ids | string[] | true | member id list |
Request-Example
curl -X DELETE -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/ 62849dc690d79d4947dd033d/members --data '{
"member_ids": [
"asdfsdf2211212aa",
"2sadfs288332223s"
]
}'
Response example
Response-Success
HttpStatus: 200
{
"count": 100
}
Response-Error
{
"code": 30000,
"message": "Authentication failed"
}