API 参考
标签与归档规则
自动或手动将发出和收到的邮件整理到文件夹中。
没有与此筛选条件匹配的操作。
POST
API 密钥/emails/:id/labels为邮件添加或移除标签
按名称或 lbl_ ID 添加和移除标签。`add` 中不存在的名称会被自动创建,除非 `create` 为 false。一封邮件最多可以带 10 个标签。
curl https://sendhq.cc/api/v1/emails/id_value/labels \
-X POST \
-H "Authorization: Bearer $SENDHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"add":["Billing"],"remove":["Support"]}'{
"id": "em_…",
"labels": [
{
"id": "lbl_…",
"name": "Billing",
"color": "#188038"
}
]
}GET
API 密钥/labels列出标签及其邮件数和归档规则
列出标签及其邮件数和归档规则
curl https://sendhq.cc/api/v1/labels \
-X GET \
-H "Authorization: Bearer $SENDHQ_API_KEY"{
"data": [],
"count": 0,
"mailbox": {
"inboxUnread": 0,
"updatesUnread": 0,
"spamTotal": 0,
"importantUnread": 0,
"resortPending": 0
}
}POST
API 密钥/labels创建标签,可同时设置自动归档规则
创建一个文件夹式的标签。设置 `skip_inbox: true` 可将其变为分类:收到的邮件如果获得了该标签(无论是通过规则、作为带该标签发出的会话的回复,还是手动添加),都会被归档,因此只会出现在该标签中,永远不会出现在收件箱里。可选的 `rules` 会自动归档新发出或新收到的邮件:规则上设置的每个条件都必须匹配(inbox_id、direction,以及不区分大小写的 from/to/subject 子串)。设置 `apply_to_existing` 还会归档已保留的邮件。
curl https://sendhq.cc/api/v1/labels \
-X POST \
-H "Authorization: Bearer $SENDHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Agent/Orders","color":"#188038","skip_inbox":true,"rules":[{"inbox_id":"inb_…"}],"apply_to_existing":true}'{
"id": "lbl_…",
"name": "Agent/Orders",
"color": "#188038",
"skipInbox": true,
"totalCount": 0,
"unreadCount": 0,
"rules": []
}GET
API 密钥/labels/:id按 ID 或名称获取标签
按 ID 或名称获取标签
curl https://sendhq.cc/api/v1/labels/id_value \
-X GET \
-H "Authorization: Bearer $SENDHQ_API_KEY"{
"id": "lbl_…",
"name": "Billing",
"color": "#188038",
"skipInbox": false,
"totalCount": 0,
"unreadCount": 0,
"rules": []
}PATCH
API 密钥/labels/:id重命名标签、更改颜色或将其变为分类
更改 `name`、`color` 或 `skip_inbox`。开启 `skip_inbox` 时,还会归档标签中已有的收到的邮件,除非 `apply_to_existing` 为 false。
curl https://sendhq.cc/api/v1/labels/id_value \
-X PATCH \
-H "Authorization: Bearer $SENDHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Finance/Billing","color":"#1a73e8","skip_inbox":true}'{
"id": "lbl_…",
"name": "Finance/Billing",
"color": "#1a73e8",
"skipInbox": true
}DELETE
API 密钥/labels/:id删除标签,但不删除其中的邮件
删除标签,但不删除其中的邮件
curl https://sendhq.cc/api/v1/labels/id_value \
-X DELETE \
-H "Authorization: Bearer $SENDHQ_API_KEY"{
"ok": true
}POST
API 密钥/labels/:id/rules为标签添加自动归档规则
为标签添加自动归档规则
curl https://sendhq.cc/api/v1/labels/id_value/rules \
-X POST \
-H "Authorization: Bearer $SENDHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"direction":"in","from":"@stripe.com","subject":"invoice","skip_inbox":true,"apply_to_existing":false}'{
"id": "lrule_…",
"labelId": "lbl_…",
"direction": "in",
"inboxId": null,
"from": "@stripe.com",
"to": null,
"subject": "invoice",
"skipInbox": true
}DELETE
API 密钥/labels/:id/rules/:rule_id删除自动归档规则
删除自动归档规则
curl https://sendhq.cc/api/v1/labels/id_value/rules/rule_id_value \
-X DELETE \
-H "Authorization: Bearer $SENDHQ_API_KEY"{
"ok": true
}