# Delete a role

`DELETE https://api.mailmasker.org/api/v1/admin/roles/:name`

Remove a role, taking it from every account that has it.

- Who can use it: Site admins
- Area: Users and roles
- Answers 200 OK when it works
- Page: https://developer.mailmasker.org/admin-delete-role

The role goes completely: every account that had it loses it at once, along with the permissions it carried.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `name` | path | yes | The role's name. | `auditor` |

## Good to know

- The built-in `user`, `site_admin` and `system_agent` roles are protected; deleting one answers 400.
- An unknown role answers 404.

## Examples

cURL:

```bash
curl -s -X DELETE 'https://api.mailmasker.org/api/v1/admin/roles/auditor' \
  -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/admin/roles/auditor',
    { Authorization => "Bearer $ENV{TOKEN}" })->result;
die $res->code, ' ', ($res->json('/error') // $res->message), "\n" unless $res->is_success;
print $res->body, "\n";
```

homelab-cli:

```bash
homelab-cli admin roles remove auditor
```

## Response

200 OK:

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