Blocked senders

Blocked senders

Discard a sender’s new email before it is stored.

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

On this page
  1. blocks.list
  2. blocks.add
  3. blocks.addMany
  4. blocks.remove

blocks.list

List the senders blocked in your mailboxes.

POST/v1/blocks.list

API token

Parameters

It takes no input: send an empty object.

Returns

data is a list of objects, each with:

  • mailboxstring

    The mailbox the block is on.

  • addressstring

    The blocked sender.

  • createdAtnumber

    When they were blocked, in milliseconds since 1970.

  • discardednumber

    How many of their messages were discarded since.

  • unsubscribenullable enum

    Whether they were asked to stop sending, too. Null for an older block.

    One ofpendingsentfailednone

In the CLIErrors

import { Mailset } from 'mailset';

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

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

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

answer = mailset.blocks.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.Blocks.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.blocks.list
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->list();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Block;
import java.util.List;

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

List<Block> answer = mailset.blocks().list();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;

let answer = mailset.blocks().list().await?;
println!("{answer:?}");
curl https://mailset.app/v1/blocks.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 blocks list
Response
{
  "ok": true,
  "data": [
    {
      "mailbox": "text",
      "address": "moc.elpmaxe@olleh",
      "createdAt": 1796048940000,
      "discarded": 1,
      "unsubscribe": "pending"
    }
  ]
}

blocks.add

Discard a sender’s new mail in one mailbox.

POST/v1/blocks.add

API token

Parameters

  • mailboxstringrequired

    One of your mailboxes, by address.

  • addressstringrequired

    The sender’s address.

  • everywherebooleanoptional

    In every mailbox you can open, not only this one.

Returns

data is a list of objects, each with:

  • mailboxstring

    The mailbox the block is on.

  • addressstring

    The blocked sender.

  • createdAtnumber

    When they were blocked, in milliseconds since 1970.

  • discardednumber

    How many of their messages were discarded since.

  • unsubscribenullable enum

    Whether they were asked to stop sending, too. Null for an older block.

    One ofpendingsentfailednone

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.blocks.add({
	mailbox: "moc.elpmaxe@ana",
	address: "ten.elpmaxe@sreffo",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.blocks.add(
    {
        "mailbox": "moc.elpmaxe@ana",
        "address": "ten.elpmaxe@sreffo",
    }
)
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.BlocksAddParams{
		Mailbox: "moc.elpmaxe@ana",
		Address: "ten.elpmaxe@sreffo",
	}
	answer, err := client.Blocks.Add(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.blocks.add(
  mailbox: 'moc.elpmaxe@ana',
  address: 'ten.elpmaxe@sreffo'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->add([
    'mailbox' => 'moc.elpmaxe@ana',
    'address' => 'ten.elpmaxe@sreffo',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Block;
import app.mailset.model.BlocksAddParams;
import java.util.List;

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

var params = BlocksAddParams.builder()
        .mailbox("moc.elpmaxe@ana")
        .address("ten.elpmaxe@sreffo")
        .build();
List<Block> answer = mailset.blocks().add(params);
System.out.println(answer);
use mailset::types::BlocksAddParams;

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

let answer = mailset
    .blocks()
    .add(BlocksAddParams {
        mailbox: "moc.elpmaxe@ana".into(),
        address: "ten.elpmaxe@sreffo".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/blocks.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","address":"ten.elpmaxe@sreffo"}}'

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 blocks add ten.elpmaxe@sreffo --mailbox moc.elpmaxe@ana
Response
{
  "ok": true,
  "data": [
    {
      "mailbox": "text",
      "address": "moc.elpmaxe@olleh",
      "createdAt": 1796048940000,
      "discarded": 1,
      "unsubscribe": "pending"
    }
  ]
}

blocks.addMany

Block several senders at once, each in its own mailbox.

POST/v1/blocks.addMany

API token

Parameters

  • sendersarray of objectsrequired

    The senders to block, each with the mailbox to block it in. Up to 100.

    1 to 100 items.

    Show child attributesHide child attributes
    • mailboxstringrequired

      One of your mailboxes, by address.

    • addressstringrequired

      The sender’s address.

Returns

data is a list of objects, each with:

  • mailboxstring

    The mailbox the block is on.

  • addressstring

    The blocked sender.

  • createdAtnumber

    When they were blocked, in milliseconds since 1970.

  • discardednumber

    How many of their messages were discarded since.

  • unsubscribenullable enum

    Whether they were asked to stop sending, too. Null for an older block.

    One ofpendingsentfailednone

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.blocks.addMany({
	senders: [
		{
			mailbox: "moc.elpmaxe@ana",
			address: "ten.elpmaxe@sreffo",
		},
		{
			mailbox: "moc.elpmaxe@ana",
			address: "gro.elpmaxe@slaed",
		},
	],
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.blocks.add_many(
    {
        "senders": [
            {
                "mailbox": "moc.elpmaxe@ana",
                "address": "ten.elpmaxe@sreffo",
            },
            {
                "mailbox": "moc.elpmaxe@ana",
                "address": "gro.elpmaxe@slaed",
            },
        ],
    }
)
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.BlocksAddManyParams{
require 'mailset'

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

answer = mailset.blocks.add_many(
  senders: [
    {
      mailbox: 'moc.elpmaxe@ana',
      address: 'ten.elpmaxe@sreffo'
    },
    {
      mailbox: 'moc.elpmaxe@ana',
      address: 'gro.elpmaxe@slaed'
    }
  ]
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->addMany([
    'senders' => [
        [
            'mailbox' => 'moc.elpmaxe@ana',
            'address' => 'ten.elpmaxe@sreffo',
        ],
        [
            'mailbox' => 'moc.elpmaxe@ana',
            'address' => 'gro.elpmaxe@slaed',
        ],
    ],
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Block;
import app.mailset.model.BlocksAddManyParams;
import app.mailset.model.BlocksAddManyParamsSender;
import java.util.List;

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

var params = BlocksAddManyParams.builder()
        .senders(List.of(
                BlocksAddManyParamsSender.builder()
                        .mailbox("moc.elpmaxe@ana")
                        .address("ten.elpmaxe@sreffo")
                        .build(),
                BlocksAddManyParamsSender.builder()
                        .mailbox("moc.elpmaxe@ana")
                        .address("gro.elpmaxe@slaed")
                        .build()))
        .build();
List<Block> answer = mailset.blocks().addMany(params);
System.out.println(answer);
use mailset::types::{
    BlocksAddManyParams, BlocksAddManyParamsSender,
};

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

let answer = mailset
    .blocks()
    .add_many(BlocksAddManyParams {
        senders: vec![
            BlocksAddManyParamsSender {
                mailbox: "moc.elpmaxe@ana".into(),
                address: "ten.elpmaxe@sreffo".into(),
            },
            BlocksAddManyParamsSender {
                mailbox: "moc.elpmaxe@ana".into(),
                address: "gro.elpmaxe@slaed".into(),
            },
        ],
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/blocks.addMany \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"senders":[{"mailbox":"moc.elpmaxe@ana","address":"ten.elpmaxe@sreffo"},{"mailbox":"moc.elpmaxe@ana","address":"gro.elpmaxe@slaed"}]}}'

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 blocks addMany --senders @senders.json
senders.json
[
  {
    "mailbox": "moc.elpmaxe@ana",
    "address": "ten.elpmaxe@sreffo"
  },
  {
    "mailbox": "moc.elpmaxe@ana",
    "address": "gro.elpmaxe@slaed"
  }
]
Response
{
  "ok": true,
  "data": [
    {
      "mailbox": "text",
      "address": "moc.elpmaxe@olleh",
      "createdAt": 1796048940000,
      "discarded": 1,
      "unsubscribe": "pending"
    }
  ]
}

blocks.remove

Stop blocking a sender.

POST/v1/blocks.remove

API token

Parameters

  • mailboxstringrequired

    One of your mailboxes, by address.

  • addressstringrequired

    The sender’s address.

  • everywherebooleanoptional

    In every mailbox you can open, not only this one.

Returns

data is an object with:

  • removedboolean

    True when there was a block to remove.

In the CLIErrors

import { Mailset } from 'mailset';

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

const answer = await mailset.blocks.remove({
	mailbox: "moc.elpmaxe@ana",
	address: "ten.elpmaxe@sreffo",
});
console.log(answer);
from mailset import Mailset

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

answer = mailset.blocks.remove(
    {
        "mailbox": "moc.elpmaxe@ana",
        "address": "ten.elpmaxe@sreffo",
    }
)
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.BlocksRemoveParams{
		Mailbox: "moc.elpmaxe@ana",
		Address: "ten.elpmaxe@sreffo",
	}
	answer, err := client.Blocks.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.blocks.remove(
  mailbox: 'moc.elpmaxe@ana',
  address: 'ten.elpmaxe@sreffo'
)
p answer
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->remove([
    'mailbox' => 'moc.elpmaxe@ana',
    'address' => 'ten.elpmaxe@sreffo',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.BlocksRemoveParams;
import app.mailset.model.BlocksRemoveResult;

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

var params = BlocksRemoveParams.builder()
        .mailbox("moc.elpmaxe@ana")
        .address("ten.elpmaxe@sreffo")
        .build();
BlocksRemoveResult answer =
        mailset.blocks().remove(params);
System.out.println(answer);
use mailset::types::BlocksRemoveParams;

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

let answer = mailset
    .blocks()
    .remove(BlocksRemoveParams {
        mailbox: "moc.elpmaxe@ana".into(),
        address: "ten.elpmaxe@sreffo".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
curl https://mailset.app/v1/blocks.remove \
  -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","address":"ten.elpmaxe@sreffo"}}'

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 blocks remove ten.elpmaxe@sreffo --mailbox moc.elpmaxe@ana
Response
{
  "ok": true,
  "data": {
    "removed": true
  }
}