# Take a role from an account

`DELETE https://api.mailmasker.org/api/v1/admin/users/:id/roles/:role`

Remove one role from an account.

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

The account loses what the role allowed, unless another of its roles allows the same. Each removal is recorded in the audit log.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The account's number, from the account list. | `7` |
| `role` | path | yes | The role's name. | `auditor` |

## Good to know

- It answers ok even when the account didn't have the role.
- Nothing stops you taking `site_admin` from your own account, so take care.

## Examples

cURL:

```bash
curl -s -X DELETE 'https://api.mailmasker.org/api/v1/admin/users/7/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/users/7/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 users revoke-role 7 auditor
```

## Response

200 OK:

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