API reference
Labels and filing rules
Organize sent and received mail into folders automatically or by hand.
No operations match this filter.
/emails/:id/labelsAdd or remove labels on an email
Add and remove labels by name or lbl_ ID. Unknown names in `add` are created unless `create` is false. An email may carry at most 10 labels.
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"
}
]
}/labelsList labels with message counts and filing rules
List labels with message counts and filing rules
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
}
}/labelsCreate a label, optionally with auto-filing rules
Create a folder-style label. Set `skip_inbox: true` to make it a bucket: received mail that gets this label (from a rule, from a reply to a conversation sent with the label, or added by hand) is archived so it appears only in the label, never the Inbox. Optional `rules` file new sent or received mail automatically: every condition set on a rule must match (inbox_id, direction, and case-insensitive from/to/subject substrings). Set `apply_to_existing` to file retained mail too.
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": []
}/labels/:idRetrieve a label by ID or name
Retrieve a label by ID or name
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": []
}/labels/:idRename, recolor, or turn a label into a bucket
Change `name`, `color`, or `skip_inbox`. Turning `skip_inbox` on also archives received mail already in the label unless `apply_to_existing` is 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
}/labels/:idDelete a label without deleting its email
Delete a label without deleting its email
curl https://sendhq.cc/api/v1/labels/id_value \
-X DELETE \
-H "Authorization: Bearer $SENDHQ_API_KEY"{
"ok": true
}/labels/:id/rulesAdd an auto-filing rule to a label
Add an auto-filing rule to a label
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
}/labels/:id/rules/:rule_idDelete an auto-filing rule
Delete an auto-filing rule
curl https://sendhq.cc/api/v1/labels/id_value/rules/rule_id_value \
-X DELETE \
-H "Authorization: Bearer $SENDHQ_API_KEY"{
"ok": true
}