# Suspend or restore an account

`POST https://api.mailmasker.org/api/v1/admin/users/:id/active`

Stop an account signing in anywhere, or let it sign in again.

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

Suspending stops every way the account signs in, all at once: the web, single sign-on, reading mail and sending it. It also ends the account's current sign-in sessions and their refresh tokens, so it can't go on using one it already has. Restoring lets it sign in again. Nothing is deleted either way.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The account's number, from the account list. | `7` |
| `active` | body | yes | false to suspend the account, true to restore it. | `false` |

## Good to know

- Leaving out `active` counts as false, so it suspends.
- You can't suspend your own account; the answer is 400.
- An unknown account answers 404.

## Examples

cURL:

```bash
curl -s -X POST 'https://api.mailmasker.org/api/v1/admin/users/7/active' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"active":false}'
```

Perl:

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

my $ua  = Mojo::UserAgent->new;
my $res = $ua->post('https://api.mailmasker.org/api/v1/admin/users/7/active',
    { Authorization => "Bearer $ENV{TOKEN}" },
    json => { active => \0 })->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, "id": 7, "email": "alice@example.com", "active": false }
```
