# Block or allow any address

`POST https://api.mailmasker.org/api/v1/domains/recipient-access`

Reject all mail to an address, or let it through ahead of every other check.

- Who can use it: Site admins
- Area: Domains and DNS
- Answers 201 Created when it works
- Page: https://developer.mailmasker.org/block-any-address

Takes effect at once, for mail from every sender. Unlike blocking your own addresses, nothing here checks whose address it is.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `recipient` | body | yes | The address. Any address, not only one of yours. | `shop@example.com` |
| `action` | body | yes | REJECT to block, or OK to allow ahead of every other check. Other Postfix actions, such as DISCARD, are passed on as written. | `REJECT` |
| `reason` | body | no | Why. A blocked sender sees it in the rejection. | `Sells addresses` |

## Good to know

- An address already on the list is updated in place, and stays with the account or admin who first made it.
- Nothing stops this blocking an account's own login address, which cuts off all of its mail.

## Examples

cURL:

```bash
curl -s -X POST 'https://api.mailmasker.org/api/v1/domains/recipient-access' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"recipient":"shop@example.com","action":"REJECT","reason":"Sells addresses"}'
```

Perl:

```perl
use Mojo::Base -strict;
use Mojo::UserAgent;

my $ua  = Mojo::UserAgent->new;
my $res = $ua->post('https://api.mailmasker.org/api/v1/domains/recipient-access',
    { Authorization => "Bearer $ENV{TOKEN}" },
    json => { recipient => 'shop@example.com', action => 'REJECT', reason => 'Sells addresses' })->result;
die $res->code, ' ', ($res->json('/error') // $res->message), "\n" unless $res->is_success;
print $res->body, "\n";
```

homelab-cli:

```bash
homelab-cli dns recipient-access block shop@example.com --reason "Sells addresses"
```

## Response

201 Created:

```json
{
  "id": 9,
  "recipient": "shop@example.com",
  "action": "REJECT",
  "reason": "Sells addresses",
  "created_by": "you@example.com",
  "user_email": null,
  "created_at": "2026-11-03 21:42:10.123456-06",
  "updated_at": "2026-11-03 21:42:10.123456-06"
}
```
