# Suppressions

Block sends to addresses that bounced, complained, or were added manually. Suppressions belong to your Groundmail account, and each of your [tenants](https://docs.groundmail.dev/tenants) also has its own list.

Base URL: `https://api.groundmail.dev`

---

## Authentication

```http
Authorization: Bearer gm_…
```

Requires a **full**-scope API key (or dashboard session). Sending-scoped keys cannot manage suppressions.

---

## Behavior

- Emails are stored **normalized lowercase**.
- Hard bounces, permanent SMTP delivery failures (e.g. invalid mailbox / 5xx), and complaint-like events auto-add suppressions (`source: bounce` / `complaint`).
- Block bounces (`bounce_type: "block"`: the receiving server refused the sender because of reputation or policy, not because of the address) never add a suppression.
- Emails refused for their size (`552 5.3.4`, `5.2.3`) fail without adding a suppression: the address takes a smaller email. A full mailbox (`552 5.2.2`) is still suppressed.
- Managed unsubscribe links add suppressions with `source: unsubscribe`.
- One-click unsubscribes from one category (product or newsletter email) are kept as [category opt-outs](#category-opt-outs), not suppressions: the reader still gets your other mail.
- `POST /emails` checks `to` / `cc` / `bcc` before sending. Suppressed recipients are left out: the email goes to the rest, and the response lists them in `held_back` with `reason: "suppressed"`. When every `to` recipient is suppressed, nothing is sent: the API returns **422** with `code: validation_error` and `details.suppressed`, and emits `email.suppressed` (a `suppressed` email record is created).

---

## Tenant lists

If you use [tenants](https://docs.groundmail.dev/tenants), bounces, complaints and unsubscribes on a tenant's email go on that tenant's own list, so a complaint to one of your customers never stops another customer emailing the same person. Sends for a tenant check its list and your account-wide list. Category opt-outs (a reader leaving a tenant's product or newsletter email) are kept per tenant the same way.

- `GET /suppressions?tenant=cust_8412` lists the tenant's list. Its entries carry `"tenant": "cust_8412"`.
- `POST /suppressions` with `"tenant": "cust_8412"` adds to the tenant's list only.
- `DELETE /suppressions?email=…&tenant=cust_8412` (or `DELETE /suppressions/{id}?tenant=cust_8412`) removes from it.
- Add `type=category_opt_out` to list or remove a tenant's [category opt-outs](#category-opt-outs).
- A key limited to one tenant always works on its tenant's list.

Without `tenant`, these endpoints work on the account-wide list, which applies to every send.

---

## Groundmail validation on send

Your suppression list holds what *your* account has learned. On top of it, Groundmail validation holds back recipients that cannot receive email before they bounce, whichever account learned it first. See [Recipients held back by Groundmail validation](https://docs.groundmail.dev/emails#recipients-held-back-by-groundmail-validation) for the reasons and the response shapes.

- Held-back recipients are **not** added to your suppression list. Fix the address and the next send goes out.
- An email with some recipients held back still goes to the rest; one with every `to` held back is refused with `details.held_back`, like a suppressed recipient.
- Two of the checks use what Groundmail has seen across senders: `previously_bounced` (a hard bounce for any Groundmail sender in the last 90 days; block bounces never count) and `mailbox_not_found`. An account owner can turn both off in **Settings → Suppressions** ("Hold back addresses known to bounce"). Invalid addresses and domains with no mail server are always held back.
- To check an address before you accept it, use [`POST /validate`](https://docs.groundmail.dev/validation).

---

## List

`GET /suppressions`

Query: `limit`, `cursor`, optional `email`.

```json
{
  "data": [
    {
      "id": "…",
      "email": "bad@example.com",
      "reason": "550 user unknown",
      "source": "bounce",
      "created_at": "2026-07-26T12:00:00.000Z",
      "updated_at": "2026-07-26T12:00:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

---

## Add

`POST /suppressions`

```json
{ "email": "user@example.com", "reason": "manual opt-out" }
```

`source` is set to `api`. Upserts on `(account, email)`.

---

## Remove

`DELETE /suppressions/{id}`, where `{id}` is the suppression `id` or the address itself (`DELETE /suppressions/user@example.com`)

or

`DELETE /suppressions?email=user@example.com`

Returns `404` (`not_found`) when nothing matches.

```json
{ "ok": true }
```

---

## Category opt-outs

A reader who uses the one-click unsubscribe on product or newsletter email is opted out of that category only. Sends in that category to them return **422** with `details.category_unsubscribed`; transactional email still goes out. A product opt-out also covers newsletters, since it's the broader no; a newsletter opt-out leaves product email alone. On a [tenant's](https://docs.groundmail.dev/tenants) email the opt-out applies to that tenant only.

Add `type=category_opt_out` to the list and remove endpoints to work with these instead of the suppression list. `tenant` works the same way as for suppressions: with it you see and change that tenant's opt-outs, without it the account-wide ones, and a key limited to one tenant always works on its tenant's.

### List opt-outs

`GET /suppressions?type=category_opt_out`

Query: `limit`, `cursor`, optional `email`, `category` (`product` or `newsletter`), `tenant`. Without `tenant`, add `include_tenants=true` to list the account-wide opt-outs and every tenant's together.

```json
{
  "data": [
    {
      "id": "6f1c…",
      "type": "category_opt_out",
      "email": "reader@example.com",
      "category": "newsletter",
      "tenant": "cust_8412",
      "created_at": "2026-10-19T12:00:00.000Z",
      "updated_at": "2026-10-19T12:00:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

`tenant` is `null` on an account-wide opt-out.

### Remove an opt-out

When the reader asks to hear from you again (they re-subscribe, or sign up again), remove the opt-out so sends in that category reach them:

`DELETE /suppressions?type=category_opt_out&email=reader@example.com&category=newsletter&tenant=cust_8412`

or by opt-out id (or address):

`DELETE /suppressions/{id}?type=category_opt_out&tenant=cust_8412`

Leave out `category` to remove every category for the address. Returns `404` (`not_found`) when nothing matches, which you can treat as "already subscribed".

```json
{ "ok": true, "deleted": 1 }
```

Only remove an opt-out when the reader asked for the mail again. Re-adding someone who unsubscribed is the fastest way to collect spam complaints.

---

## SDK

```ts
import { Groundmail } from 'groundmail'

const client = new Groundmail(process.env.GROUNDMAIL_API_KEY!)

await client.suppressions.create({ email: 'user@example.com', reason: 'opt-out' })
const { data } = await client.suppressions.list()
await client.suppressions.remove('user@example.com')

// A tenant's own list
await client.suppressions.create({ email: 'user@example.com', tenant: 'cust_8412' })
await client.suppressions.remove('user@example.com', { tenant: 'cust_8412' })

// Category opt-outs: list a tenant's, and re-subscribe a reader to its newsletter
const { data: optOuts } = await client.suppressions.listCategoryOptOuts({ tenant: 'cust_8412' })
await client.suppressions.removeCategoryOptOut('reader@example.com', {
  category: 'newsletter',
  tenant: 'cust_8412',
})
```

---

## CLI

```bash
groundmail suppressions list
groundmail suppressions add --email user@example.com --reason "opt-out"
groundmail suppressions remove --email user@example.com

# Category opt-outs
groundmail suppressions list --type category_opt_out --tenant cust_8412
groundmail suppressions remove --type category_opt_out --email reader@example.com --category newsletter --tenant cust_8412
```

---

## OpenAPI

[`openapi/groundmail.yaml`](https://docs.groundmail.dev/openapi.yaml)
