# Unsubscribes

Who opted out of a mailbox’s or sending domain’s promotional email.

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

## The Unsubscribe object

One address that opted out of a mailbox’s or sending domain’s promotional email, and when.

### Attributes

- `address` (string): The address that unsubscribed, in lowercase.
- `at` (number): When, in milliseconds since 1970.
- `app` (nullable string): The app key whose mail the link was in, by the name it was approved with. Null when a person sent that mail.

```json
{
  "address": "ana@example.org",
  "at": 1796048940000,
  "app": "Acme News"
}
```

Answered by [unsubscribes.list](https://mailset.app/docs/api/unsubscribes#unsubscribes.list).

## unsubscribes.list

Who unsubscribed from a mailbox’s (or a domain key’s domain’s) promotional mail, newest first.

`POST /v1/unsubscribes.list`

An app key that may send as the mailbox, or as the addresses it names on the domain. Or a person: an admin or owner of the org.

### Parameters

- `mailbox` (string, required): The mailbox whose promotional mail they unsubscribed from, by its address. For a domain key’s mail, its sending domain, such as `example.com`.
- `cursor` (string, optional): The `next` of the page before, for the page after it. At most 600 characters.

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is an object with:

- `unsubscribes` (array of [Unsubscribe](https://mailset.app/docs/api/unsubscribes#unsubscribe) objects): Up to 100 opt-outs, newest first.
- `next` (nullable string): Pass back as `cursor` for the next page. Null on the last one.

### Request

TypeScript:

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

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

const answer = await mailset.unsubscribes.list({
	mailbox: "news@news.example.com",
});
console.log(answer);
```

Python:

```python
from mailset import Mailset

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

answer = mailset.unsubscribes.list(
    {"mailbox": "news@news.example.com"}
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_KEY from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.UnsubscribesListParams{
		Mailbox: "news@news.example.com",
	}
	answer, err := client.Unsubscribes.List(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.unsubscribes.list(
  mailbox: 'news@news.example.com'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

$answer = $mailset->unsubscribes->list([
    'mailbox' => 'news@news.example.com',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
```

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.UnsubscribePage;
import app.mailset.model.UnsubscribesListParams;

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

var params = UnsubscribesListParams.builder()
        .mailbox("news@news.example.com")
        .build();
UnsubscribePage answer =
        mailset.unsubscribes().list(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::UnsubscribesListParams;

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

let answer = mailset
    .unsubscribes()
    .list(UnsubscribesListParams {
        mailbox: "news@news.example.com".into(),
        ..Default::default()
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/unsubscribes.list \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"mailbox":"news@news.example.com"},"org":"org_3f9a1c0e7b2d"}'
```

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 unsubscribes list news@news.example.com
```

### Response

```json
{
  "ok": true,
  "data": {
    "unsubscribes": [
      {
        "address": "ana@example.org",
        "at": 1796048940000,
        "app": "Acme News"
      }
    ],
    "next": null
  }
}
```

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

## unsubscribes.remove

Let a mailbox’s (or a domain key’s domain’s) promotional mail reach an address again, once they ask for it.

`POST /v1/unsubscribes.remove`

An app key that may send as the mailbox, or as the addresses it names on the domain. Or a person: an admin or owner of the org.

### Parameters

- `mailbox` (string, required): The mailbox they unsubscribed from, by its address. For a domain key’s mail, its sending domain, such as `example.com`.
- `address` (string, required): The address that asked for its promotional mail again.

Beside `input`:

- `org` (string, optional): The org this is about. Needed when the caller is in more than one.

### Returns

`data` is an object with:

- `removed` (boolean): True when the address had unsubscribed and now gets this mailbox’s promotional mail again. False when it hadn’t.

### Request

TypeScript:

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

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

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

Python:

```python
from mailset import Mailset

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

answer = mailset.unsubscribes.remove(
    {
        "address": "ana@example.org",
        "mailbox": "news@news.example.com",
    }
)
print(answer)
```

Go:

```go
package main

import (
	"context"
	"fmt"
	"log"

	mailset "mailset.app/go"
)

func main() {
	// Reads MAILSET_KEY from the environment.
	client, err := mailset.NewClient()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()
	params := &mailset.UnsubscribesRemoveParams{
		Address: "ana@example.org",
		Mailbox: "news@news.example.com",
	}
	answer, err := client.Unsubscribes.Remove(ctx, params)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(answer)
}
```

Ruby:

```ruby
require 'mailset'

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

answer = mailset.unsubscribes.remove(
  address: 'ana@example.org',
  mailbox: 'news@news.example.com'
)
p answer
```

PHP:

```php
<?php

require 'vendor/autoload.php';

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

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

Java:

```java
import app.mailset.Mailset;
import app.mailset.model.UnsubscribesRemoveParams;
import app.mailset.model.UnsubscribesRemoveResult;

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

var params = UnsubscribesRemoveParams.builder()
        .address("ana@example.org")
        .mailbox("news@news.example.com")
        .build();
UnsubscribesRemoveResult answer =
        mailset.unsubscribes().remove(params);
System.out.println(answer);
```

Rust:

```rust
use mailset::types::UnsubscribesRemoveParams;

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

let answer = mailset
    .unsubscribes()
    .remove(UnsubscribesRemoveParams {
        mailbox: "news@news.example.com".into(),
        address: "ana@example.org".into(),
    })
    .await?;
println!("{answer:?}");
```

curl:

```bash
curl https://mailset.app/v1/unsubscribes.remove \
  -H "Authorization: Bearer $TOKEN" \
  -H "ms-time: $MS_TIME" \
  -H "ms-proof: $MS_PROOF" \
  -H "Content-Type: application/json" \
  -d '{"input":{"address":"ana@example.org","mailbox":"news@news.example.com"},"org":"org_3f9a1c0e7b2d"}'
```

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 unsubscribes remove news@news.example.com --address ana@example.org
```

### Response

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

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