# Set an account's mail quota

`POST https://api.mailmasker.org/api/v1/admin/users/:id/mail-quota`

Change how much mail one account may keep, or put it back to the default.

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

Sets the account's own limit, in bytes, which the mail server then enforces. Leave out `limit_bytes` (or send null) to remove the account's own limit, so the 1 TB default applies again.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The account's number, from the account list. | `7` |
| `limit_bytes` | body | no | The new limit in bytes, as a whole number. Leave it out, or send null, for the default. | `5368709120` |

## Good to know

- Putting it back to the default answers a null `mail_quota_bytes` and a `note` saying "reset to default".
- A limit lower than what the account already keeps deletes nothing, so check its usage first.
- A limit that isn't a whole number answers 400, and an unknown account 404.

## Examples

cURL:

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

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/mail-quota',
    { Authorization => "Bearer $ENV{TOKEN}" },
    json => { limit_bytes => 5368709120 })->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, "email": "alice@example.com", "mail_quota_bytes": 5368709120 }
```
