# Response and data model

The same result object is returned by the REST API (`format=json`), by the hosted MCP tool `convert_statement` (as `structuredContent`) and by the local MCP server.

## Result

| Field | Type | Meaning |
| --- | --- | --- |
| `id` | string or null | Identifier of the stored result. `null` unless you asked for storage. |
| `filename` | string | Name of the input file. `statement.pdf` when unknown. |
| `pages` | integer | Pages in the PDF. This is what the call cost. |
| `currency` | string or null | ISO 4217 code found in the statement text (for example `EUR`). `null` when the statement only shows an ambiguous symbol such as `$`, or no currency at all. |
| `balance_check` | object | See below. |
| `warnings` | array of strings | Conditions that reduce confidence. See below. |
| `transactions` | array | In the order they appear in the statement. |

## Transaction

| Field | Type | Meaning |
| --- | --- | --- |
| `date` | string | ISO date, `YYYY-MM-DD`. The posting or transaction date printed first on the row. |
| `description` | string | The row's text without the date and amounts. Continuation lines are appended, separated by a space. |
| `amount` | number | Signed, two decimals at most. Negative: money left the account. Positive: money came in. |
| `balance` | number or null | The running balance printed on that row. `null` when the statement has no balance column. |

### Sign convention

The sign always describes the account holder's point of view.

- Bank account: a card payment, withdrawal or fee is negative. A salary or deposit is positive.
- Credit card: a purchase is negative. A payment to the card or a refund is positive. This holds even though card statements usually print purchases as positive numbers.

How the sign is determined, in order of reliability:

1. Separate columns (debit and credit, withdrawals and deposits, paid out and paid in), identified from the column headers.
2. An explicit sign or marker on the amount: a minus sign, brackets, `CR` or `DR`.
3. The running balance: if the balance went down by the amount, it was money out.
4. Conventions: on a statement where most amounts are unsigned and a few are negative, it is read as a credit card (see the `card-convention` warning).

If none of these apply, signs cannot be known. Amounts are then returned as negative and the `unsigned-amounts` warning is set.

## balance_check

```json
"balance_check": { "checkable": 41, "reconciled": 41 }
```

| Field | Meaning |
| --- | --- |
| `checkable` | Number of rows that have a printed balance and a previous balance to compare with. |
| `reconciled` | Number of those rows where previous balance + amount = printed balance, to the cent. |

How to read it:

- `reconciled == checkable` and `checkable > 0`: every checked row is arithmetically consistent with the statement. This is strong evidence that amounts, signs and row order are right. It does not prove dates or descriptions.
- `reconciled < checkable`: `checkable - reconciled` rows do not add up. Common causes: a row was missed, a multi-line row was split, or the statement contains several accounts (the balance jumps where one account ends and the next begins, which costs exactly one row per boundary).
- `checkable == 0`: the statement prints no running balance, so nothing could be verified. The result may still be right, but it is unverified.

## warnings

| Value | Meaning | What to do |
| --- | --- | --- |
| `year-inferred` | Dates on the statement have no year (for example `12 Jan`). The year was taken from the most frequent year in the statement text, or the current year if none was found. | Confirm the year. Statements that span December and January get the same year on both sides. |
| `unsigned-amounts` | No columns, signs or balance tell money in from money out. All amounts were returned as negative. | Do not trust the signs. Ask the user, or classify rows yourself from the descriptions and say so. |
| `card-convention` | Read as a credit card statement: unsigned charges became negative, and payments or credits became positive. | Usually correct. Mention that it was treated as a card statement. |

## Things the result does not contain

- Account numbers, account holder names, statement period, opening and closing balances. Opening balance lines are used for the balance check and then dropped.
- Categories, merchants or counterparties as separate fields. The description is the raw text.
- Per-row confidence. Use `balance_check` and `warnings`.
- Totals and summary lines printed on the statement. They are filtered out on purpose.

## Several accounts in one PDF

All rows are returned in one list, in document order. There is no account field. Expect one failed balance check at each account boundary.
