# Create an account without an invite

`POST https://api.mailmasker.org/api/v1/admin/users/service-account`

Make an account directly, for a system mailbox or an operator or test login.

- Who can use it: Site admins
- Area: Users and roles
- Answers 201 Created when it works
- Page: https://developer.mailmasker.org/admin-create-service-account

For an account the invite process won't make: a system mailbox (the one invites are sent from, say), or an operator or test account on one of this system's own mail domains. It gets the ordinary `user` role and signs in to mail like any other account. Without a `password`, a random one is made. Either way the answer shows it, this once only.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `email` | body | yes | The new account's address. | `invites@example.com` |
| `password` | body | no | A password to use instead of a random one. At least 8 characters. |  |

## Good to know

- Keep the password when you get it; it is never shown again.
- An address that already has an account answers 409, and a password shorter than 8 characters 400.
- The new account is recorded in the audit log.

## Examples

cURL:

```bash
curl -s -X POST 'https://api.mailmasker.org/api/v1/admin/users/service-account' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"email":"invites@example.com"}'
```

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/service-account',
    { Authorization => "Bearer $ENV{TOKEN}" },
    json => { email => 'invites@example.com' })->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 create-service-account --email invites@example.com
```

## Response

201 Created:

```json
{ "id": 12, "email": "invites@example.com", "password": "<generated password>" }
```
