# Disable a domain

`DELETE https://api.mailmasker.org/api/v1/domains/:domain`

Stop accepting mail for a domain, without deleting anything.

- Who can use it: Site admins
- Area: Domains and DNS
- Answers 200 OK when it works
- Page: https://developer.mailmasker.org/domain-disable

Turns the domain off (`active` becomes 0), so mail to it is refused from now on. Nothing is deleted: its DNS zone is still served and its extra addresses stay. Change a domain's settings with `active` true turns it back on.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `domain` | path | yes | The domain name. | `example.com` |

## Good to know

- A domain that isn't listed answers 404.
- homelab-cli's `dns domains disable` turns `mail_enabled` off instead, through Change a domain's settings. Mail to the domain is refused either way.

## Examples

cURL:

```bash
curl -s -X DELETE 'https://api.mailmasker.org/api/v1/domains/example.com' \
  -H "Authorization: Bearer $TOKEN"
```

Perl:

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

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

homelab-cli:

There is no homelab-cli command for this yet.

## Response

200 OK:

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