:::endpoint PUT /v1/admin/settings/support

Only the fields you send change, so somebody who fixes the phone number does
not write back a mode or an assistant a colleague changed meanwhile. The save
is one transaction: all of it lands, or none.

The assistant's three fields also need `manage_ai_settings`, and the two mail
switches `manage_email`, because they are kept where the AI Settings and Email
templates screens keep them. A save that carries one of them without that
permission is refused whole, with `403 forbidden`, rather than half saved.
That refusal carries no `required_permission`. The [settings](/docs/api/admin/support-settings)
say in `can` beforehand which fields this person may send.

Text is trimmed, and a field sent empty is saved as null. `assistant_name`
is the exception: sent empty, it is refused.

Answers with the [settings](/docs/api/admin/support-settings) as they are now.

Needs a firm. Our own staff name one with the `Propper-Workspace` header.

## Request

| Field                           | Description |
| ------------------------------- | ----------- |
| `support_mode`                  | `ai_first`, `human_only` or `disabled` |
| `contact_page`                  | `builtin` for the firm's own page at `/contact`, which clears `external_contact_url`, or `external`. Not stored: the saved address is the choice. With `external`, an `external_contact_url` sent empty or null is refused. Left out, the saved address stays |
| `external_contact_url`          | Where `/contact` sends everybody: an `http` or `https` address, up to 2048 characters |
| `support_email`                 | A valid email address, up to 255 characters |
| `support_phone`                 | Up to 50 characters |
| `support_address`               | Up to 500 characters, line breaks allowed |
| `auto_close_enabled`            | `true` or `false`. Off, a ticket waiting on the trader stays open until somebody closes it, including one already warned |
| `auto_close_warn_after_days`    | Days of silence before the warning, 1 to 60 |
| `auto_close_after_warning_days` | Days after the warning before the ticket closes, 1 to 30 |
| `assistant_name`                | Up to 50 characters. Needs `manage_ai_settings` |
| `assistant_personality`         | `professional`, `casual`, `friendly` or `custom`. Needs `manage_ai_settings` |
| `assistant_instructions`        | Up to 2000 characters, null for none. Needs `manage_ai_settings` |
| `mail_reply_enabled`            | The mail to a trader who is away when the team answers. Needs `manage_email` |
| `mail_idle_warning_enabled`     | The mail with the warning that a quiet ticket is about to close. Switching it off does not stop quiet tickets from closing. Needs `manage_email` |

A change to the days applies from the next daily run, to every ticket already
waiting on a trader.

```bash
curl -X PUT "https://api.proppertrading.com/v1/admin/settings/support" \
  -H "Authorization: Bearer ptat_9f2c1a44_3b8e7d2f5c9a1b4e6d8f0a2c4e6b8d1f" \
  -H "Propper-Workspace: acme" \
  -H "Content-Type: application/json" \
  -d '{"support_mode": "ai_first", "contact_page": "external", "external_contact_url": "https://help.acme.com/contact", "support_email": "support@acme.com"}'
```

## Response

The [settings](/docs/api/admin/support-settings), with `mode`,
`external_contact_url` and `support_email` as they are now.

## Errors

| Status | Code                      | Meaning                                                                         |
| ------ | ------------------------- | ------------------------------------------------------------------------------- |
| 400    | `workspace_required`      | Asked by our own staff without naming a firm                                    |
| 401    | `invalid_token`           | Not a token, or the secret does not match                                       |
| 401    | `revoked_token`           | Signed out here or from another device                                          |
| 401    | `expired_token`           | Ninety days without use, or a set expiry passed                                 |
| 403    | `admin_access_required`   | This account no longer helps run the environment                                |
| 403    | `insufficient_scope`      | This device does not hold `admin:write`                                         |
| 403    | `workspace_not_permitted` | The `Propper-Workspace` header names an environment this account cannot act in |
| 403    | `forbidden`               | Without `manage_support_settings`, an assistant field without `manage_ai_settings`, or a mail switch without `manage_email`. Nothing is saved |
| 422    | `validation_failed`       | A value out of its range or not one of its values, `external` with an empty `external_contact_url`, or an address that is not `http` or `https`. Nothing is saved |