Documentation menu
API reference
Tags
Label messages by hand or with rules.
Add a tag to a message
POST/v1/messages/{id}/tags
Path parameters
- idstringrequiredMessage ID.
Request body
- tagstringrequired
Returns
- tagstringrequired
Errors
400The request was malformed or a value was invalid.
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
curl -X POST "https://app.mailbench.dev/v1/messages/msg_htumcicppd26jek6/tags" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"tag": "billing"}'const res = await fetch("https://app.mailbench.dev/v1/messages/msg_htumcicppd26jek6/tags", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"tag": "billing"
}),
});
const { data } = await res.json();import os, requests
res = requests.post(
"https://app.mailbench.dev/v1/messages/msg_htumcicppd26jek6/tags",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
json={
"tag": "billing",
},
)
data = res.json()["data"]{
"success": true,
"data": {
"tag": "string"
}
}Replace a message's tags
PUT/v1/messages/{id}/tags
Path parameters
- idstringrequiredMessage ID.
Request body
- tagsarray of stringsrequired
Returns
- tagsarray of stringsrequired
Errors
400The request was malformed or a value was invalid.
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
{
"success": true,
"data": {
"tags": [
"billing"
]
}
}Remove a tag from a message
DELETE/v1/messages/{id}/tags/{name}
Path parameters
- idstringrequiredMessage ID.
- namestringrequiredThe tag to remove. URL-encode it.
Returns
- removedstringrequired
Errors
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
curl -X DELETE "https://app.mailbench.dev/v1/messages/msg_htumcicppd26jek6/tags/<name>" \
-H "Authorization: Bearer $API_KEY"const res = await fetch("https://app.mailbench.dev/v1/messages/msg_htumcicppd26jek6/tags/<name>", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
});
const { data } = await res.json();import os, requests
res = requests.delete(
"https://app.mailbench.dev/v1/messages/msg_htumcicppd26jek6/tags/<name>",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
)
data = res.json()["data"]{
"success": true,
"data": {
"removed": "string"
}
}List tags in use
GET/v1/tags
Returns a list of
- namestringrequired
- colorstringrequiredA CSS color, or empty for the automatic color.
- message_countintegerrequired
Errors
401Missing or invalid API key.
429Too many requests. Wait `Retry-After` seconds.
{
"success": true,
"data": [
{
"name": "billing",
"color": "#2563eb",
"message_count": 4
}
]
}List tag rules
GET/v1/tag-rules
A rule tags matching messages as they arrive.
Query parameters
- inbox_idstringOnly rules for this inbox.
Returns a list of
- idstringrequired
- workspace_idstring
- inbox_idstring or null
- namestringrequired
- fieldstringrequired
- patternstringrequiredA regular expression.
- tagsarray of stringsrequired
- activebooleanrequired
- created_atstring (date-time)required
Errors
401Missing or invalid API key.
429Too many requests. Wait `Retry-After` seconds.
curl "https://app.mailbench.dev/v1/tag-rules" \
-H "Authorization: Bearer $API_KEY"const res = await fetch("https://app.mailbench.dev/v1/tag-rules", {
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
});
const { data } = await res.json();import os, requests
res = requests.get(
"https://app.mailbench.dev/v1/tag-rules",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
)
data = res.json()["data"]{
"success": true,
"data": [
{
"id": "trule_ai6monxoyc6e4hcv",
"workspace_id": "ws_k3m9x2p7qa4d8fbn",
"inbox_id": null,
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing"
],
"active": true,
"created_at": "2026-10-12T10:00:00Z"
}
]
}Create a tag rule
POST/v1/tag-rules
Request body
- inbox_idstringOmit to apply to every inbox.
- namestringrequired
- fieldstringrequired
- patternstringrequired
- tagsarray of stringsrequired
- activeboolean
Returns
- idstringrequired
- workspace_idstring
- inbox_idstring or null
- namestringrequired
- fieldstringrequired
- patternstringrequiredA regular expression.
- tagsarray of stringsrequired
- activebooleanrequired
- created_atstring (date-time)required
Errors
400The request was malformed or a value was invalid.
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
429Too many requests. Wait `Retry-After` seconds.
curl -X POST "https://app.mailbench.dev/v1/tag-rules" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"inbox_id": "string", "name": "Billing emails", "field": "from", "pattern": "billing@", "tags": [ "billing" ], "active": true}'const res = await fetch("https://app.mailbench.dev/v1/tag-rules", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"inbox_id": "string",
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing"
],
"active": true
}),
});
const { data } = await res.json();import os, requests
res = requests.post(
"https://app.mailbench.dev/v1/tag-rules",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
json={
"inbox_id": "string",
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing",
],
"active": True,
},
)
data = res.json()["data"]{
"success": true,
"data": {
"id": "trule_ai6monxoyc6e4hcv",
"workspace_id": "ws_k3m9x2p7qa4d8fbn",
"inbox_id": null,
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing"
],
"active": true,
"created_at": "2026-10-12T10:00:00Z"
}
}Rename a tag or change its color
PUT/v1/tags/{name}
Renaming applies to every message that has the tag.
Path parameters
- namestringrequiredThe tag. URL-encode it.
Request body
- namestringThe new name. Omit to keep it.
- colorstringA CSS color such as
#2563eb. Empty for the automatic color.
Returns
- old_namestringrequired
- namestringrequired
- colorstring
Errors
400The request was malformed or a value was invalid.
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
curl -X PUT "https://app.mailbench.dev/v1/tags/<name>" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "string", "color": "string"}'const res = await fetch("https://app.mailbench.dev/v1/tags/<name>", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "string",
"color": "string"
}),
});
const { data } = await res.json();import os, requests
res = requests.put(
"https://app.mailbench.dev/v1/tags/<name>",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
json={
"name": "string",
"color": "string",
},
)
data = res.json()["data"]{
"success": true,
"data": {
"old_name": "string",
"name": "string",
"color": "string"
}
}Delete a tag
DELETE/v1/tags/{name}
Removes it from every message. The messages stay.
Path parameters
- namestringrequiredThe tag. URL-encode it.
Returns
- deletedstringrequired
Errors
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
curl -X DELETE "https://app.mailbench.dev/v1/tags/<name>" \
-H "Authorization: Bearer $API_KEY"const res = await fetch("https://app.mailbench.dev/v1/tags/<name>", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
});
const { data } = await res.json();import os, requests
res = requests.delete(
"https://app.mailbench.dev/v1/tags/<name>",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
)
data = res.json()["data"]{
"success": true,
"data": {
"deleted": "string"
}
}Replace a tag rule
PUT/v1/tag-rules/{id}
Path parameters
- idstringrequired
Request body
- inbox_idstringOmit to apply to every inbox.
- namestringrequired
- fieldstringrequired
- patternstringrequired
- tagsarray of stringsrequired
- activeboolean
Returns
- idstringrequired
- workspace_idstring
- inbox_idstring or null
- namestringrequired
- fieldstringrequired
- patternstringrequiredA regular expression.
- tagsarray of stringsrequired
- activebooleanrequired
- created_atstring (date-time)required
Errors
400The request was malformed or a value was invalid.
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
curl -X PUT "https://app.mailbench.dev/v1/tag-rules/<id>" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"inbox_id": "string", "name": "Billing emails", "field": "from", "pattern": "billing@", "tags": [ "billing" ], "active": true}'const res = await fetch("https://app.mailbench.dev/v1/tag-rules/<id>", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"inbox_id": "string",
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing"
],
"active": true
}),
});
const { data } = await res.json();import os, requests
res = requests.put(
"https://app.mailbench.dev/v1/tag-rules/<id>",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
json={
"inbox_id": "string",
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing",
],
"active": True,
},
)
data = res.json()["data"]{
"success": true,
"data": {
"id": "trule_ai6monxoyc6e4hcv",
"workspace_id": "ws_k3m9x2p7qa4d8fbn",
"inbox_id": null,
"name": "Billing emails",
"field": "from",
"pattern": "billing@",
"tags": [
"billing"
],
"active": true,
"created_at": "2026-10-12T10:00:00Z"
}
}Delete a tag rule
DELETE/v1/tag-rules/{id}
Messages already tagged keep their tags.
Path parameters
- idstringrequired
Returns
- deletedstringrequired
Errors
401Missing or invalid API key.
403The key is read-only, or the action needs a dashboard session.
404No such object in this workspace.
429Too many requests. Wait `Retry-After` seconds.
curl -X DELETE "https://app.mailbench.dev/v1/tag-rules/<id>" \
-H "Authorization: Bearer $API_KEY"const res = await fetch("https://app.mailbench.dev/v1/tag-rules/<id>", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
},
});
const { data } = await res.json();import os, requests
res = requests.delete(
"https://app.mailbench.dev/v1/tag-rules/<id>",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
)
data = res.json()["data"]{
"success": true,
"data": {
"deleted": "string"
}
}