# Labels

Your own labels for conversations.

An SDK signs every request with your key: [Authentication](https://mailset.app/docs/authentication.md). To sign one yourself, see [Calling the API without an SDK](https://mailset.app/docs/authentication/http.md).

## The Label object

A label: its name, its color and how many conversations carry it.

### Attributes

- `name` (string): The label’s name.
- `color` (enum): Its color. One of `slate`, `amber`, `green`, `red`, `blue`, `violet`.
- `count` (number): Conversations carrying it, outside Trash and Junk.

```json
{
  "name": "Acme API",
  "color": "slate",
  "count": 12
}
```

Answered by [labels.list](https://mailset.app/docs/api/labels#labels.list), [labels.create](https://mailset.app/docs/api/labels#labels.create), [labels.update](https://mailset.app/docs/api/labels#labels.update).

## labels.list

List your labels.

`POST /v1/labels.list`

Any signed-in person, with an API token.

### Parameters

It takes no input: send an empty object.

### Returns

`data` is a list of [Label objects](https://mailset.app/docs/api/labels#label).

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.labels.list();
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.labels.list()
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	answer, err := client.Labels.List(ctx)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.labels.list
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->labels->list();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Label;
import java.util.List;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

List<Label> answer = mailset.labels().list();
System.out.println(answer);
```

Rust:

```rust
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.labels().list().await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/labels.list \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{}}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset labels list
```

### Response

```json
{
  "ok": true,
  "data": [
    {
      "name": "Acme API",
      "color": "slate",
      "count": 12
    }
  ]
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/labels#labels-list)

## labels.create

Create a label.

`POST /v1/labels.create`

Any signed-in person, with an API token.

### Parameters

- `name` (string, required): The label’s name, up to 60 characters. At most 60 characters.
- `color` (enum, optional): Its colour. One of `slate`, `amber`, `green`, `red`, `blue`, `violet`. Default `slate`.

### Returns

`data` is the [Label object](https://mailset.app/docs/api/labels#label).

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.labels.create({
	color: "green",
	name: "Finance",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.labels.create(
    {"color": "green", "name": "Finance"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.LabelsCreateParams{
		Color: mailset.LabelColorGreen,
		Name:  "Finance",
	}
	answer, err := client.Labels.Create(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.labels.create(
  color: 'green',
  name: 'Finance'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->labels->create([
    'color' => 'green',
    'name' => 'Finance',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Label;
import app.mailset.model.LabelColor;
import app.mailset.model.LabelsCreateParams;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

var params = LabelsCreateParams.builder()
        .color(LabelColor.GREEN)
        .name("Finance")
        .build();
Label answer = mailset.labels().create(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{LabelColor, LabelsCreateParams};

// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .labels()
    .create(LabelsCreateParams {
        name: "Finance".into(),
        color: Some(LabelColor::Green),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/labels.create \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"color":"green","name":"Finance"}}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset labels create Finance --color green
```

### Response

```json
{
  "ok": true,
  "data": {
    "name": "Acme API",
    "color": "slate",
    "count": 12
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/labels#labels-create)

## labels.update

Rename or recolour a label.

`POST /v1/labels.update`

Any signed-in person, with an API token.

### Parameters

- `name` (string, required): The label’s name as it is now. At most 60 characters.
- `rename` (string, optional): Its new name. At most 60 characters.
- `color` (enum, optional): Its new colour. One of `slate`, `amber`, `green`, `red`, `blue`, `violet`.

### Returns

`data` is the [Label object](https://mailset.app/docs/api/labels#label).

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.labels.update({
	rename: "Invoices",
	color: "blue",
	name: "Finance",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.labels.update(
    {
        "rename": "Invoices",
        "color": "blue",
        "name": "Finance",
    }
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.LabelsUpdateParams{
		Rename: mailset.String("Invoices"),
		Color:  mailset.LabelColorBlue,
		Name:   "Finance",
	}
	answer, err := client.Labels.Update(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.labels.update(
  rename: 'Invoices',
  color: 'blue',
  name: 'Finance'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->labels->update([
    'rename' => 'Invoices',
    'color' => 'blue',
    'name' => 'Finance',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.Label;
import app.mailset.model.LabelColor;
import app.mailset.model.LabelsUpdateParams;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

var params = LabelsUpdateParams.builder()
        .rename("Invoices")
        .color(LabelColor.BLUE)
        .name("Finance")
        .build();
Label answer = mailset.labels().update(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::{LabelColor, LabelsUpdateParams};

// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .labels()
    .update(LabelsUpdateParams {
        name: "Finance".into(),
        rename: Some("Invoices".into()),
        color: Some(LabelColor::Blue),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/labels.update \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"rename":"Invoices","color":"blue","name":"Finance"}}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset labels update Finance --rename Invoices --color blue
```

### Response

```json
{
  "ok": true,
  "data": {
    "name": "Acme API",
    "color": "slate",
    "count": 12
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/labels#labels-update)

## labels.remove

Delete a label, and take it off every conversation.

`POST /v1/labels.remove`

Any signed-in person, with an API token.

### Parameters

- `name` (string, required): The label’s name. At most 60 characters.

### Returns

`data` is an object with:

- `removed` (boolean)

### Request

TypeScript:

```typescript
import { Mailset } from 'mailset';

// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();

const answer = await mailset.labels.remove({
	name: "Finance",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()

answer = mailset.labels.remove({"name": "Finance"})
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_TOKEN from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.LabelsRemoveParams{
		Name: "Finance",
	}
	answer, err := client.Labels.Remove(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new

answer = mailset.labels.remove(name: 'Finance')
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();

$answer = $mailset->labels->remove(['name' => 'Finance']);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.LabelsRemoveParams;
import app.mailset.model.LabelsRemoveResult;

// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();

var params = LabelsRemoveParams.builder()
        .name("Finance")
        .build();
LabelsRemoveResult answer =
        mailset.labels().remove(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::LabelsRemoveParams;

// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset
    .labels()
    .remove(LabelsRemoveParams {
        name: "Finance".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/labels.remove \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"name":"Finance"}}'
```

curl can’t sign a request. `$TOKEN` is your credential’s token, and `$MS_TIME` and `$MS_PROOF` sign this exact body: [Calling the API without an SDK](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset labels remove Finance
```

### Response

```json
{
  "ok": true,
  "data": {
    "removed": true
  }
}
```

In the CLI: [mailset reference](https://mailset.app/docs/cli/labels#labels-remove)

---

© 2026 Intenseloop, Inc. Mailset’s site, docs and guides are copyrighted. You may read them and use their code to build with Mailset. Don’t republish them or use them to build a copy of Mailset. Terms: https://mailset.app/terms#content