> For an agent: the map of this documentation is at https://escouade.io/en/mail/docs/llms.txt; every page exists in Markdown, at the same address with `.md` appended.

# Space settings

> A space's human adjusts it from their assistant, without writing to anyone: the sending window, mandatory approval, its access, its webhook, its closure. These gestures need the `approve` permission. An agent reads the settings; it does not change them. Whatever lasts or cannot be undone is reported to the human by e-mail.

## What can be adjusted

| Setting | Default | Bounds |
|---|---|---|
| Sending window | Monday to Friday, 9 am to 6 pm, Paris time. | Ranges of hours between 6 am and 10 pm, day by day. |
| Public holidays | Closed. | The eleven French public holidays. |
| Days without sending | None. | 60 dates at most. |
| Human approval | On request. | Mandatory for the whole space, or on request. |
| Spacing | 10 minutes between two sends from one inbox. | From 10 to 240 minutes. |
| Duplicates | 30 days. | From 30 to 365 days. |
| Space name, postal address | | The postal address is written in the footer of first messages. |

What cannot be adjusted: an inbox's daily quota and its warm-up. See [Sending rules](https://escouade.io/en/mail/docs/regles-envoi.md).

Access is managed with `list_keys`, `create_key` and `revoke_key`: see [Keys and permissions](https://escouade.io/en/mail/docs/cles.md). The space's webhook is declared with `set_webhook`: see [Webhooks](https://escouade.io/en/mail/docs/webhooks.md).

## `get_settings`

Reads the space's settings. Any key can call it. No parameters.

- `send_window` carries the window in plain words (`text`), the ranges from Monday to Friday (`weekdays`), for Saturday and Sunday, the seven days one by one (`days`, Monday first), `skip_holidays` and `no_send_days`.
- `webhook` carries the declared address. An access without `approve` only reads its host.
- `closure` carries the erasure date (`closes_at`) when the space's closure is confirmed; `null` otherwise.

## `update_settings`

Changes the space's settings. Only the ones given change. Permission: `approve`.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | text | no | The space's name, 2 to 80 characters. |
| `postal_address` | text | no | The sender's postal address, on one line, 200 characters at most. |
| `weekdays` | text | no | The ranges from Monday to Friday: `9-18`, or `8-12,14-18`. |
| `saturday` | text | no | Saturday's ranges, or `closed`. |
| `sunday` | text | no | Sunday's ranges, or `closed`. |
| `skip_holidays` | boolean | no | `true`: nothing leaves on French public holidays. |
| `no_send_days` | list | no | Days without sending, in the `YYYY-MM-DD` format. The list replaces the previous one. |
| `require_approval` | boolean | no | `true`: every send of the space stays a draft until it is approved. |
| `spacing_minutes` | integer | no | The minimum minutes between two sends from one inbox. |
| `dedup_days` | integer | no | The days during which an inbox does not write two first messages to the same recipient. |

- **What is queued leaves according to the new window.** A message that has already left does not change.
- Spacing and the duplicate rule can be tightened; they never go below the service's setting.
- A window with no open hour at all is refused: nothing would leave.
- Every change is written in the space's log, with its author.
- **Lifting mandatory approval alerts the human by e-mail**: the agents' sends leave again without review.
- The name and the postal address go out in the messages' footer: they cannot carry a key (code `secret_in_message`).
- A space opened by an Escouade Mail administrator keeps the settings they set for it: code `space_managed`.

## `close_space`

Closes the space and erases its data: inboxes, threads, messages, domains, access, block list. The plan's direct debit stops. The invoices are kept. Permission: `approve`.

| Parameter | Type | Required | Description |
|---|---|---|---|
| `confirmation_code` | text | no | The 6-digit code the space's human received by e-mail. |
| `cancel` | boolean | no | `true`: cancels the confirmed closure, and any pending code. |

Closure happens in three steps.

1. **Without a code**: the tool says what will be erased, and sends a 6-digit code to the space's human. Nothing is confirmed.
2. **With `confirmation_code`**: the closure is confirmed. The space will be erased 48 hours later; until then, everything works as before. The human receives an e-mail that gives the date, and says how to cancel.
3. **On the stated date**, the service erases the space: access stops answering, the inboxes are deleted from the mail server, the data is erased. The human receives one last e-mail.

- **With `cancel` = `true`, the closure is cancelled** as long as its date has not passed. Nothing has changed in the space.
- The code is valid for 15 minutes, for five attempts. Five codes at most in 24 hours.
- **The code is given by the space's human.** An assistant does not look for it itself, not even in an inbox it can read, and does not guess it. The 48-hour delay is there in case it did.
- The space's addresses on the shared domain are never given out again.
- A space opened by an Escouade Mail administrator cannot be closed this way: code `space_managed`.
- Possible refusals: `no_pending_code`, `invalid_code`, `code_expired`, `too_many_attempts`, `code_too_soon`, `code_limit`, `code_not_sent`, `no_human`, `billing_unavailable`, `space_managed`. See [Errors](https://escouade.io/en/mail/docs/erreurs.md#espace).
