# Blocked senders

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

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).

## blocks.list

List the senders blocked in your mailboxes.

`POST /v1/blocks.list`

Any signed-in person, with an API token.

### Parameters

It takes no input: send an empty object.

### Returns

`data` is a list of objects, each with:

- `mailbox` (string): The mailbox the block is on.
- `address` (string): The blocked sender.
- `createdAt` (number): When they were blocked, in milliseconds since 1970.
- `discarded` (number): How many of their messages were discarded since.
- `unsubscribe` (nullable enum): Whether they were asked to stop sending, too. Null for an older block. One of `pending`, `sent`, `failed`, `none`.

### Request

TypeScript:

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

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

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

Python:

```python
from mailset import Mailset

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

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

PHP:

```php
<?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;
```

Java:

```java
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);
```

Rust:

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

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

curl:

```bash
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](https://mailset.app/docs/authentication/http) shows how.

CLI:

```bash
mailset blocks list
```

### Response

```json
{
  "ok": true,
  "data": [
    {
      "mailbox": "text",
      "address": "hello@example.com",
      "createdAt": 1796048940000,
      "discarded": 1,
      "unsubscribe": "pending"
    }
  ]
}
```

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

## blocks.add

Discard a sender’s new mail in one mailbox.

`POST /v1/blocks.add`

Any signed-in person, with an API token.

### Parameters

- `mailbox` (string, required): One of your mailboxes, by address.
- `address` (string, required): The sender’s address.
- `everywhere` (boolean, optional): In every mailbox you can open, not only this one.

### Returns

`data` is a list of objects, each with:

- `mailbox` (string): The mailbox the block is on.
- `address` (string): The blocked sender.
- `createdAt` (number): When they were blocked, in milliseconds since 1970.
- `discarded` (number): How many of their messages were discarded since.
- `unsubscribe` (nullable enum): Whether they were asked to stop sending, too. Null for an older block. One of `pending`, `sent`, `failed`, `none`.

### Request

TypeScript:

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

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

const answer = await mailset.blocks.add({
	mailbox: "ana@example.com",
	address: "offers@example.net",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.blocks.add(
    {
        "mailbox": "ana@example.com",
        "address": "offers@example.net",
    }
)
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.BlocksAddParams{
		Mailbox: "ana@example.com",
		Address: "offers@example.net",
	}
	answer, err := client.Blocks.Add(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.blocks.add(
  mailbox: 'ana@example.com',
  address: 'offers@example.net'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->add([
    'mailbox' => 'ana@example.com',
    'address' => 'offers@example.net',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
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("ana@example.com")
        .address("offers@example.net")
        .build();
List<Block> answer = mailset.blocks().add(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::BlocksAddParams;

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

let answer = mailset
    .blocks()
    .add(BlocksAddParams {
        mailbox: "ana@example.com".into(),
        address: "offers@example.net".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
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":"ana@example.com","address":"offers@example.net"}}'
```

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 blocks add offers@example.net --mailbox ana@example.com
```

### Response

```json
{
  "ok": true,
  "data": [
    {
      "mailbox": "text",
      "address": "hello@example.com",
      "createdAt": 1796048940000,
      "discarded": 1,
      "unsubscribe": "pending"
    }
  ]
}
```

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

## blocks.addMany

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

`POST /v1/blocks.addMany`

Any signed-in person, with an API token.

### Parameters

- `senders` (array of objects, required): The senders to block, each with the mailbox to block it in. Up to 100. 1 to 100 items.
  - `mailbox` (string, required): One of your mailboxes, by address.
  - `address` (string, required): The sender’s address.

### Returns

`data` is a list of objects, each with:

- `mailbox` (string): The mailbox the block is on.
- `address` (string): The blocked sender.
- `createdAt` (number): When they were blocked, in milliseconds since 1970.
- `discarded` (number): How many of their messages were discarded since.
- `unsubscribe` (nullable enum): Whether they were asked to stop sending, too. Null for an older block. One of `pending`, `sent`, `failed`, `none`.

### Request

TypeScript:

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

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

const answer = await mailset.blocks.addMany({
	senders: [
		{
			mailbox: "ana@example.com",
			address: "offers@example.net",
		},
		{
			mailbox: "ana@example.com",
			address: "deals@example.org",
		},
	],
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.blocks.add_many(
    {
        "senders": [
            {
                "mailbox": "ana@example.com",
                "address": "offers@example.net",
            },
            {
                "mailbox": "ana@example.com",
                "address": "deals@example.org",
            },
        ],
    }
)
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.BlocksAddManyParams{
		Senders: []mailset.BlocksAddManyParamsSender{
			{
				Mailbox: "ana@example.com",
				Address: "offers@example.net",
			},
			{
				Mailbox: "ana@example.com",
				Address: "deals@example.org",
			},
		},
	}
	answer, err := client.Blocks.AddMany(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.blocks.add_many(
  senders: [
    {
      mailbox: 'ana@example.com',
      address: 'offers@example.net'
    },
    {
      mailbox: 'ana@example.com',
      address: 'deals@example.org'
    }
  ]
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->addMany([
    'senders' => [
        [
            'mailbox' => 'ana@example.com',
            'address' => 'offers@example.net',
        ],
        [
            'mailbox' => 'ana@example.com',
            'address' => 'deals@example.org',
        ],
    ],
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
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("ana@example.com")
                        .address("offers@example.net")
                        .build(),
                BlocksAddManyParamsSender.builder()
                        .mailbox("ana@example.com")
                        .address("deals@example.org")
                        .build()))
        .build();
List<Block> answer = mailset.blocks().addMany(params);
System.out.println(answer);
```

Rust:

```rust
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: "ana@example.com".into(),
                address: "offers@example.net".into(),
            },
            BlocksAddManyParamsSender {
                mailbox: "ana@example.com".into(),
                address: "deals@example.org".into(),
            },
        ],
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
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":"ana@example.com","address":"offers@example.net"},{"mailbox":"ana@example.com","address":"deals@example.org"}]}}'
```

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 blocks addMany --senders @senders.json
```

`senders.json`:

```json
[
  {
    "mailbox": "ana@example.com",
    "address": "offers@example.net"
  },
  {
    "mailbox": "ana@example.com",
    "address": "deals@example.org"
  }
]
```

### Response

```json
{
  "ok": true,
  "data": [
    {
      "mailbox": "text",
      "address": "hello@example.com",
      "createdAt": 1796048940000,
      "discarded": 1,
      "unsubscribe": "pending"
    }
  ]
}
```

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

## blocks.remove

Stop blocking a sender.

`POST /v1/blocks.remove`

Any signed-in person, with an API token.

### Parameters

- `mailbox` (string, required): One of your mailboxes, by address.
- `address` (string, required): The sender’s address.
- `everywhere` (boolean, optional): In every mailbox you can open, not only this one.

### Returns

`data` is an object with:

- `removed` (boolean): True when there was a block to remove.

### Request

TypeScript:

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

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

const answer = await mailset.blocks.remove({
	mailbox: "ana@example.com",
	address: "offers@example.net",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.blocks.remove(
    {
        "mailbox": "ana@example.com",
        "address": "offers@example.net",
    }
)
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.BlocksRemoveParams{
		Mailbox: "ana@example.com",
		Address: "offers@example.net",
	}
	answer, err := client.Blocks.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.blocks.remove(
  mailbox: 'ana@example.com',
  address: 'offers@example.net'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->blocks->remove([
    'mailbox' => 'ana@example.com',
    'address' => 'offers@example.net',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
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("ana@example.com")
        .address("offers@example.net")
        .build();
BlocksRemoveResult answer =
        mailset.blocks().remove(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::BlocksRemoveParams;

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

let answer = mailset
    .blocks()
    .remove(BlocksRemoveParams {
        mailbox: "ana@example.com".into(),
        address: "offers@example.net".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
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":"ana@example.com","address":"offers@example.net"}}'
```

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 blocks remove offers@example.net --mailbox ana@example.com
```

### Response

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

In the CLI: [mailset reference](https://mailset.app/docs/cli/blocks#blocks-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