Skip to main content
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.labels.update(
  "lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E",
  {
    color: "blue",
  },
);
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"
}

Update a label

Renaming a label renames it on every thread that carries it.
PATCH/v1/labels/{id}scope · manage
import { createClient } from "@mailsai/sdk";

const client = createClient(); // reads MAILS_API_KEY

const result = await client.labels.update(
  "lbl_01JZX8K3M9Q4P7VN2YB6RTDC0E",
  {
    color: "blue",
  },
);
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"
}

Path Parameters

idstringrequired

Label id (lbl_…).

Body Parameters

namestring

Renaming a label renames it on every thread that carries it.

colorstring

A new colour from the same palette of 12. Left out, the colour stays as it is; a request must carry name, color or both.

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

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?