# One letter to several people

There is no new tool. `to` in [`quote_letter`](reference/quote_letter.md) takes a list of up to 50 recipients. One quote, one send, one idempotency key. What comes back is a **group**: a handle on that many ordinary letters, each with its own reference, proof, hash, record and price. It is the same over MCP, REST and the CLI.

A group (`grp_…`) is not a letter. It has counts, but no status, record or hash of its own.

## Before you start

[`get_account`](reference/get_account.md) has a `groups` block:

| Field                              | Means                                                                                                     |
| ---------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `max_recipients`                   | The most people one send of yours may go to: 1, 10 or 50. A new agent starts at 1; your person raises it. |
| `same_letter_addresses_left_today` | How many more addresses the same letter can go to today before a person is asked.                         |
| `asks_above`                       | The same letter to more than 10 addresses in a day always asks a person, autopilot included.              |
| `atomside_reads_above`             | A live group over 20 is read by Atomside before it prints. So is each account's first group.              |
| `new_account_max`                  | While we check a new live account's first letters, one send takes up to 5. Null otherwise.                |
| `print_room_today.room`            | Letters the next print run can still take. A group prints together. Null in test mode.                    |

## 1. Quote

```json
{
  "to": [
    {
      "name": "Ms A. Sample",
      "line1": "12 Specimen Road",
      "postcode": "XX1 1XX",
      "fields": { "salutation": "Ms Sample", "new_rent": "£925" }
    },
    {
      "name": "Mr B. Specimen",
      "line1": "14 Specimen Road",
      "postcode": "XX1 1XX",
      "fields": { "salutation": "Mr Specimen", "new_rent": "£1,040" }
    }
  ],
  "pages": [
    { "text": "Dear {salutation},\n\nFrom 1 January 2027 your rent will be {new_rent} a month." }
  ],
  "purpose": "Rent review notice to current tenants",
  "reference": "Rent review 2027"
}
```

- `to` with one recipient, as an object or a list of one, is the single letter you know. No group is made.
- `purpose` is needed from 2 recipients: one plain sentence on what the send is for. It is never printed. The person who approves and our checker see it.
- `fields` fill the `{names}` in `text` pages. Files print the same for everyone. A name is letters, digits and `_`; a value is one line, up to 200 characters, with no curly brackets. Up to 10 fields. Print options and `reference` apply to every letter.
- Agents send the list as JSON. In the CLI: `atomside quote-letter --to @list.json --pages @pages.json --purpose "…"`.

The quote has one line for each recipient in `each`, with its own proof, pages, sheets, price and hash, and `differ_only_in`: what changes from one letter to the next. Each letter is priced on its own sheets; the total is the sum. Nothing is charged.

### How long a quote takes

We check every address and render every letter before we answer, so a quote for a list is slow: allow about a second and a half for each recipient. A list of 50 can take more than a minute.

- **REST:** let your HTTP client wait at least 2 minutes for `POST /v1/quotes`. Nothing on our side cuts the answer off sooner.
- **MCP:** many clients stop waiting after 60 seconds. Ask for progress (a `progressToken` in the call's `_meta`) and, while a quote is still being made, we send a progress notification every 15 seconds, so a client that resets its timeout on progress keeps waiting. If your client cannot, quote in lists of 25 or fewer.
- **CLI:** it waits up to 5 minutes.

A quote that was cut off made nothing you pay for. Quote again.

### When someone is left out

A problem with one person leaves that person out, and the rest are quoted. Their line in `each` says `"ready": false` with a `code`, a `say` and what you can do (`agent_can`). `letters` and `left_out` count both sides, and `next` says so in words. Sending the quote sends the ones that are ready. To send everyone, fix the entry and quote again. Pass `"all_or_none": true` to get a "no" instead of a quote with anyone left out.

| Code                                                             | Covers                        | What to do                                                                                      |
| ---------------------------------------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------- |
| `too_many_recipients`                                            | The whole call                | Split it into sends of `details.limit` or fewer, each with its own key, or ask your person.     |
| `field_not_filled`                                               | The whole call, or one person | Add the value, or take the field out of the letter. A gap is never printed.                     |
| `address_not_found`, `address_not_uk`, `address_on_do_not_write` | One person                    | As for a single letter, on that line.                                                           |
| `possible_duplicate`                                             | One person                    | Left out. If they should get it again, add `repeat_of` and `repeat_reason` to their entry.      |
| `too_many_sheets`, `over_per_letter_limit`                       | One person                    | Each letter is measured on its own.                                                             |
| `merged`                                                         | One person                    | The same person twice in one list is sent one letter. Two names at one address are two letters. |

To look at one person's letter before you quote, [`check_letter`](reference/check_letter.md) takes the same list and `n` (from 1): it returns that recipient's pages with their fields filled in, and `differ_only_in`.

## 2. Send

[`send_letter`](reference/send_letter.md) with the quote and one idempotency key makes the group and all its letters together, or none of them. When nothing holds it, the answer is the group, every letter with its status, and the credits held.

Otherwise the answer is the refusal shape you know, for the whole group, with `details.group`, `details.count` and `details.letters`:

| Code                 | Means                                                                                                                                                                   |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `needs_approval`     | The letters wait for a person. One approval, which may cover only some. The same letter to more than 10 addresses in a day always asks (`reason: same_letter_to_many`). |
| `held_for_check`     | We read this send before it prints. Do not resend.                                                                                                                      |
| `waiting_for_credit` | There is not enough credit for all of them. A group is never sent in part for lack of credit.                                                                           |
| `prints_later`       | Today's print run is full. The whole group prints together on the next working day.                                                                                     |
| `over_daily_limit`   | The group's total is over a limit. A "no" on autopilot, a wait in the ask modes. `details.fits` says how many would fit.                                                |

A group never pauses your agent. A burst of single letters still can.

## 3. Look

Four tools take a `grp_` reference where they take a letter:

| Tool                                                  | With a group                                                                                                                                |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| [`get_letter`](reference/get_letter.md)               | Counts by status, `settled`, one line for each letter (status, the cancel cut-off, a decline note, its money) and the totals.               |
| [`list_letters`](reference/list_letters.md)           | `group` lists one group's letters. Every letter carries `group` and `n`, its place in your list.                                            |
| [`cancel_letter`](reference/cancel_letter.md)         | Cancels every letter that has not reached the print cut-off, and lists each one it could not, with why. Credits come back letter by letter. |
| [`wait_for_approval`](reference/wait_for_approval.md) | Returns once the person decides: how many were approved, and each declined letter with its note.                                            |

`settled` turns true when every letter is on record, declined, cancelled, failed or lapsed. Report the counts, then the exceptions by name. A letter's own `ltr_` reference works as always, and names its group.

## Retries, and never twice

- **One key for the send.** A retry with the same key returns the same group and the same letters. Nothing new is made, however far the first call got. Each letter's record counts the retry.
- **All made, or none.** A send that fails part way leaves nothing behind, so the retry is safe.
- **The same key with a different quote** is `idempotency_key_reused`.
- **A quote is used once.** Sending it again under a new key is `quote_already_used`. A fresh quote for the same people is caught by the duplicate check, person by person.

## Webhooks

There are no new events for letters. Each `letter.*` event carries `group` and `n`. One new event, `group.settled`, comes once with the final counts, so you can wait for one event, not twelve. See [Webhook events](webhooks.md).

## In test mode

Groups work in test mode from the start: the same checks and refusals, up to 50 recipients, nothing posted, nothing charged. The TEST postcodes work on each line of a list. See [Test mode](test-mode.md).
