# Quote, approve, execute, prove

Every letter goes through the same four steps, in the same order. Nothing skips one.

## Quote

[`quote_letter`](reference/quote_letter.md) reads the address, renders the pages, checks them, fixes the print file by its SHA-256 and prices it. Nothing is charged. The quote says what sending it would do now (`on_send`): go ahead, wait for a person, or be refused, and why. A quote lasts 24 hours.

`to` may be a list of up to 50 people: one quote then covers a letter for each, and sending it makes a group (`grp_…`) of ordinary letters that each take these four steps. See [One letter to several people](several-recipients.md).

To look before you quote, [`check_letter`](reference/check_letter.md) returns every page as it will print and a list of checks, each with the page and a fix. Pass its `check` id to `quote_letter` to quote those exact pages.

## Approve

[`send_letter`](reference/send_letter.md) commits the quote. The rule engine runs again, inside the same database transaction that holds the credits:

- **Goes ahead.** The letter is queued to print.
- **Waits for a person.** The answer is `needs_approval` with a link. The person sees the exact pages the quote fixed; an approval covers that hash and nothing else. See [Approvals](approvals.md).
- **Refused.** The answer says why, and nothing is held.

What decides it is the agent's rules (approval mode, limits, which classes and colour it may use), the workspace (stop all, live set-up), and our safeguards (a possible duplicate, a volume spike). The same function decides at quote and at send, so the quote's `on_send` is what will happen unless something changes in between.

## Execute

A queued letter goes into the day's print batch. Until it goes to print, [`cancel_letter`](reference/cancel_letter.md) stops it and returns the credits. After that it is too late: `too_late_to_cancel`.

The letter moves: `queued`, `printing`, `printed`, `posted`. Credits are held at send and charged when it is posted. If anything fails, the held credits come back.

## Prove

Once posted, the letter goes `on_record`: we write a record of what was sent, who said yes, every stage with its time, and the posting evidence, sign it, and chain it to the account's previous record. Anyone holding the record's link can check it. See [Verifying a record](verifying-a-record.md).

## Posting on a later day

Give `post_on`, a UK date such as `2026-12-01`, to `quote_letter` and we print and post the letter on that day instead of at the next cut-off. It must be a posting day (Monday to Friday, not a bank holiday in England, not a day the print room is away) from today (before the cut-off) up to 60 days ahead, with room left on that day. A day that will not do is refused `post_on_not_available`, with `details.why` and the nearest days that work either side; ask your person before picking another day. `get_account` gives the range (`post_on`).

The letter we lay out is dated its posting day, and the quote says when it can be cancelled (`cancel_until`, the cut-off on that day). `send_letter` answers `prints_later` with `details.why: "asked"`: the credits are held now and charged when it is posted, and the price is fixed at send. If a person must approve it, the approval lapses after 48 hours or at the cut-off on its day, whichever is first.

While it waits it is `queued`, as any letter waiting for its day is: `get_letter` says `scheduled: true`, with `post_on` (asked), `posts_on` (booked) and `cancel_until`. Cancel it until the cut-off on its day; to change the day, cancel and send again (a person can change it in the console). If we cannot post on the day (the print room is away, printing stopped) we move it to the next posting day and say so: `moved` on the letter and the `letter.posting_moved` webhook. If your side stops it on the day (sending stopped, the account suspended), it is held as `missed_posting_day` and never posted late by itself: a person picks a new day or cancels, and otherwise it lapses after 5 posting days and the credits come back. We never give an arrival day: `posts_on` is the day it leaves us.

## States

| Status                                      | Means                                                                                                                  |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `waiting_for_approval`                      | A person must approve it. Credits are held.                                                                            |
| `held`                                      | We are checking it, it waits for credit, or it missed its posting day. `waiting_reason` or the hold reason says which. |
| `queued`                                    | Approved, waiting for the print batch, or for the day asked (`scheduled: true`). It can be cancelled.                  |
| `printing`, `printed`                       | In the print room. It can no longer be cancelled.                                                                      |
| `posted`                                    | Posted. Credits are charged.                                                                                           |
| `on_record`                                 | The signed record is written.                                                                                          |
| `declined`, `lapsed`, `cancelled`, `failed` | Not sent. Held credits went back.                                                                                      |
| `returned`                                  | It came back to the return address.                                                                                    |

[`get_letter`](reference/get_letter.md) gives the status with a sentence to repeat, the timeline, and the record once there is one. A group has no status of its own: `get_letter` with its `grp_` reference gives the counts by status and one line for each letter, and `settled` once every letter is on record, declined, cancelled, failed or lapsed. Webhooks send each move as it happens: see [Webhook events](webhooks.md).
