分組管理
創建分組
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 名稱 ; 當 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_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.按屬性分組;1.按發送效果分組 |
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"
}