import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.labels.create({
name: "Invoices",
color: "green",
});
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.create_label(
name="Invoices",
color="green",
)
print(result)curl -X POST 'https://api.mails.ai/v1/labels' \
-H "Authorization: Bearer $MAILS_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "name": "Invoices", "color": "green" }'mails labels create billing --color blue{
"name": "mails_labels_create",
"arguments": { "name": "Invoices", "color": "green" }
}{
"id": "lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"name": "<name>",
"color": "gray",
"created_at": "2026-10-04T12:00:00.000Z",
"updated_at": "2026-10-04T12:00:00.000Z"
}201 The created label.
400 Invalid request — malformed JSON or a field failed
validation. Also feature_not_enabled when this
server has a feature switched off (custom domains
before they are available).
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
409 Conflict — duplicate resource, an in-progress
idempotent request, a draft or scheduled message
that started sending while it was being changed, or
a thread deleted for good while one of its messages
is being sent (duplicate_resource); or an agent
name more than one agent has (agent_name_conflict:
use the agent's id); or a status change on an
archived agent, since archiving cannot be undone
(agent_archived).
500 Internal server error.Create a label
A name (unique in the workspace, ignoring case) and a colour from a fixed palette of 12.
import { createClient } from "@mailsai/sdk";
const client = createClient(); // reads MAILS_API_KEY
const result = await client.labels.create({
name: "Invoices",
color: "green",
});
console.log(result);from mailsai import create_client
client = create_client() # reads MAILS_API_KEY
result = client.create_label(
name="Invoices",
color="green",
)
print(result)curl -X POST 'https://api.mails.ai/v1/labels' \
-H "Authorization: Bearer $MAILS_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "name": "Invoices", "color": "green" }'mails labels create billing --color blue{
"name": "mails_labels_create",
"arguments": { "name": "Invoices", "color": "green" }
}{
"id": "lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E",
"name": "<name>",
"color": "gray",
"created_at": "2026-10-04T12:00:00.000Z",
"updated_at": "2026-10-04T12:00:00.000Z"
}201 The created label.
400 Invalid request — malformed JSON or a field failed
validation. Also feature_not_enabled when this
server has a feature switched off (custom domains
before they are available).
401 Missing or invalid API key.
403 The API key lacks the required scope
(insufficient_scope), or the token belongs to an
app connected by sign-in and this operation is
closed to connected apps
(connected_app_not_allowed).
409 Conflict — duplicate resource, an in-progress
idempotent request, a draft or scheduled message
that started sending while it was being changed, or
a thread deleted for good while one of its messages
is being sent (duplicate_resource); or an agent
name more than one agent has (agent_name_conflict:
use the agent's id); or a status change on an
archived agent, since archiving cannot be undone
(agent_archived).
500 Internal server error.Body Parameters
namestringrequired
Unique within the workspace, ignoring case. 1-64 characters.
colorstring
The label's colour, one of 12 palette names. Left out, it is gray.
Response
idstring
Label id (lbl_…).
namestring
Unique in the workspace, ignoring case.
colorstring
The label's colour, one of 12 palette names: gray unless another was chosen.
created_atstring
When the label was created (UTC).
updated_atstring
When the label was last changed with PATCH, even by a request that left it as it was. Equal to created_at on a label never patched.
Was this page helpful?