# POST /mail/settings

First published 14 Oct 2026 (release 0.2.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the mail group.

Save one or more mail settings together

- Who may call it: administrator
- Token scope, any of: mail, all
- Answers: 200 OK

Only administrators can call this operation. The token must have the mail scope. UrbeStack returns 400 if settings is missing, is empty, is not an object, or contains a key with an invalid format. Use the urbestack-mail-smarthost-set command to update mail.smarthost.

UrbeStack validates each setting, generates the mail configuration once, and runs one round of checks using postfix check, doveconf, rspamadm configtest, and webmail PHP-FPM. If all checks pass, UrbeStack reloads the affected daemons in one pass and returns 200 with the stored settings and details of the configuration changes and reloads.

If a configuration check fails, UrbeStack returns the check output and rolls back the entire save. It restores the previous settings and configuration files without reloading the daemons.

## As a command

- [urbestack-mail-settings-set](https://urbestack.com/docs/commands/urbestack-mail-settings-set.md): Saves one or more mail.* settings together.

## Request body

JSON.

- `settings` (object, required): Nonempty object mapping mail.* setting names to their values, excluding mail.webmail_des_key and mail.smarthost. Each key starts with mail. followed by 1 to 64 lowercase ASCII letters or underscores.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/mail/settings" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "settings": {}
  }'
```

Response, 200 OK:

```
{
  "mail": {},
  "settings": {}
}
```

## Errors

- 400: '<zone>' is not a zone this machine knows: timedatectl list-timezones names them
- 400: --set wants KEY=VALUE, not '<pair>'
- 400: <k> is not a mail setting
- 400: <key> is not a mail setting saved here
- 400: <what> must be text without control characters, 1 to <max> characters
- 400: A new job is queued or running
- 400: Domain name required
- 400: Domain name too long
- 400: Invalid IPv4 address
- 400: Invalid IPv6 address
- 400: Invalid domain name
- 400: Invalid port
- 400: Invalid setting key
- 400: Job parameters must be an object
- 400: No setting was given
- 400: PHP <version> cannot be the default: it is hidden from new choices on this server
- 400: PHP <version> cannot be the default: it is not installed on this server
- 400: Standard input must hold a JSON object of key to value
- 400: Unknown job type
- 400: Unknown setting '<key>'
- 400: jobs.keep_days (<keep>) may not be smaller than jobs.show_days (<show>): a job cannot be shown longer than it is kept; 0 keeps them for good
- 400: settings must be an object of mail.* keys to values
- 401: Authentication required
- 404: Setting '<key>' not found
- 409: <key> cannot take that value: <SECOND>{<k>}{on} <sp> (<k>). <SECOND>{<k>}{move}, or choose another
- 409: <key> cannot take that value: the panel listens on port <port> (panel.port). Move the panel first, or choose another
- 409: <s.subject> cannot take port <port>: 
- 409: <s.subject> cannot take port <port>: <why>
- 409: <s.subject> cannot take port <port>: it is the panel's port (panel.port)
- 409: A change is already armed for revert (
- 409: Sharing is required with this license.
- 409: The panel cannot take port <port>: 
- 409: The panel cannot take port <port>: <why>
- 409: These are the nameservers of a distribution network with several nodes, and every node lists the same ones. To remove a nameserver or move it to another node, use the actions beside its name on DNS zones › Nameservers & addresses, or urbestack-dns-nameserver
