Rules
File, label or forward new email as it arrives.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
The Rule object
A rule on a mailbox: the email it matches and what it does to it.
Attributes
The rule’s id.
The mailbox it runs on.
The rule’s name.
What mail it matches. Every part has to hold.
Show child attributesHide child attributes
Mail from this sender.
Mail sent to this address.
Words in the subject.
Words anywhere in it.
Words it must not have.
It carries a file.
Larger than this many bytes.
Smaller than this many bytes.
What it does to that mail.
Show child attributesHide child attributes
Archives it as it arrives.
Marks it read.
Stars it.
Puts this label on it.
Forwards it to this address.
Moves it to Trash.
Never sends it to Junk.
Marks the conversation important.
Keeps it from ever being marked important. Beats
important.Files it in this inbox tab.
One of
primaryupdatesnewsletterspromotions
The rule in one line, in the operators it’s written in.
Conversations it has matched or changed.
Its latest run over existing mail, if it has had one.
It forwards, and forwarding isn’t on here yet.
Answered by
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"name": "Acme API",
"conditions": {
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"subject": "Your Acme receipt",
"hasWords": "text",
"doesntHave": "text",
"hasAttachment": true,
"larger": 1,
"smaller": 1
},
"actions": {
"skipInbox": true,
"markRead": true,
"star": true,
rules.list
List the rules on your mailboxes, in the order they run.
POST/v1/rules.list
Parameters
Only this mailbox’s rules.
Returns
data is a list of Rule objects.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.list({
mailbox: "moc.elpmaxe@ana",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.list(
{"mailbox": "moc.elpmaxe@ana"}
)
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.RulesListParams{
Mailbox: mailset.String("moc.elpmaxe@ana"),
}
answer, err := client.Rules.List(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.rules.list(mailbox: 'moc.elpmaxe@ana')
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->list([
'mailbox' => 'moc.elpmaxe@ana',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Rule;
import app.mailset.model.RulesListParams;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesListParams.builder()
.mailbox("moc.elpmaxe@ana")
.build();
List<Rule> answer = mailset.rules().list(params);
System.out.println(answer);
use mailset::types::RulesListParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.list(RulesListParams {
mailbox: Some("moc.elpmaxe@ana".into()),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.list \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"mailbox":"moc.elpmaxe@ana"}}'
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 rules list --mailbox moc.elpmaxe@ana
{
"ok": true,
"data": [
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"name": "Acme API",
"conditions": {
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"subject": "Your Acme receipt",
"hasWords": "text",
"doesntHave": "text",
"hasAttachment": true,
"larger": 1,
"smaller": 1
},
"actions": {
rules.add
Add a rule.
POST/v1/rules.add
Parameters
The mailbox the rule runs on.
A name for the rule, up to 120 characters.
At most 120 characters.
Mail from this sender: an address, a domain or a name.
At most 1,500 characters.
Mail sent to this address.
At most 1,500 characters.
Mail with these words in its subject.
At most 1,500 characters.
Mail with these words anywhere in it.
At most 1,500 characters.
Mail without these words.
At most 1,500 characters.
Mail that carries a file.
Mail larger than this: bytes, or
5M,500K.Mail smaller than this: bytes, or
5M,500K.Archive it as it arrives.
Mark it read.
Star it.
Put this label on it, by name.
Forward it to this address. Asks for a passkey.
Move it to Trash.
Never send it to Junk.
Mark it important.
Never mark it important. Beats
important.File it in this inbox tab.
One of
primaryupdatesnewsletterspromotionsAlso run it over the conversations already here.
Beside input
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is the Rule object.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.add({
mailbox: "moc.elpmaxe@ana",
from: "stripe.com",
label: "Finance",
skipInbox: true,
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.add(
{
"mailbox": "moc.elpmaxe@ana",
"from": "stripe.com",
"label": "Finance",
"skip_inbox": True,
}
)
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.RulesAddParams{
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.rules.add(
mailbox: 'moc.elpmaxe@ana',
from: 'stripe.com',
label: 'Finance',
skip_inbox: true
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->add([
'mailbox' => 'moc.elpmaxe@ana',
'from' => 'stripe.com',
'label' => 'Finance',
'skipInbox' => true,
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Rule;
import app.mailset.model.RulesAddParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesAddParams.builder()
.mailbox("moc.elpmaxe@ana")
.from("stripe.com")
.label("Finance")
.skipInbox(true)
.build();
Rule answer = mailset.rules().add(params);
System.out.println(answer);
use mailset::types::RulesAddParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.add(RulesAddParams {
mailbox: "moc.elpmaxe@ana".into(),
from: Some("stripe.com".into()),
skip_inbox: Some(true),
label: Some("Finance".into()),
..Default::default()
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.add \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"mailbox":"moc.elpmaxe@ana","from":"stripe.com","label":"Finance","skipInbox":true}}'
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 rules add --mailbox moc.elpmaxe@ana --from stripe.com --label Finance --skip-inbox
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"name": "Acme API",
"conditions": {
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"subject": "Your Acme receipt",
"hasWords": "text",
"doesntHave": "text",
"hasAttachment": true,
"larger": 1,
"smaller": 1
},
"actions": {
"skipInbox": true,
rules.update
Change a rule.
POST/v1/rules.update
Parameters
The rule’s id, from
rules list.A name for the rule, up to 120 characters.
At most 120 characters.
Mail from this sender: an address, a domain or a name.
At most 1,500 characters.
Mail sent to this address.
At most 1,500 characters.
Mail with these words in its subject.
At most 1,500 characters.
Mail with these words anywhere in it.
At most 1,500 characters.
Mail without these words.
At most 1,500 characters.
Mail that carries a file.
Mail larger than this: bytes, or
5M,500K.Mail smaller than this: bytes, or
5M,500K.Archive it as it arrives.
Mark it read.
Star it.
Put this label on it, by name.
Forward it to this address. Asks for a passkey.
Move it to Trash.
Never send it to Junk.
Mark it important.
Never mark it important. Beats
important.File it in this inbox tab.
One of
primaryupdatesnewsletterspromotionsAlso run it over the conversations already here.
Beside input
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is the Rule object.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.update({
label: "Invoices",
markRead: true,
id: "rl_1c7e3a9f5b2d4068e4a9c2f1",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.update(
{
"label": "Invoices",
"mark_read": True,
"id": "rl_1c7e3a9f5b2d4068e4a9c2f1",
}
)
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.RulesUpdateParams{
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.rules.update(
label: 'Invoices',
mark_read: true,
id: 'rl_1c7e3a9f5b2d4068e4a9c2f1'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->update([
'label' => 'Invoices',
'markRead' => true,
'id' => 'rl_1c7e3a9f5b2d4068e4a9c2f1',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Rule;
import app.mailset.model.RulesUpdateParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesUpdateParams.builder()
.label("Invoices")
.markRead(true)
.id("rl_1c7e3a9f5b2d4068e4a9c2f1")
.build();
Rule answer = mailset.rules().update(params);
System.out.println(answer);
use mailset::types::RulesUpdateParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.update(RulesUpdateParams {
id: "rl_1c7e3a9f5b2d4068e4a9c2f1".into(),
mark_read: Some(true),
label: Some("Invoices".into()),
..Default::default()
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.update \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"label":"Invoices","markRead":true,"id":"rl_1c7e3a9f5b2d4068e4a9c2f1"}}'
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 rules update rl_1c7e3a9f5b2d4068e4a9c2f1 --label Invoices --mark-read
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"name": "Acme API",
"conditions": {
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"subject": "Your Acme receipt",
"hasWords": "text",
"doesntHave": "text",
"hasAttachment": true,
"larger": 1,
"smaller": 1
},
"actions": {
"skipInbox": true,
rules.remove
Delete a rule.
POST/v1/rules.remove
Parameters
The rule’s id, from
rules list.
Returns
data is an object with:
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.remove({
id: "rl_1c7e3a9f5b2d4068e4a9c2f1",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.remove(
{"id": "rl_1c7e3a9f5b2d4068e4a9c2f1"}
)
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.RulesRemoveParams{
ID: "rl_1c7e3a9f5b2d4068e4a9c2f1",
}
answer, err := client.Rules.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.rules.remove(
id: 'rl_1c7e3a9f5b2d4068e4a9c2f1'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->remove([
'id' => 'rl_1c7e3a9f5b2d4068e4a9c2f1',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.RulesRemoveParams;
import app.mailset.model.RulesRemoveResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesRemoveParams.builder()
.id("rl_1c7e3a9f5b2d4068e4a9c2f1")
.build();
RulesRemoveResult answer = mailset.rules().remove(params);
System.out.println(answer);
use mailset::types::RulesRemoveParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.remove(RulesRemoveParams {
id: "rl_1c7e3a9f5b2d4068e4a9c2f1".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.remove \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"rl_1c7e3a9f5b2d4068e4a9c2f1"}}'
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 rules remove rl_1c7e3a9f5b2d4068e4a9c2f1
{
"ok": true,
"data": {
"removed": true
}
}
rules.reorder
Set the order a mailbox’s rules run in.
POST/v1/rules.reorder
Parameters
The mailbox whose rules these are.
Every rule’s id, in the order they should run.
1 to 1,000 items.
Returns
data is a list of Rule objects.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.reorder({
mailbox: "moc.elpmaxe@ana",
ids: [
"rl_9a2f6c1e8b4d3057c1e6a3b8",
"rl_1c7e3a9f5b2d4068e4a9c2f1",
],
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.reorder(
{
"mailbox": "moc.elpmaxe@ana",
"ids": [
"rl_9a2f6c1e8b4d3057c1e6a3b8",
"rl_1c7e3a9f5b2d4068e4a9c2f1",
],
}
)
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.RulesReorderParams{
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.rules.reorder(
mailbox: 'moc.elpmaxe@ana',
ids: [
'rl_9a2f6c1e8b4d3057c1e6a3b8',
'rl_1c7e3a9f5b2d4068e4a9c2f1'
]
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->reorder([
'mailbox' => 'moc.elpmaxe@ana',
'ids' => [
'rl_9a2f6c1e8b4d3057c1e6a3b8',
'rl_1c7e3a9f5b2d4068e4a9c2f1',
],
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Rule;
import app.mailset.model.RulesReorderParams;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesReorderParams.builder()
.mailbox("moc.elpmaxe@ana")
.ids(List.of(
"rl_9a2f6c1e8b4d3057c1e6a3b8",
"rl_1c7e3a9f5b2d4068e4a9c2f1"))
.build();
List<Rule> answer = mailset.rules().reorder(params);
System.out.println(answer);
use mailset::types::RulesReorderParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.reorder(RulesReorderParams {
mailbox: "moc.elpmaxe@ana".into(),
ids: vec![
"rl_9a2f6c1e8b4d3057c1e6a3b8".into(),
"rl_1c7e3a9f5b2d4068e4a9c2f1".into(),
],
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.reorder \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"mailbox":"moc.elpmaxe@ana","ids":["rl_9a2f6c1e8b4d3057c1e6a3b8","rl_1c7e3a9f5b2d4068e4a9c2f1"]}}'
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 rules reorder --mailbox moc.elpmaxe@ana --ids rl_9a2f6c1e8b4d3057c1e6a3b8,rl_1c7e3a9f5b2d4068e4a9c2f1
{
"ok": true,
"data": [
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"name": "Acme API",
"conditions": {
"from": "moc.elpmaxe@olleh",
"to": "moc.elpmaxe@ana",
"subject": "Your Acme receipt",
"hasWords": "text",
"doesntHave": "text",
"hasAttachment": true,
"larger": 1,
"smaller": 1
},
"actions": {
rules.test
Show what a rule would match, without doing anything.
POST/v1/rules.test
Parameters
A rule you have, by its id. Left out: the flags describe one.
The mailbox to test against, for a rule described by flags.
A name for the rule, up to 120 characters.
At most 120 characters.
Mail from this sender: an address, a domain or a name.
At most 1,500 characters.
Mail sent to this address.
At most 1,500 characters.
Mail with these words in its subject.
At most 1,500 characters.
Mail with these words anywhere in it.
At most 1,500 characters.
Mail without these words.
At most 1,500 characters.
Mail that carries a file.
Mail larger than this: bytes, or
5M,500K.Mail smaller than this: bytes, or
5M,500K.Archive it as it arrives.
Mark it read.
Star it.
Put this label on it, by name.
Forward it to this address. Asks for a passkey.
Move it to Trash.
Never send it to Junk.
Mark it important.
Never mark it important. Beats
important.File it in this inbox tab.
One of
primaryupdatesnewsletterspromotions
Returns
data is an object with:
The newest few, to check by eye.
The count stopped at the scan limit, so there may be more.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.test({
mailbox: "moc.elpmaxe@ana",
from: "stripe.com",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.test(
{"mailbox": "moc.elpmaxe@ana", "from": "stripe.com"}
)
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.RulesTestParams{
Mailbox: mailset.String("moc.elpmaxe@ana"),
From: mailset.String("stripe.com"),
}
answer, err := client.Rules.Test(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.rules.test(
mailbox: 'moc.elpmaxe@ana',
from: 'stripe.com'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->test([
'mailbox' => 'moc.elpmaxe@ana',
'from' => 'stripe.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.RuleTest;
import app.mailset.model.RulesTestParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesTestParams.builder()
.mailbox("moc.elpmaxe@ana")
.from("stripe.com")
.build();
RuleTest answer = mailset.rules().test(params);
System.out.println(answer);
use mailset::types::RulesTestParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.test(RulesTestParams {
mailbox: Some("moc.elpmaxe@ana".into()),
from: Some("stripe.com".into()),
..Default::default()
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.test \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"mailbox":"moc.elpmaxe@ana","from":"stripe.com"}}'
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 rules test --mailbox moc.elpmaxe@ana --from stripe.com
{
"ok": true,
"data": {
"matched": 1,
"sample": [
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"from": "moc.elpmaxe@olleh",
"fromAddress": "moc.elpmaxe@olleh",
"subject": "Your Acme receipt",
"snippet": "text",
"count": 12,
"latestAt": 1796048940000,
"unread": true,
"starred": true,
"important": true,
"place": "inbox",
rules.apply
Run a rule over the conversations already here, in the background.
POST/v1/rules.apply
Parameters
The rule’s id, from
rules list.
Returns
data is an object with:
The run’s id.
running,doneorfailed.One of
runningdonefailedConversations looked at so far.
Of those, how many the rule changed.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.apply({
id: "rl_1c7e3a9f5b2d4068e4a9c2f1",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.apply(
{"id": "rl_1c7e3a9f5b2d4068e4a9c2f1"}
)
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.RulesApplyParams{
ID: "rl_1c7e3a9f5b2d4068e4a9c2f1",
}
answer, err := client.Rules.Apply(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.rules.apply(
id: 'rl_1c7e3a9f5b2d4068e4a9c2f1'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->apply([
'id' => 'rl_1c7e3a9f5b2d4068e4a9c2f1',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.RuleRun;
import app.mailset.model.RulesApplyParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesApplyParams.builder()
.id("rl_1c7e3a9f5b2d4068e4a9c2f1")
.build();
RuleRun answer = mailset.rules().apply(params);
System.out.println(answer);
use mailset::types::RulesApplyParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.apply(RulesApplyParams {
id: "rl_1c7e3a9f5b2d4068e4a9c2f1".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/rules.apply \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"rl_1c7e3a9f5b2d4068e4a9c2f1"}}'
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 rules apply rl_1c7e3a9f5b2d4068e4a9c2f1
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"state": "running",
"scanned": 1,
"changed": 1,
"reason": "The day’s sending limit is reached."
}
}
rules.import
Turn a Gmail mailFilters.xml export into rules.
POST/v1/rules.import
Parameters
The mailbox the rules go on.
The file’s name.
At most 255 characters.
The file, base64.
Beside input
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
The body may be up to 8 MB.
Returns
data is an object with:
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.rules.import({
mailbox: "moc.elpmaxe@ana",
name: "mailFilters.xml",
data: "<the message as base64>",
});
console.log(answer);
<the message as base64> is a whole email, headers and body: Send your own MIME.
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.rules.import_rules(
{
"mailbox": "moc.elpmaxe@ana",
"name": "mailFilters.xml",
"data": "<the message as base64>",
}
)
print(answer)
<the message as base64> is a whole email, headers and body: Send your own MIME.
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.RulesImportParams{
<the message as base64> is a whole email, headers and body: Send your own MIME.
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.rules.import(
mailbox: 'moc.elpmaxe@ana',
name: 'mailFilters.xml',
data: '<the message as base64>'
)
p answer
<the message as base64> is a whole email, headers and body: Send your own MIME.
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->rules->import([
'mailbox' => 'moc.elpmaxe@ana',
'name' => 'mailFilters.xml',
'data' => '<the message as base64>',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
<the message as base64> is a whole email, headers and body: Send your own MIME.
import app.mailset.Mailset;
import app.mailset.model.RuleImportReport;
import app.mailset.model.RulesImportParams;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = RulesImportParams.builder()
.mailbox("moc.elpmaxe@ana")
.name("mailFilters.xml")
.data("<the message as base64>")
.build();
RuleImportReport answer =
mailset.rules().importRules(params);
System.out.println(answer);
<the message as base64> is a whole email, headers and body: Send your own MIME.
use mailset::types::RulesImportParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.rules()
.import(RulesImportParams {
mailbox: "moc.elpmaxe@ana".into(),
name: "mailFilters.xml".into(),
data: "<the message as base64>".into(),
})
.await?;
println!("{answer:?}");
<the message as base64> is a whole email, headers and body: Send your own MIME.
curl https://mailset.app/v1/rules.import \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"mailbox":"moc.elpmaxe@ana","name":"mailFilters.xml","data":"<base64 of the file>"}}'
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 rules import moc.elpmaxe@ana --file mailFilters.xml
{
"ok": true,
"data": {
"imported": 1,
"skipped": 1,
"items": [
{
"filter": "text",
"rule": "text",
"notes": [
"text"
]
}
]
}
}