# Block an address

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

Reject all future mail sent to one of your own addresses.

- Who can use it: Any signed-in account
- Area: Your addresses and blocking
- Answers 201 Created when it works
- Page: https://developer.mailmasker.org/block-address

From now on, mail to this address is refused while it is being delivered, so the sender gets a rejection and you never see it. Blocking an address that is already blocked updates its reason.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `recipient` | body | yes | The address to block. It must be one of yours. | `shop@example.com` |
| `action` | body | yes | REJECT to block. (OK would make it an allow entry instead.) | `REJECT` |
| `reason` | body | no | Shown to whoever sends mail to it, in the rejection. | `This address is no longer in use` |

## Good to know

- Your main (login) address can't be blocked, because that would cut off all of your mail; the answer is 400.
- An address you don't own is refused with 403.

## Examples

cURL:

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

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/mine',
    { Authorization => "Bearer $ENV{TOKEN}" },
    json => { recipient => 'shop@example.com', action => 'REJECT', reason => 'This address is no longer in use' })->result;
die $res->code, ' ', ($res->json('/error') // $res->message), "\n" unless $res->is_success;
print $res->body, "\n";
```

homelab-cli:

```bash
homelab-cli mail block shop@example.com --reason "This address is no longer in use"
```

## Response

201 Created:

```json
{
  "recipient": "shop@example.com",
  "action": "REJECT",
  "reason": "This address is no longer in use",
  "created_by": "you@example.com",
  "user_email": "you@example.com",
  "created_at": "2026-11-03 21:42:10.123456-06",
  "updated_at": "2026-11-03 21:42:10.123456-06"
}
```
