# Change a domain's settings

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

Turn a domain's mail, its DNS management, or the whole domain on or off.

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

Send only what you want to change; the rest stays as it is. The answer is the domain's settings afterwards.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `domain` | path | yes | The domain name. | `example.com` |
| `mail_enabled` | body | no | Accept mail for the domain. | `true` |
| `dns_managed` | body | no | Whether its DNS zone is kept here. Only the setting changes; no zone is created or removed. |  |
| `active` | body | no | false turns the whole domain off, as Disable a domain does; true turns it back on. |  |

## Good to know

- A domain that isn't listed answers 404.

## Examples

cURL:

```bash
curl -s -X PATCH 'https://api.mailmasker.org/api/v1/domains/example.com' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"mail_enabled":true}'
```

Perl:

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

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

homelab-cli:

```bash
homelab-cli dns domains enable example.com
```

## Response

200 OK:

```json
{
  "id": 1,
  "domain_name": "example.com",
  "mail_enabled": 1,
  "dns_managed": 1,
  "active": 1,
  "created_by": "you@example.com",
  "created_at": "2026-11-03 21:42:10.123456-06",
  "updated_at": "2026-11-03 21:50:02.654321-06"
}
```
