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

# Check a letter: `check_letter`

Returns every page as it will print, the address as we read it, the price and a list of checks, each with a page and a fix. Takes the same input as quote_letter. Free, and makes no quote. Pass the check id to quote_letter as "check" and it quotes these exact pages. Blocking checks must be fixed before a quote; warnings go to the approver word for word. With a list in "to", it checks one recipient, picked by n, with their fields filled in.

| | |
|---|---|
| MCP tool | `check_letter` |
| REST | `POST /v1/letters/check` |
| CLI | `atomside check-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/letters/check \
  -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"
    }
  ]
}'
```

MCP:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "check_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"
        }
      ]
    }
  }
}
```

CLI:

```sh
atomside check-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"}]'
```

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

```json
{
  "check": "chk_example000000001",
  "n": null,
  "differ_only_in": [],
  "result": "ok",
  "sha256": "43341b592305c74063413681ae2bbd2106cd255d3829a72aada68d74272ca368",
  "pages": 1,
  "sheets": 1,
  "price": {
    "credits": 15,
    "gbp": "1.50"
  },
  "price_lines": [
    {
      "what": "Second class, first sheet",
      "price": {
        "credits": 15,
        "gbp": "1.50"
      }
    }
  ],
  "images": [
    "https://…signed link…"
  ],
  "guides": [],
  "parts": [
    {
      "from": "the text",
      "first_page": 1,
      "pages": 1
    }
  ],
  "text": [
    "# Rent review\n\nDear Ms Sample,\n\nYour rent stays the same for the coming year.\n\nYours sincerely,\nExample Lettings"
  ],
  "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."
  },
  "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
    }
  ],
  "summary": "0 blocking, 0 warnings, 8 passed",
  "says": "1 page on 1 sheet, both sides. 15 credits (£1.50) if quoted now. We charge by the sheet.",
  "expires": "2026-11-17T09:30:00.000Z",
  "next": "Call quote_letter with \"check\": \"chk_example000000001\" to quote these exact pages."
}
```

## 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": {
      "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."
        }
      ],
      "description": "One recipient, or the list you will quote. With a list, n picks the one to check."
    },
    "pages": {
      "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
          }
        ]
      },
      "description": "Parts print in this order. The first carries the address."
    },
    "class": {
      "default": "second",
      "description": "second or first. Signed-for, tracked and special delivery are not offered.",
      "type": "string",
      "enum": [
        "second",
        "first",
        "signed_for",
        "tracked",
        "special_delivery"
      ]
    },
    "colour": {
      "default": false,
      "description": "Colour adds 2 credits.",
      "type": "boolean"
    },
    "sides": {
      "default": "both",
      "description": "both puts two pages on a sheet. We charge by the sheet.",
      "type": "string",
      "enum": [
        "both",
        "one"
      ]
    },
    "n": {
      "description": "With a list: which recipient to check, from 1. Default 1.",
      "type": "integer",
      "minimum": 1,
      "maximum": 50
    },
    "images": {
      "default": true,
      "description": "False for text only: no page pictures.",
      "type": "boolean"
    },
    "guides": {
      "default": false,
      "description": "True for window, fold and margin overlays.",
      "type": "boolean"
    }
  },
  "required": [
    "to",
    "pages"
  ],
  "additionalProperties": false
}
```

## Output

```json
{
  "type": "object",
  "properties": {
    "check": {
      "type": "string",
      "description": "Pass to quote_letter as \"check\" to quote these exact pages, as one letter to this recipient."
    },
    "n": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991
        },
        {
          "type": "null"
        }
      ],
      "description": "With a list: the recipient these pages are for, from 1. Null for one recipient."
    },
    "differ_only_in": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "With a list: what differs from one letter to the next, \"address\" and the field names. Empty for one recipient."
    },
    "result": {
      "type": "string",
      "enum": [
        "ok",
        "warnings",
        "blocked"
      ]
    },
    "sha256": {
      "type": "string",
      "description": "The print file. A quote of this check prints exactly this."
    },
    "pages": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "sheets": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "price": {
      "anyOf": [
        {
          "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."
        },
        {
          "type": "null"
        }
      ],
      "description": "Null when over the sheet limit."
    },
    "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
      }
    },
    "images": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "One picture per page, as it will print."
    },
    "guides": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Window, folds and margins over each page. Never printed."
    },
    "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, and the pages it became."
    },
    "text": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The words on each page as we read them from the print file, for text-only agents."
    },
    "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
    },
    "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
      }
    },
    "summary": {
      "type": "string",
      "description": "\"1 blocking, 2 warnings, 10 passed\"."
    },
    "says": {
      "type": "string",
      "description": "A sentence to repeat to your person as it stands."
    },
    "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": [
    "check",
    "n",
    "differ_only_in",
    "result",
    "sha256",
    "pages",
    "sheets",
    "price",
    "price_lines",
    "images",
    "guides",
    "parts",
    "text",
    "address",
    "checks",
    "summary",
    "says",
    "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_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. |
| [`service_not_offered`](../refusals.md#service_not_offered) | no | never | 422 | Quote first or second class if that will do. If not, ask. |
| [`file_not_found`](../refusals.md#file_not_found) | no | after_fix | 404 | Upload the file again with upload_file, or call check_letter again. |
| [`file_not_usable`](../refusals.md#file_not_usable) | no | after_fix | 422 | details.problem says which page and what is wrong. |
| [`not_found`](../refusals.md#not_found) | no | after_fix | 404 | Check the name against the tool list or /v1/openapi.json. |
