Labels

Labels

Your own labels for conversations.

An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.

On this page
  1. The Label object
  2. labels.list
  3. labels.create
  4. labels.update
  5. labels.remove

The Label object

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

Attributes

  • namestring

    The label’s name.

  • colorenum

    Its color.

    One ofslateambergreenredblueviolet

  • countnumber

    Conversations carrying it, outside Trash and Junk.

Answered by

labels.listlabels.createlabels.update

The Label object
{
  "name": "Acme API",
  "color": "slate",
  "count": 12
}

labels.list

List your labels.

POST/v1/labels.list

API token

Parameters

It takes no input: send an empty object.

Returns

data is a list of Label objects.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.labels.list();
console.log(answer);
from mailset import Mailset

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

answer = mailset.labels.list()
print(answer)
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)
}
require 'mailset'

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

answer = mailset.labels.list
p answer
<?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;
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);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.labels().list().await?;
println!("{answer:?}");
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 shows how.

mailset labels list
Response
{
  "ok": true,
  "data": [
    {
      "name": "Acme API",
      "color": "slate",
      "count": 12
    }
  ]
}

labels.create

Create a label.

POST/v1/labels.create

API token

Parameters

  • namestringrequired

    The label’s name, up to 60 characters.

    At most 60 characters.

  • colorenumoptional

    Its colour.

    One ofslateambergreenredblueviolet

    Default slate.

Returns

data is the Label object.

In the CLIErrors

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);
from mailset import Mailset

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

answer = mailset.labels.create(
    {"color": "green", "name": "Finance"}
)
print(answer)
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)
}
require 'mailset'

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

answer = mailset.labels.create(
  color: 'green',
  name: 'Finance'
)
p answer
<?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;
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);
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 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 shows how.

mailset labels create Finance --color green
Response
{
  "ok": true,
  "data": {
    "name": "Acme API",
    "color": "slate",
    "count": 12
  }
}

labels.update

Rename or recolour a label.

POST/v1/labels.update

API token

Parameters

  • namestringrequired

    The label’s name as it is now.

    At most 60 characters.

  • renamestringoptional

    Its new name.

    At most 60 characters.

  • colorenumoptional

    Its new colour.

    One ofslateambergreenredblueviolet

Returns

data is the Label object.

In the CLIErrors

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);
from mailset import Mailset

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

answer = mailset.labels.update(
    {
        "rename": "Invoices",
        "color": "blue",
        "name": "Finance",
    }
)
print(answer)
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{
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

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;
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);
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 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 shows how.

mailset labels update Finance --rename Invoices --color blue
Response
{
  "ok": true,
  "data": {
    "name": "Acme API",
    "color": "slate",
    "count": 12
  }
}

labels.remove

Delete a label, and take it off every conversation.

POST/v1/labels.remove

API token

Parameters

  • namestringrequired

    The label’s name.

    At most 60 characters.

Returns

data is an object with:

  • removedboolean

In the CLIErrors

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);
from mailset import Mailset

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

answer = mailset.labels.remove({"name": "Finance"})
print(answer)
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)
}
require 'mailset'

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

answer = mailset.labels.remove(name: 'Finance')
p answer
<?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;
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);
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 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 shows how.

mailset labels remove Finance
Response
{
  "ok": true,
  "data": {
    "removed": true
  }
}