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.
The Label object
A label: its name, its color and how many conversations carry it.
Attributes
The label’s name.
Its color.
One of
slateambergreenredbluevioletConversations carrying it, outside Trash and Junk.
Answered by
{
"name": "Acme API",
"color": "slate",
"count": 12
}
labels.list
List your labels.
POST/v1/labels.list
Parameters
It takes no input: send an empty object.
Returns
data is a list of Label objects.
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
{
"ok": true,
"data": [
{
"name": "Acme API",
"color": "slate",
"count": 12
}
]
}
labels.create
Create a label.
POST/v1/labels.create
Parameters
The label’s name, up to 60 characters.
At most 60 characters.
Its colour.
One of
slateambergreenredbluevioletDefault
slate.
Returns
data is the Label object.
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
{
"ok": true,
"data": {
"name": "Acme API",
"color": "slate",
"count": 12
}
}
labels.update
Rename or recolour a label.
POST/v1/labels.update
Parameters
The label’s name as it is now.
At most 60 characters.
Its new name.
At most 60 characters.
Its new colour.
One of
slateambergreenredblueviolet
Returns
data is the Label object.
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
{
"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
Parameters
The label’s name.
At most 60 characters.
Returns
data is an object with:
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
{
"ok": true,
"data": {
"removed": true
}
}