Skip to main content
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);
{
  "id": "lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E",
  "name": "<name>",
  "color": "gray",
  "created_at": "2026-10-04T12:00:00.000Z",
  "updated_at": "2026-10-04T12:00:00.000Z"
}

Create a label

A name (unique in the workspace, ignoring case) and a colour from a fixed palette of 12.
POST/v1/labelsscope · manage
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);
{
  "id": "lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E",
  "name": "<name>",
  "color": "gray",
  "created_at": "2026-10-04T12:00:00.000Z",
  "updated_at": "2026-10-04T12:00:00.000Z"
}

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.

One of: gray, red, orange, amber, yellow, green, teal, cyan, blue, indigo, purple, pink

Default: "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.

One of: gray, red, orange, amber, yellow, green, teal, cyan, blue, indigo, purple, pink

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?