<!-- Generated from the operation definitions by `pnpm docs:reference`. Do not edit by hand. -->

# Quote a letter: `quote_letter`

Checks the address and the pages, renders the proof, fixes the print file and returns the price in credits and pounds, the page and sheet count, and what will happen on send: goes ahead, waits for a person (and why), or refused (and why). Nothing is charged. Pass "check" from check_letter to quote those exact pages. A quote lasts 24 hours. reference, on_behalf_of, labels, reason and origin are yours and never printed.

| | |
|---|---|
| MCP tool | `quote_letter` |
| REST | `POST /v1/quotes` |
| CLI | `atomside quote-letter` |
| Key needs | Quote (`letters:quote`) |
| Changes anything | Yes. |
| Idempotency key | Not used. |

## Example

A real call and its real answer, made against the API in test mode. A test runs it again and fails if the answer changes. Ids, keys and links are replaced with stand-ins.

### A call that works

REST:

```sh
curl -X POST https://api.atomside.com/v1/quotes \
  -H "Authorization: Bearer $ATOMSIDE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": {
    "name": "Ms A. Sample",
    "line1": "12 Specimen Road",
    "town": "Exampleton",
    "postcode": "XX1 1XX"
  },
  "pages": [
    {
      "text": "# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings",
      "format": "markdown"
    }
  ],
  "reference": "rent-review-2026",
  "reason": "The annual rent review the tenancy agreement asks for."
}'
```

MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "quote_letter",
    "arguments": {
      "to": {
        "name": "Ms A. Sample",
        "line1": "12 Specimen Road",
        "town": "Exampleton",
        "postcode": "XX1 1XX"
      },
      "pages": [
        {
          "text": "# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings",
          "format": "markdown"
        }
      ],
      "reference": "rent-review-2026",
      "reason": "The annual rent review the tenancy agreement asks for."
    }
  }
}
```

CLI:

```sh
atomside quote-letter \
  --to '{"name":"Ms A. Sample","line1":"12 Specimen Road","town":"Exampleton","postcode":"XX1 1XX"}' \
  --pages '[{"text":"# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings","format":"markdown"}]' \
  --reference rent-review-2026 \
  --reason 'The annual rent review the tenancy agreement asks for.'
```

The answer (HTTP 200; over MCP, the same JSON is the result's `structuredContent`):

```json
{
  "quote": "qt_example000000001",
  "check": null,
  "test": true,
  "pages": 1,
  "sheets": 1,
  "class": "second",
  "colour": false,
  "sides": "both",
  "price": {
    "credits": 15,
    "gbp": "1.50"
  },
  "price_lines": [
    {
      "what": "Second class, first sheet",
      "price": {
        "credits": 15,
        "gbp": "1.50"
      }
    }
  ],
  "sha256": "43341b592305c74063413681ae2bbd2106cd255d3829a72aada68d74272ca368",
  "proof": "https://…signed link…",
  "images": [
    "https://…signed link…"
  ],
  "parts": [
    {
      "from": "the text",
      "first_page": 1,
      "pages": 1
    }
  ],
  "address": {
    "match": "found",
    "test": false,
    "prints_as": [
      "Ms A. Sample",
      "12 Specimen Road",
      "Exampleton",
      "XX1 1XX"
    ],
    "changes": [],
    "matches": [],
    "says": "It prints as Ms A. Sample, 12 Specimen Road, Exampleton, XX1 1XX."
  },
  "sender": {
    "name": "Example Lettings Ltd",
    "of": "workspace",
    "verified": true
  },
  "checks": [
    {
      "n": 1,
      "code": "address_found",
      "level": "passed",
      "page": 1,
      "area_mm": null,
      "says": "Found, as sent.",
      "fix": null
    },
    {
      "n": 2,
      "code": "address_in_window",
      "level": "passed",
      "page": null,
      "area_mm": [
        25,
        61,
        52.3,
        15.6
      ],
      "says": "All of it, clear of the folds.",
      "fix": null
    },
    {
      "n": 3,
      "code": "window_clear",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "Nothing else shows in the window.",
      "fix": null
    },
    {
      "n": 4,
      "code": "text_in_margin",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "Nothing in the unprintable edge.",
      "fix": null
    },
    {
      "n": 5,
      "code": "blank_page",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "No blank pages.",
      "fix": null
    },
    {
      "n": 6,
      "code": "fonts",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "None swapped.",
      "fix": null
    },
    {
      "n": 7,
      "code": "placeholder_left",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "No placeholders left.",
      "fix": null
    },
    {
      "n": 8,
      "code": "sheet_limit",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "1 sheet of 5.",
      "fix": null
    }
  ],
  "on_send": "goes_ahead",
  "on_send_reason": null,
  "on_send_says": "1 page on 1 sheet, both sides. 15 credits (£1.50) if quoted now. We charge by the sheet. It goes ahead when you send it.",
  "posting": {
    "posts_on": "2026-11-16",
    "cutoff_at": "2026-11-16T16:00:00.000Z",
    "says": "Sent now, it is posted on Mon 16 Nov."
  },
  "post_on": null,
  "cancel_until": null,
  "post_on_range": {
    "earliest": "2026-11-16",
    "latest": "2027-01-15"
  },
  "expires": "2026-11-17T09:30:00.000Z",
  "next": "Call send_letter with this quote and an idempotency key."
}
```

### A refusal: `address_not_found`

REST:

```sh
curl -X POST https://api.atomside.com/v1/quotes \
  -H "Authorization: Bearer $ATOMSIDE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": {
    "name": "Ms A. Sample",
    "line1": "1 Any Street",
    "town": "Exampleton",
    "postcode": "TEST 04"
  },
  "pages": [
    {
      "text": "# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings",
      "format": "markdown"
    }
  ]
}'
```

MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "quote_letter",
    "arguments": {
      "to": {
        "name": "Ms A. Sample",
        "line1": "1 Any Street",
        "town": "Exampleton",
        "postcode": "TEST 04"
      },
      "pages": [
        {
          "text": "# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings",
          "format": "markdown"
        }
      ]
    }
  }
}
```

CLI:

```sh
atomside quote-letter \
  --to '{"name":"Ms A. Sample","line1":"1 Any Street","town":"Exampleton","postcode":"TEST 04"}' \
  --pages '[{"text":"# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings","format":"markdown"}]'
```

The answer (HTTP 422; over MCP, the same JSON is the result's `structuredContent`):

```json
{
  "answer": "no",
  "code": "address_not_found",
  "fixed_by": "agent",
  "say": "We could not match 1 Any Street, Exampleton, TEST 04 to a UK address.",
  "money": {
    "charged": {
      "credits": 0,
      "gbp": "0.00"
    },
    "held": {
      "credits": 0,
      "gbp": "0.00"
    },
    "returned": {
      "credits": 0,
      "gbp": "0.00"
    },
    "say": "Nothing was charged."
  },
  "retry": "after_fix",
  "retry_after": null,
  "agent_can": [],
  "person": null,
  "quote": null,
  "letter": null,
  "details": {
    "address": "1 Any Street, Exampleton, TEST 04",
    "matches": [
      "12 Test Road, Testville, TEST 04",
      "14 Test Road, Testville, TEST 04"
    ]
  },
  "docs": "https://api.atomside.com/docs/refusals/address_not_found",
  "request_id": "req_example000000001"
}
```

### One letter to several people, one of them left out

REST:

```sh
curl -X POST https://api.atomside.com/v1/quotes \
  -H "Authorization: Bearer $ATOMSIDE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "to": [
    {
      "name": "Ms A. Sample",
      "line1": "12 Specimen Road",
      "town": "Exampleton",
      "postcode": "XX1 1XX",
      "fields": {
        "salutation": "Ms Sample",
        "new_rent": "£925"
      }
    },
    {
      "name": "Mr B. Specimen",
      "line1": "14 Specimen Road",
      "town": "Exampleton",
      "postcode": "XX1 1XX",
      "fields": {
        "salutation": "Mr Specimen",
        "new_rent": "£1,040"
      }
    },
    {
      "name": "Ms C. Example",
      "line1": "Flat 1",
      "line2": "2 Example Street",
      "postcode": "XX2 2XX",
      "fields": {
        "salutation": "Ms Example",
        "new_rent": "£860"
      }
    },
    {
      "name": "Mr D. Example",
      "line1": "3 Specimin Close",
      "postcode": "TEST 04",
      "fields": {
        "salutation": "Mr Example",
        "new_rent": "£990"
      }
    }
  ],
  "pages": [
    {
      "text": "# Rent review\n\nDear {salutation},\n\nFrom 1 January 2027 your rent will be {new_rent} a month.\n\nYours sincerely,\nExample Lettings",
      "format": "markdown"
    }
  ],
  "purpose": "Rent review notice to current tenants",
  "reference": "Rent review 2027"
}'
```

MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "quote_letter",
    "arguments": {
      "to": [
        {
          "name": "Ms A. Sample",
          "line1": "12 Specimen Road",
          "town": "Exampleton",
          "postcode": "XX1 1XX",
          "fields": {
            "salutation": "Ms Sample",
            "new_rent": "£925"
          }
        },
        {
          "name": "Mr B. Specimen",
          "line1": "14 Specimen Road",
          "town": "Exampleton",
          "postcode": "XX1 1XX",
          "fields": {
            "salutation": "Mr Specimen",
            "new_rent": "£1,040"
          }
        },
        {
          "name": "Ms C. Example",
          "line1": "Flat 1",
          "line2": "2 Example Street",
          "postcode": "XX2 2XX",
          "fields": {
            "salutation": "Ms Example",
            "new_rent": "£860"
          }
        },
        {
          "name": "Mr D. Example",
          "line1": "3 Specimin Close",
          "postcode": "TEST 04",
          "fields": {
            "salutation": "Mr Example",
            "new_rent": "£990"
          }
        }
      ],
      "pages": [
        {
          "text": "# Rent review\n\nDear {salutation},\n\nFrom 1 January 2027 your rent will be {new_rent} a month.\n\nYours sincerely,\nExample Lettings",
          "format": "markdown"
        }
      ],
      "purpose": "Rent review notice to current tenants",
      "reference": "Rent review 2027"
    }
  }
}
```

CLI:

```sh
atomside quote-letter \
  --to '[{"name":"Ms A. Sample","line1":"12 Specimen Road","town":"Exampleton","postcode":"XX1 1XX","fields":{"salutation":"Ms Sample","new_rent":"£925"}},{"name":"Mr B. Specimen","line1":"14 Specimen Road","town":"Exampleton","postcode":"XX1 1XX","fields":{"salutation":"Mr Specimen","new_rent":"£1,040"}},{"name":"Ms C. Example","line1":"Flat 1","line2":"2 Example Street","postcode":"XX2 2XX","fields":{"salutation":"Ms Example","new_rent":"£860"}},{"name":"Mr D. Example","line1":"3 Specimin Close","postcode":"TEST 04","fields":{"salutation":"Mr Example","new_rent":"£990"}}]' \
  --pages '[{"text":"# Rent review\n\nDear {salutation},\n\nFrom 1 January 2027 your rent will be {new_rent} a month.\n\nYours sincerely,\nExample Lettings","format":"markdown"}]' \
  --purpose 'Rent review notice to current tenants' \
  --reference 'Rent review 2027'
```

The answer (HTTP 200; over MCP, the same JSON is the result's `structuredContent`):

```json
{
  "quote": "qt_example000000004",
  "test": true,
  "letters": 3,
  "left_out": 1,
  "sheets": 3,
  "price": {
    "credits": 45,
    "gbp": "4.50"
  },
  "price_lines": [
    {
      "what": "3 letters on 1 sheet, 15 credits each",
      "price": {
        "credits": 45,
        "gbp": "4.50"
      }
    }
  ],
  "each": [
    {
      "n": 1,
      "to": "Ms A. Sample, XX1 1XX",
      "ready": true,
      "quote": "qt_example000000005",
      "pages": 1,
      "sheets": 1,
      "credits": 15,
      "proof": "https://…signed link…",
      "images": [
        "https://…signed link…"
      ],
      "sha256": "a60d2e7597ef325b136bc309b7bb23fcd990b0e04fb9a3b7b4238cb3eb9ca043",
      "fields": {
        "salutation": "Ms Sample",
        "new_rent": "£925"
      },
      "code": null,
      "say": null,
      "agent_can": [],
      "details": {}
    },
    {
      "n": 2,
      "to": "Mr B. Specimen, XX1 1XX",
      "ready": true,
      "quote": "qt_example000000006",
      "pages": 1,
      "sheets": 1,
      "credits": 15,
      "proof": "https://…signed link…",
      "images": [
        "https://…signed link…"
      ],
      "sha256": "ecf288e32aee972ceb013b7c7b8fca44253656a307adb38df1b28a1a87b7264c",
      "fields": {
        "salutation": "Mr Specimen",
        "new_rent": "£1,040"
      },
      "code": null,
      "say": null,
      "agent_can": [],
      "details": {}
    },
    {
      "n": 3,
      "to": "Ms C. Example, XX2 2XX",
      "ready": true,
      "quote": "qt_example000000007",
      "pages": 1,
      "sheets": 1,
      "credits": 15,
      "proof": "https://…signed link…",
      "images": [
        "https://…signed link…"
      ],
      "sha256": "4835dd8af5a6d1dd44dc7c64920b39e77844da19804dbb020b4e4c5985f5ae86",
      "fields": {
        "salutation": "Ms Example",
        "new_rent": "£860"
      },
      "code": null,
      "say": null,
      "agent_can": [],
      "details": {}
    },
    {
      "n": 4,
      "to": "Mr D. Example, TEST 04",
      "ready": false,
      "quote": null,
      "pages": null,
      "sheets": null,
      "credits": null,
      "proof": null,
      "images": [],
      "sha256": null,
      "fields": {
        "salutation": "Mr Example",
        "new_rent": "£990"
      },
      "code": "address_not_found",
      "say": "We could not match 3 Specimin Close, TEST 04 to a UK address.",
      "agent_can": [
        {
          "do": "Use 12 Test Road, Testville, TEST 04, if it is clearly the same place.",
          "tool": "quote_letter",
          "with": null,
          "changes_wording": false,
          "changes_day": false
        },
        {
          "do": "Use 14 Test Road, Testville, TEST 04, if it is clearly the same place.",
          "tool": "quote_letter",
          "with": null,
          "changes_wording": false,
          "changes_day": false
        }
      ],
      "details": {
        "address": "3 Specimin Close, TEST 04",
        "matches": [
          "12 Test Road, Testville, TEST 04",
          "14 Test Road, Testville, TEST 04"
        ]
      }
    }
  ],
  "differ_only_in": [
    "address",
    "salutation",
    "new_rent"
  ],
  "fields": [
    "salutation",
    "new_rent"
  ],
  "purpose": "Rent review notice to current tenants",
  "class": "second",
  "colour": false,
  "sides": "both",
  "checks": [
    {
      "n": 1,
      "code": "address_found",
      "level": "passed",
      "page": 1,
      "area_mm": null,
      "says": "Found, as sent.",
      "fix": null
    },
    {
      "n": 2,
      "code": "address_in_window",
      "level": "passed",
      "page": null,
      "area_mm": [
        25,
        61,
        52.3,
        15.6
      ],
      "says": "All of it, clear of the folds.",
      "fix": null
    },
    {
      "n": 3,
      "code": "window_clear",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "Nothing else shows in the window.",
      "fix": null
    },
    {
      "n": 4,
      "code": "text_in_margin",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "Nothing in the unprintable edge.",
      "fix": null
    },
    {
      "n": 5,
      "code": "blank_page",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "No blank pages.",
      "fix": null
    },
    {
      "n": 6,
      "code": "fonts",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "None swapped.",
      "fix": null
    },
    {
      "n": 7,
      "code": "placeholder_left",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "No placeholders left.",
      "fix": null
    },
    {
      "n": 8,
      "code": "sheet_limit",
      "level": "passed",
      "page": null,
      "area_mm": null,
      "says": "1 sheet of 5.",
      "fix": null
    }
  ],
  "sender": {
    "name": "Example Lettings Ltd",
    "of": "workspace",
    "verified": true
  },
  "on_send": "goes_ahead",
  "on_send_reason": null,
  "on_send_says": "3 letters, 3 sheets in all, 45 credits (£4.50) if sent now. 1 recipient is left out: each[] says why. It goes ahead when you send it.",
  "posting": {
    "posts_on": "2026-11-16",
    "cutoff_at": "2026-11-16T16:00:00.000Z",
    "says": "Sent now, they are posted on Mon 16 Nov."
  },
  "expires": "2026-11-17T09:30:00.000Z",
  "next": "Call send_letter with this quote and one idempotency key. It sends 3 letters; to send to everyone, fix the entries left out and quote again."
}
```

## Input

Over REST, fields in the path go in the path, GET fields in the query string, and POST fields in the JSON body. Over MCP, every field is an argument of the tool.

```json
{
  "type": "object",
  "properties": {
    "to": {
      "description": "One recipient, or a list of up to 50: one letter each, from one quote and one send. Leave out when you pass check.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100,
              "description": "As it should print, e.g. \"Ms A. Sample\"."
            },
            "line1": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "line2": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "line3": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "town": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "postcode": {
              "type": "string",
              "minLength": 2,
              "maxLength": 10
            },
            "country": {
              "description": "Leave out for the UK. We post to UK addresses only.",
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "fields": {
              "description": "Values for the {names} in your text pages. Never printed elsewhere.",
              "type": "object",
              "propertyNames": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,39}$"
              },
              "additionalProperties": {
                "type": "string",
                "maxLength": 200,
                "pattern": "^[^\\r\\n{}]*$"
              }
            },
            "repeat_of": {
              "description": "An earlier letter this person should get again on purpose. A person still decides.",
              "type": "string",
              "minLength": 1,
              "maxLength": 40
            },
            "repeat_reason": {
              "description": "Why they get it again. Shown to the person who decides.",
              "type": "string",
              "minLength": 1,
              "maxLength": 500
            }
          },
          "required": [
            "name",
            "line1",
            "postcode"
          ],
          "additionalProperties": false
        },
        {
          "minItems": 1,
          "maxItems": 1000,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100,
                "description": "As it should print, e.g. \"Ms A. Sample\"."
              },
              "line1": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "line2": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "line3": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100
              },
              "town": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "postcode": {
                "type": "string",
                "minLength": 2,
                "maxLength": 10
              },
              "country": {
                "description": "Leave out for the UK. We post to UK addresses only.",
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "fields": {
                "description": "Values for the {names} in your text pages. Never printed elsewhere.",
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9_]{0,39}$"
                },
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 200,
                  "pattern": "^[^\\r\\n{}]*$"
                }
              },
              "repeat_of": {
                "description": "An earlier letter this person should get again on purpose. A person still decides.",
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              "repeat_reason": {
                "description": "Why they get it again. Shown to the person who decides.",
                "type": "string",
                "minLength": 1,
                "maxLength": 500
              }
            },
            "required": [
              "name",
              "line1",
              "postcode"
            ],
            "additionalProperties": false
          },
          "description": "Up to 50 recipients: one letter each."
        }
      ]
    },
    "pages": {
      "description": "Leave out when you pass check.",
      "minItems": 1,
      "maxItems": 10,
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100000,
                "description": "The letter, written in the call. We lay it out."
              },
              "format": {
                "default": "text",
                "type": "string",
                "enum": [
                  "text",
                  "markdown",
                  "html"
                ]
              }
            },
            "required": [
              "text"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "file": {
                "type": "string",
                "description": "An id from upload_file."
              },
              "pages": {
                "description": "PDF only: which of its pages go in, in this order, e.g. \"2-3\" or \"1,4\". Leave out for every page.",
                "type": "string",
                "pattern": "^\\s*\\d{1,3}(\\s*-\\s*\\d{1,3})?(\\s*,\\s*\\d{1,3}(\\s*-\\s*\\d{1,3})?){0,19}\\s*$"
              }
            },
            "required": [
              "file"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "file_url": {
                "type": "string",
                "format": "uri",
                "description": "An https link we fetch once, at quote time."
              }
            },
            "required": [
              "file_url"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "check": {
      "description": "A check id from check_letter: quote those exact pages.",
      "type": "string"
    },
    "class": {
      "description": "second (default) or first.",
      "type": "string",
      "enum": [
        "second",
        "first",
        "signed_for",
        "tracked",
        "special_delivery"
      ]
    },
    "colour": {
      "description": "Colour adds 2 credits. Default false.",
      "type": "boolean"
    },
    "sides": {
      "description": "Default both. We charge by the sheet.",
      "type": "string",
      "enum": [
        "both",
        "one"
      ]
    },
    "reference": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "on_behalf_of": {
      "type": "object",
      "properties": {
        "ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100,
          "pattern": "^[^@\\s]+$",
          "description": "Your own id for the customer. Never printed."
        },
        "name": {
          "description": "A label. Never printed.",
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      },
      "required": [
        "ref"
      ],
      "additionalProperties": false
    },
    "labels": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 50
      }
    },
    "reason": {
      "description": "Why you send it. Shown to the approver, marked as your words.",
      "type": "string",
      "minLength": 1,
      "maxLength": 500
    },
    "origin": {
      "type": "object",
      "properties": {
        "run": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "url": {
          "type": "string",
          "maxLength": 500,
          "format": "uri"
        },
        "software": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "model": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "asked_by": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        }
      },
      "additionalProperties": false
    },
    "post_on": {
      "description": "A later posting day, YYYY-MM-DD, read as a UK day: we print and post it that day. A posting day (Monday to Friday, not a bank holiday) up to 60 days ahead. Leave out to go at the next cut-off. The letter is dated that day. Never an arrival day. For one recipient only.",
      "type": "string",
      "format": "date",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
    },
    "purpose": {
      "description": "Needed from 2 recipients: one plain sentence on what the send is for. Never printed. Shown to the person who approves and to our checker.",
      "type": "string",
      "minLength": 1,
      "maxLength": 300
    },
    "all_or_none": {
      "description": "With a list: refuse the quote if anyone would be left out, instead of quoting the rest.",
      "type": "boolean"
    }
  },
  "additionalProperties": false
}
```

## Output

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "quote": {
          "type": "string"
        },
        "check": {
          "description": "The check these pages came from, if any.",
          "type": [
            "string",
            "null"
          ]
        },
        "test": {
          "type": "boolean",
          "description": "True in test mode: this quote can never print."
        },
        "pages": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "sheets": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        "class": {
          "type": "string",
          "enum": [
            "second",
            "first"
          ]
        },
        "colour": {
          "type": "boolean"
        },
        "sides": {
          "type": "string",
          "enum": [
            "both",
            "one"
          ]
        },
        "price": {
          "type": "object",
          "properties": {
            "credits": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Whole credits. 1 credit is 10p."
            },
            "gbp": {
              "type": "string",
              "pattern": "^-?\\d+\\.\\d{2}$",
              "description": "The same amount in pounds, ex VAT, as a decimal string."
            }
          },
          "required": [
            "credits",
            "gbp"
          ],
          "additionalProperties": false,
          "description": "The total. Nothing is charged until send_letter."
        },
        "price_lines": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "what": {
                "type": "string"
              },
              "price": {
                "type": "object",
                "properties": {
                  "credits": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991,
                    "description": "Whole credits. 1 credit is 10p."
                  },
                  "gbp": {
                    "type": "string",
                    "pattern": "^-?\\d+\\.\\d{2}$",
                    "description": "The same amount in pounds, ex VAT, as a decimal string."
                  }
                },
                "required": [
                  "credits",
                  "gbp"
                ],
                "additionalProperties": false,
                "description": "An amount in credits, with pounds beside it."
              }
            },
            "required": [
              "what",
              "price"
            ],
            "additionalProperties": false
          }
        },
        "sha256": {
          "type": "string",
          "description": "The print file this quote fixes. An approval covers this hash."
        },
        "proof": {
          "type": "string",
          "description": "The print file, as it will print."
        },
        "images": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "parts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "from": {
                "type": "string",
                "description": "\"the text\", a file id, or a link."
              },
              "first_page": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991,
                "description": "The page of the letter it starts on."
              },
              "pages": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "from",
              "first_page",
              "pages"
            ],
            "additionalProperties": false
          },
          "description": "Each part of pages, in order: where it came from and the pages it became."
        },
        "address": {
          "type": "object",
          "properties": {
            "match": {
              "type": "string",
              "enum": [
                "found",
                "not_found"
              ]
            },
            "test": {
              "type": "boolean",
              "description": "True for a TEST postcode: nothing is looked up."
            },
            "prints_as": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "changes": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "What we changed from what you sent."
            },
            "matches": {
              "type": "array",
              "items": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "description": "Close matches when it is not found."
            },
            "says": {
              "type": "string",
              "description": "A sentence to repeat to your person as it stands."
            }
          },
          "required": [
            "match",
            "test",
            "prints_as",
            "changes",
            "matches",
            "says"
          ],
          "additionalProperties": false
        },
        "sender": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "of": {
                  "type": "string",
                  "enum": [
                    "workspace",
                    "customer"
                  ]
                },
                "verified": {
                  "type": "boolean"
                }
              },
              "required": [
                "name",
                "of",
                "verified"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ],
          "description": "The sender printed on the letter. Null in test mode before a sender is set."
        },
        "checks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "n": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "code": {
                "type": "string"
              },
              "level": {
                "type": "string",
                "enum": [
                  "blocking",
                  "warning",
                  "passed"
                ]
              },
              "page": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "area_mm": {
                "default": null,
                "description": "Where on the page it looked or found the problem, in millimetres from the page's top-left corner: x, y, width, height. Null when the check is about the whole letter.",
                "anyOf": [
                  {
                    "type": "array",
                    "prefixItems": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "items": false,
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "says": {
                "type": "string"
              },
              "fix": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "n",
              "code",
              "level",
              "page",
              "area_mm",
              "says",
              "fix"
            ],
            "additionalProperties": false
          },
          "description": "Warnings travel to the approver word for word."
        },
        "on_send": {
          "type": "string",
          "enum": [
            "goes_ahead",
            "waits_for_approval",
            "refused"
          ],
          "description": "What send_letter would do now. Same words as get_account."
        },
        "on_send_reason": {
          "description": "Why, as a code: over_daily_limit, new_address, waiting_for_credit…",
          "type": [
            "string",
            "null"
          ]
        },
        "on_send_says": {
          "type": "string",
          "description": "A sentence to repeat to your person as it stands."
        },
        "posting": {
          "type": "object",
          "properties": {
            "posts_on": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The UK date it will be posted."
            },
            "cutoff_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "says": {
              "type": "string",
              "description": "A sentence to repeat to your person as it stands."
            }
          },
          "required": [
            "posts_on",
            "cutoff_at",
            "says"
          ],
          "additionalProperties": false
        },
        "post_on": {
          "anyOf": [
            {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            },
            {
              "type": "null"
            }
          ],
          "description": "The posting day asked for, or null for the next cut-off. The letter is dated that day."
        },
        "cancel_until": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
            },
            {
              "type": "null"
            }
          ],
          "description": "With post_on: once sent, it can be cancelled until this cut-off on its posting day."
        },
        "post_on_range": {
          "type": "object",
          "properties": {
            "earliest": {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            },
            "latest": {
              "type": "string",
              "format": "date",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
            }
          },
          "required": [
            "earliest",
            "latest"
          ],
          "additionalProperties": false,
          "description": "The first and last posting days post_on can be now. Days we do not post between them are refused."
        },
        "expires": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
        },
        "next": {
          "type": "string"
        }
      },
      "required": [
        "quote",
        "check",
        "test",
        "pages",
        "sheets",
        "class",
        "colour",
        "sides",
        "price",
        "price_lines",
        "sha256",
        "proof",
        "images",
        "parts",
        "address",
        "sender",
        "checks",
        "on_send",
        "on_send_reason",
        "on_send_says",
        "posting",
        "post_on",
        "cancel_until",
        "post_on_range",
        "expires",
        "next"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "quote": {
          "type": "string",
          "description": "The group quote. Send it with send_letter and one idempotency key."
        },
        "test": {
          "type": "boolean",
          "description": "True in test mode: this quote can never print."
        },
        "letters": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Letters in the quote: the recipients that are ready."
        },
        "left_out": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Recipients left out: each[] says why, and how to fix it."
        },
        "sheets": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "description": "Sheets in all."
        },
        "price": {
          "type": "object",
          "properties": {
            "credits": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991,
              "description": "Whole credits. 1 credit is 10p."
            },
            "gbp": {
              "type": "string",
              "pattern": "^-?\\d+\\.\\d{2}$",
              "description": "The same amount in pounds, ex VAT, as a decimal string."
            }
          },
          "required": [
            "credits",
            "gbp"
          ],
          "additionalProperties": false,
          "description": "The total: each letter priced by its own sheets. Nothing is charged yet."
        },
        "price_lines": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "what": {
                "type": "string"
              },
              "price": {
                "type": "object",
                "properties": {
                  "credits": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991,
                    "description": "Whole credits. 1 credit is 10p."
                  },
                  "gbp": {
                    "type": "string",
                    "pattern": "^-?\\d+\\.\\d{2}$",
                    "description": "The same amount in pounds, ex VAT, as a decimal string."
                  }
                },
                "required": [
                  "credits",
                  "gbp"
                ],
                "additionalProperties": false,
                "description": "An amount in credits, with pounds beside it."
              }
            },
            "required": [
              "what",
              "price"
            ],
            "additionalProperties": false
          }
        },
        "each": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "n": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991,
                "description": "Its place in your list, from 1."
              },
              "to": {
                "type": "string",
                "description": "\"Ms A. Sample, XX1 1XX\"."
              },
              "ready": {
                "type": "boolean",
                "description": "True when this recipient is in the quote."
              },
              "quote": {
                "description": "This letter of the group, for its page pictures. Never sent on its own.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "pages": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "sheets": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "credits": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "proof": {
                "description": "The print file, as it will print.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "images": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "sha256": {
                "description": "The print file this letter fixes.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "fields": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                },
                "description": "The values this letter was filled with."
              },
              "code": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "address_not_found",
                      "address_not_uk",
                      "address_on_do_not_write",
                      "test_postcode_in_live",
                      "possible_duplicate",
                      "too_many_sheets",
                      "file_not_usable",
                      "over_per_letter_limit",
                      "over_recipient_limit",
                      "outside_agent_rules",
                      "field_not_filled",
                      "merged"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Why it is left out, as a refusal code."
              },
              "say": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "agent_can": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "do": {
                      "type": "string"
                    },
                    "tool": {
                      "type": "string"
                    },
                    "with": {
                      "anyOf": [
                        {
                          "type": "object",
                          "propertyNames": {
                            "type": "string"
                          },
                          "additionalProperties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "changes_wording": {
                      "type": "boolean"
                    },
                    "changes_day": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "do",
                    "tool",
                    "with",
                    "changes_wording",
                    "changes_day"
                  ],
                  "additionalProperties": false
                }
              },
              "details": {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              }
            },
            "required": [
              "n",
              "to",
              "ready",
              "quote",
              "pages",
              "sheets",
              "credits",
              "proof",
              "images",
              "sha256",
              "fields",
              "code",
              "say",
              "agent_can",
              "details"
            ],
            "additionalProperties": false
          },
          "description": "One line for each recipient, in your order."
        },
        "differ_only_in": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "What differs between the letters: the address and the fields."
        },
        "fields": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The fields the letter uses."
        },
        "purpose": {
          "type": "string"
        },
        "class": {
          "type": "string",
          "enum": [
            "second",
            "first"
          ]
        },
        "colour": {
          "type": "boolean"
        },
        "sides": {
          "type": "string",
          "enum": [
            "both",
            "one"
          ]
        },
        "checks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "n": {
                "type": "integer",
                "minimum": -9007199254740991,
                "maximum": 9007199254740991
              },
              "code": {
                "type": "string"
              },
              "level": {
                "type": "string",
                "enum": [
                  "blocking",
                  "warning",
                  "passed"
                ]
              },
              "page": {
                "anyOf": [
                  {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "area_mm": {
                "default": null,
                "description": "Where on the page it looked or found the problem, in millimetres from the page's top-left corner: x, y, width, height. Null when the check is about the whole letter.",
                "anyOf": [
                  {
                    "type": "array",
                    "prefixItems": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "items": false,
                    "minItems": 4,
                    "maxItems": 4
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "says": {
                "type": "string"
              },
              "fix": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "n",
              "code",
              "level",
              "page",
              "area_mm",
              "says",
              "fix"
            ],
            "additionalProperties": false
          },
          "description": "The checks on the first letter. Warnings travel to the approver."
        },
        "sender": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "of": {
                  "type": "string",
                  "enum": [
                    "workspace",
                    "customer"
                  ]
                },
                "verified": {
                  "type": "boolean"
                }
              },
              "required": [
                "name",
                "of",
                "verified"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ],
          "description": "The sender printed on the letter. Null in test mode before a sender is set."
        },
        "on_send": {
          "type": "string",
          "enum": [
            "goes_ahead",
            "waits_for_approval",
            "refused"
          ],
          "description": "What send_letter would do now, for the whole group."
        },
        "on_send_reason": {
          "type": [
            "string",
            "null"
          ]
        },
        "on_send_says": {
          "type": "string",
          "description": "A sentence to repeat to your person as it stands."
        },
        "posting": {
          "type": "object",
          "properties": {
            "posts_on": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "The UK date it will be posted."
            },
            "cutoff_at": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
                },
                {
                  "type": "null"
                }
              ]
            },
            "says": {
              "type": "string",
              "description": "A sentence to repeat to your person as it stands."
            }
          },
          "required": [
            "posts_on",
            "cutoff_at",
            "says"
          ],
          "additionalProperties": false
        },
        "expires": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
        },
        "next": {
          "type": "string"
        }
      },
      "required": [
        "quote",
        "test",
        "letters",
        "left_out",
        "sheets",
        "price",
        "price_lines",
        "each",
        "differ_only_in",
        "fields",
        "purpose",
        "class",
        "colour",
        "sides",
        "checks",
        "sender",
        "on_send",
        "on_send_reason",
        "on_send_says",
        "posting",
        "expires",
        "next"
      ],
      "additionalProperties": false
    }
  ]
}
```

## Refusals

Every refusal has the same shape. Branch on `code`, `answer` and `retry`; repeat `say` to your person.

| Code | Answer | Retry | HTTP | What to do next |
|---|---|---|---|---|
| [`key_missing`](../refusals.md#key_missing) | no | after_fix | 401 | Send the key as "Authorization: Bearer as_test_…". Ask your person if you have none. |
| [`key_not_valid`](../refusals.md#key_not_valid) | no | never | 401 | Ask your person for a new key. There is no link: we cannot say whose it was. |
| [`scope_missing`](../refusals.md#scope_missing) | no | after_person | 403 | Ask your person to give the key that permission. |
| [`invalid_request`](../refusals.md#invalid_request) | no | after_fix | 400 | Fix the field named in details.field. The same idempotency key is fine. |
| [`rate_limited`](../refusals.md#rate_limited) | no | at_time | 429 | Wait. The same idempotency key never sends twice. |
| [`try_again_shortly`](../refusals.md#try_again_shortly) | no | at_time | 503 | Try again after retry_after with the same idempotency key. |
| [`account_expired`](../refusals.md#account_expired) | no | never | 401 | Start again with start_account if your person still wants this. |
| [`connection_ended`](../refusals.md#connection_ended) | no | after_person | 401 | Tell your person. To carry on, they connect Atomside again in your assistant. |
| [`too_many_recipients`](../refusals.md#too_many_recipients) | no | after_fix | 400 | Split it into sends of details.limit or fewer, each with its own idempotency key. If the agent setting is the limit, ask your person to raise it. |
| [`field_not_filled`](../refusals.md#field_not_filled) | no | after_fix | 400 | Add the value, or take the field out of the letter, then quote again. Nothing is charged. |
| [`address_not_found`](../refusals.md#address_not_found) | no | after_fix | 422 | Use one of details.matches only if it is clearly the same place. |
| [`address_not_uk`](../refusals.md#address_not_uk) | no | never | 422 | Tell your person. We cannot post this letter. |
| [`address_on_do_not_write`](../refusals.md#address_on_do_not_write) | no | after_person | 403 | Tell your person. Only they can take it off the list. |
| [`test_postcode_in_live`](../refusals.md#test_postcode_in_live) | no | after_fix | 422 | Use the real address. Rehearse outcomes with a test key. |
| [`too_many_sheets`](../refusals.md#too_many_sheets) | no | after_fix | 422 | If it is printed on one side, quote again on both sides. Otherwise ask your person before cutting pages. |
| [`file_not_usable`](../refusals.md#file_not_usable) | no | after_fix | 422 | details.problem says which page and what is wrong. |
| [`file_not_found`](../refusals.md#file_not_found) | no | after_fix | 404 | Upload the file again with upload_file, or call check_letter again. |
| [`service_not_offered`](../refusals.md#service_not_offered) | no | never | 422 | Quote first or second class if that will do. If not, ask. |
| [`on_behalf_of_required`](../refusals.md#on_behalf_of_required) | no | after_fix | 422 | Quote again with on_behalf_of.ref set to your own id for the customer. |
| [`origin_required`](../refusals.md#origin_required) | no | after_fix | 422 | Quote again with origin: the run, the software and who asked. |
| [`customer_paused`](../refusals.md#customer_paused) | no | after_person | 403 | Do not retry. Tell your person; only they can resume this customer. |
| [`customer_suspended`](../refusals.md#customer_suspended) | no | after_person | 403 | Do not retry. Tell the person you are working for. |
| [`customer_closed`](../refusals.md#customer_closed) | no | never | 409 | Do not retry. Make a new customer with a new ref if your person wants to write again. |
| [`customer_limit_reached`](../refusals.md#customer_limit_reached) | no | after_person | 403 | Do not retry now. Send letters for the customers you have; get_account shows when the limit is lifted. |
| [`test_customer_in_live`](../refusals.md#test_customer_in_live) | no | after_fix | 422 | Use a test key, or a ref that does not start cust_test_. |
| [`customer_ref_not_valid`](../refusals.md#customer_ref_not_valid) | no | after_fix | 422 | Use your own id for the customer, not an email, name or postcode. |
| [`customer_ref_not_allowed`](../refusals.md#customer_ref_not_allowed) | no | after_person | 403 | Check the reference. If it is new and right, ask your person to allow it. |
| [`post_on_not_available`](../refusals.md#post_on_not_available) | no | after_fix | 422 | Ask your person before you pick another day: details.day_before and details.day_after are the nearest days that work (changes_day). Leave post_on out to go at the next cut-off. For differs_from_quote, quote again with the new day. |
| [`not_found`](../refusals.md#not_found) | no | after_fix | 404 | Check the name against the tool list or /v1/openapi.json. |
