分组管理
创建分组
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments
HTTP 请求方式
POST
Content-Type
application/json; charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Body 参数
Parameter | Type | Required | Description |
---|---|---|---|
segment_name | string | true | 分组名称 (最长48个字符,不支持字符 ^,?,+,.,*,\,[,],(,) ) |
type | integer | true | 分组类型 ( 0或1) 0.by field (按照属性分组); 1. by campaign(按照发送效果分组) |
condition | object | true | 分组条件 |
relation | string | true | 条件关系 (and 或 or) |
items | object[] | true | 条件 (最多支持10个筛选条件,筛选条件之间关系(relation),要么全为且关系,要么全为或关系) |
campaign_id | integer | false | 营销任务 ID 如果 field_name=campaign,此值必填,且该 ID 对应的任务状态必须是正在发送中或已发送完成 |
field_name | string | true | 1.若 type=0 field_name 为属性名,value 为属性值; field_name 为 "tag" 时,value=tag name 2.若 type=1 field_name 必为 campaign,value 为 "sent","open","click","unopen","unclick","notsent" 之一,此时 campaign_id 必填,为该 campaign 的 ID |
op | string | true | 操作符 (== , != , > , >= , < , <= , contain , does not contain) 当 field_name=campaign 时,此时 op 必须为 ==; 当 field_name 为属性名或 tag 时,op 请参看筛选条件 |
value | string | true | 当 fieldName 为 "tag" ,此时 value=tagName ; 当 fieldName 为属性名,格式请参考筛选条件; 当 fieldName = "campaign",value=sent, open, click, unopen, unclick, notsent 中之一 |
说明
- field_name 和op 对应的关系请参考筛选条件
请求示例
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": "湖北用户",
"type": 0,
"condition": {
"relation": "and",
"items": [
{
"field_name": "Name",
"op": "contain",
"value": "李磊"
}
]
}
}'
响应示例
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": "李磊"
}
]
},
"process": {
"statusDesc": "segmentation completed",
"complete": true,
"percent": 100
}
}
}
Response-Error
{
"code": 30035,
"message": "[segment_name]:Special characters such as ^, ?, +, ., \\, [, ], (, ), cannot be used"
}
删除分组
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}
HTTP 请求方式
DELETE
Content-Type
application/x-www-form-urlencoded;charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
请求示例
curl -X DELETE -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/6566f12d1e9adc15e3efd4
响应示例
Response-Success
HttpStatus: 200
{
"count": 1
}
Response-Error
{
"code": 30036,
"message": "not found"
}
更新分组
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}
HTTP 请求方式
PUT
Content-Type
application/json; charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Body 参数
Parameter | Type | Required | Description |
---|---|---|---|
segment_name | string | false | 分组名称 (最长48个字符) |
type | integer | true | 分组类型 ( 0或1) 0.by field (按照属性分组); 1. by campaign(按照发送效果分组) |
condition | object | true | 分组条件 |
relation | string | true | 条件关系 (and 或 or) |
items | object[] | true | 条件 (最多支持10个筛选条件,筛选条件之间关系(relation),要么全为且关系,要么全为或关系 |
campaign_id | integer | false | 营销任务 ID 如果 field_name=campaign,此值必填,且该 ID 对应的任务状态必须是正在发送中或已发送完成 |
field_name | string | true | 1.若 type=0 2.若 type=1 field_name 必为 campaign,value 为 "sent","open","click","unopen","unclick","notsent" 之一,此时 campaignId 必填,为该 campaign 的 ID |
op | string | true | 操作符 (== , != , > , >= , < , <= , contain , does not contain) 当 field_name=campaign 时,此时 op 必须为 ==; 当 field_name 为属性名或 tag 时,op 请参看筛选条件 |
value | string | true | 当 field_name 为 "tag" ,此时 value=tag name ; 当 field_name 为属性名,格式请参考筛选条件; 当 field_name = "campaign",value = sent, open, click, unopen, unclick, notsent 中之一 |
说明
- field_name 和op 对应的关系请参考筛选条件
请求示例
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": "年龄介于13与45之间",
"type": 0,
"condition": {
"relation": "and",
"items": [
{
"field_name": "Age",
"op": ">=",
"value": "13"
},
{
"field_name": "Age",
"op": "<=",
"value": "45"
}
]
}
}'
响应说明
parameters | Type | Description |
---|---|---|
segment_id | string | 分组 ID |
segment_name | string | 分组名 |
list_id | integer | 列表关联 ID |
status | string | 分组状态 (-1.失败 1.更新中 2.更新完成) |
create_time | string | 创建时间 (UTC+8) |
update_time | string | 更新时间 (UTC+8) |
member_total | integer | 分组联系人总数 |
type | integer | 分组类型 ( 0或1) 0.by field (按照属性分组); 1. by campaign(按照发送效果分组) |
condition | object | 分组条件 |
relation | string | 条件关系and,or |
items | object[] | 条件 |
campaign_id | integer | 任务 ID |
field_name | string | 属性名 |
op | string | 操作符 |
value | string | 属性值 |
process | object | 分组处理进度 |
status_desc | string | 处理状态描述 |
complete | Boolean | true 已完成, false 未完成 |
percent | integer | 处理百分比 |
响应示例
Response-Success
HttpStatus: 200
{
"result": {
"segment_id": "6566f91fceac8f702f24dbba",
"user_id": 104201,
"segment_name": "年龄介于13与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"
}
分组详情
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}
HTTP 请求方式
GET
Content-Type
application/x-www-form-urlencoded;charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
请求示例
curl -X GET -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/62849dc690d79d4947dd033d
响应说明
parameters | Type | Description |
---|---|---|
segment_id | string | 分组 ID |
segment_name | string | 分组名 |
list_id | integer | 列表关联 ID |
status | string | 分组状态 (-1.失败 1.更新中 2.更新完成) |
create_time | string | 创建时间 (UTC+8) |
update_time | string | 更新时间 (UTC+8) |
member_total | integer | 分组联系人总数 |
type | integer | 分组类型 ( 0或1) 0. by field (按照属性分组); 1. by campaign(按照发送效果分组) |
condition | object | 分组条件 |
relation | string | 条件关系and,or |
items | object[] | 条件 |
campaign_id | integer | 任务 ID |
field_name | string | 属性名 |
op | string | 操作符 |
value | string | 属性值 |
process | object | 分组处理进度 |
status_desc | string | 处理状态描述 |
complete | Boolean | true 已完成, false 未完成 |
percent | integer | 处理百分比 |
响应示例
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"
}
分组列表
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments
HTTP 请求方式
GET
Content-Type
application/x-www-form-urlencoded;charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Query 参数
Parameter | Type | Required | Description |
---|---|---|---|
segment_name | string | false | 分组名,支持模糊搜索 |
type | integer | false | 分组类型 ( 0或1) 0.by field (按照属性分组); 1. by campaign(按照发送效果分组) |
offset | integer | false | 查询起始位置, 取值区间 [0-], 默认为 0 |
limit | integer | false | 查询个数, 取值区间 [1-100], 默认为 10 |
请求示例
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
响应说明
Parameters | Type | Description |
---|---|---|
list | array | 联系人列表 |
segment_id | string | 分组 ID |
segment_name | string | 分组名 |
list_id | integer | 列表关联 ID |
status | string | 分组状态 (-1:失败 1:更新中 2:更新完成) |
create_time | string | 创建时间 (UTC+8) |
update_time | string | 更新时间 (UTC+8) |
member_total | integer | 分组联系人总数 |
type | integer | 分组类型 ( 0或1) 0.by field (按照属性分组); 1. by campaign(按照发送效果分组) |
condition | object | 分组条件 |
relation | string | 条件关系and,or |
items | object[] | 条件 |
campaign_id | integer | 任务 ID |
field_name | string | 属性名 |
op | string | 操作符 |
value | string | 属性值 |
process | object | 分组处理进度 |
status_desc | string | 处理状态描述 |
complete | Boolean | true 已完成, false 未完成 |
percent | integer | 处理百分比 |
total | integer | 记录总数 |
count | integer | 结果记录数 |
响应示例
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)"
}
查询分组的处理进度
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}/process
HTTP 请求方式
GET
Content-Type
application/x-www-form-urlencoded;charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
请求示例
curl -X GET -H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ==' -i https://email.api.engagelab.cc/v1/marketing/lists/segments/62849dc690d79d4947dd033d/process
响应示例
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"
}
某个分组的成员列表
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}/members
HTTP 请求方式
POST
Content-Type
application/json; charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Query 参数
Parameter | Type | Required | Description |
---|---|---|---|
offset | integer | false | 查询起始位置, 取值区间 [0-], 默认为 0 |
limit | integer | false | 查询个数, 取值区间 [1-100], 默认为 10 |
Body 参数
Parameter | Type | Required | Description |
---|---|---|---|
condition | object | false | 分组条件 |
relation | string | true | 条件关系 (and 或 or) |
items | object[] | true | 条件 (最多支持10个筛选条件,筛选条件之间关系(relation),要么全为且关系,要么全为或关系) |
field_name | string | true | field_name 为属性名,value 为属性值; field_name 为"tag" 时,value=tag name |
op | string | true | 操作符 (== , != , > , >= , < , <= , contain , does not contain) |
value | string | true | 当 field_name = "tag" 时,value = tag name ; 当 field_name 为属性名时,格式请参考筛选条件 |
说明
- field_name 和op 对应的关系请参考筛选条件
请求示例
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"
}
]
}
}'
响应说明
parameters | Type | Description |
---|---|---|
list | array[object] | 列表数组 |
id | string | 联系人 ID |
list_id | integer | 列表 ID |
string | 邮箱地址 | |
phone | string | 手机号码 |
name | string | 名字 |
create_time | string | 创建时间(UTC+8) |
update_time | string | 更新订阅时间(UTC+8) |
unsubscribe_time | string | 取消订阅时间(UTC+8) |
fields | object | 联系人属性 |
tag_ids | string[] | 标签 ID 集合 |
tag_names | string[] | 标签名集合 |
total | integer | 记录总数 |
响应示例
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": "女"
},
"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"
}
删除分组联系人
URL
https://email.api.engagelab.cc/v1/marketing/lists/segments/{segment_id}/members
HTTP 请求方式
DELETE
Content-Type
application/json; charset=utf-8
请求 Headers
Header | Type | Required | Description |
---|---|---|---|
Authorization | string | true | Basic base64(api_user:api_key) |
Body 参数
Parameter | Type | Required | Description |
---|---|---|---|
member_ids | string[] | true | 联系人 ID 列表 |
请求示例
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-Success
HttpStatus: 200
{
"count": 100
}
Response-Error
{
"code": 30000,
"message": "Authentication failed"
}