{
  "openapi": "3.1.0",
  "info": {
    "title": "StatementBear bank statement parsing API",
    "version": "1",
    "summary": "Send a bank or credit card statement, get back its accounts, transactions, checks and authenticity signals as JSON.",
    "description": "Send a PDF, a scan, a photo or a CSV, OFX or QIF export to `POST /documents` and get back every transaction, the account it belongs to, a check that the figures reconcile and signs that the file was edited.\n\nAuthenticate every request with `Authorization: Bearer sb_live_...`, or `sb_test_...` for a fixture that reads nothing and is never billed. A key sees only documents and collections of its own mode. Every response carries `Cache-Control: no-store`. A method a path does not support returns `405 method_not_allowed` with an `Allow` header.\n\nPricing: $0.08 a page of a document that reads successfully, $0.05 a page past 50,000 in a calendar month. The first 200 pages are free. Errors and failed reads are free. `X-Billable-Pages` on every response carrying a document says what it was billed.\n\nLimits: 50MB a file, 60 pages synchronously or 500 with `async=true`, 4 synchronous reads in flight per account, 120 test requests a minute.\n\nWithin v1 fields and error codes may be added, never removed or changed in meaning. Parse leniently and ignore what you do not recognise.",
    "termsOfService": "https://statementbear.com/terms",
    "contact": {
      "name": "StatementBear support",
      "email": "support@statementbear.com",
      "url": "https://statementbear.com/docs"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://statementbear.com/terms"
    },
    "x-logo": {
      "url": "https://statementbear.com/brand/statementbear-icon.png",
      "altText": "StatementBear"
    }
  },
  "externalDocs": {
    "description": "Documentation",
    "url": "https://statementbear.com/docs"
  },
  "servers": [
    {
      "url": "https://statementbear.com/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Documents",
      "description": "Send a statement and fetch what was read.",
      "externalDocs": {
        "url": "https://statementbear.com/docs/api/documents"
      }
    },
    {
      "name": "Collections",
      "description": "Hosted upload links for applicants.",
      "externalDocs": {
        "url": "https://statementbear.com/docs/api/collections"
      }
    },
    {
      "name": "Webhooks",
      "description": "Events posted to your endpoints. Add endpoints in the console.",
      "externalDocs": {
        "url": "https://statementbear.com/docs/webhooks"
      }
    }
  ],
  "paths": {
    "/documents": {
      "post": {
        "operationId": "createDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Send a document",
        "description": "Reads one bank or credit card statement and returns it as a document. Up to 50MB. Up to 60 pages synchronously, or 500 with `async`. Send the file as a raw body with its own `Content-Type`, or as a multipart part named `file`. The file type is read from the file's own bytes. Send a `Content-Length` header: without one the request returns `411 length_required`. Set a client timeout of at least 180 seconds, or send with `async=true`.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/documents#send-a-document"
        },
        "parameters": [
          {
            "name": "async",
            "in": "query",
            "description": "`true` answers `202` at once; the result arrives by webhook or `GET /documents/{id}`. A multipart `async` part does the same.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "`json` returns a document. `csv` returns the rows as CSV, `qbo` a QuickBooks Web Connect file, `ofx` an OFX 1.02 file and `qif` a QIF file, each holding every account with signed amounts. Synchronous only. Errors are JSON in every format.",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv",
                "ofx",
                "qbo",
                "qif"
              ],
              "default": "json"
            }
          },
          {
            "name": "metadata",
            "in": "query",
            "description": "A JSON object of strings, URL-encoded, for a raw body. A multipart `metadata` part takes precedence.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "One unique string per document, reused by every retry. A repeat within 24 hours returns the first request's document and is not billed again.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Filename",
            "in": "header",
            "description": "The file's name, for a raw body. Comes back as `filename`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Test-Scenario",
            "in": "header",
            "description": "Test keys only. Picks which fixture or error comes back. A live key returns `400 test_scenario_on_live_key`.\n\n- `bank` (`200`): A single current account, reconciled. The default when no header is sent.\n- `credit_card` (`200`): A card statement. Its credits are the repayment and a refund, so it is what to test your income filter against.\n- `multi_account` (`200`): A checking and a savings account on one document, with a transfer printed on both sides.\n- `unreconciled` (`200`): A document whose figures did not reconcile. Exercises your manual review path.\n- `suspicious` (`200`): An unreconciled document with `authenticity.risk` `high`: edited in a PDF editor, modified after creation, balances that do not follow. Exercises your fraud review path.\n- `not_a_bank_statement` (`422`): The file was readable and is not a statement.\n- `password_required` (`422`): The PDF is password-protected and no password was sent.\n- `incorrect_password` (`422`): The password sent does not open the PDF.\n- `parse_failed` (`500`): Our error. Retry it.\n- `free_pages_exhausted` (`402`): The free pages are spent and no payment method is on file.\n- `not_enough_free_pages` (`402`): Some free pages are left, fewer than the file has, and no payment method is on file.\n- `monthly_cap_reached` (`402`): The file would pass the monthly page cap.\n- `canceled` (`402`): Billing for the account was cancelled.\n- `too_many_concurrent_requests` (`429`): Too many documents in flight. Exercises your backoff.\n- `file_too_large` (`413`): Over the size limit, without uploading 50MB to find out.",
            "schema": {
              "type": "string",
              "enum": [
                "bank",
                "credit_card",
                "multi_account",
                "unreconciled",
                "not_a_bank_statement",
                "password_required",
                "incorrect_password",
                "parse_failed",
                "suspicious",
                "free_pages_exhausted",
                "not_enough_free_pages",
                "monthly_cap_reached",
                "canceled",
                "too_many_concurrent_requests",
                "file_too_large"
              ],
              "default": "bank"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The statement."
                  },
                  "password": {
                    "type": "string",
                    "description": "The password of a protected PDF. Opens that one file and is not kept."
                  },
                  "metadata": {
                    "type": "string",
                    "description": "A JSON object of strings, echoed back on the document and its webhooks."
                  },
                  "async": {
                    "type": "boolean",
                    "description": "`true` to answer `202` at once."
                  }
                }
              },
              "encoding": {
                "file": {
                  "contentType": "application/pdf, image/jpeg, image/png, text/csv, application/x-ofx, application/qif, text/plain, application/octet-stream"
                }
              }
            },
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/jpeg": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "image/png": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "text/csv": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/x-ofx": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/qif": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "text/plain": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The document, with `status: \"succeeded\"`, or the file `format` asked for. A replayed async document can be `failed`. Billed by its pages unless `livemode` is false.",
            "headers": {
              "X-Billable-Pages": {
                "$ref": "#/components/headers/X-Billable-Pages"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              },
              "X-Document-Id": {
                "$ref": "#/components/headers/X-Document-Id"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                },
                "examples": {
                  "read": {
                    "summary": "A read document (live key)",
                    "value": {
                      "id": "doc_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "status": "succeeded",
                      "error": null,
                      "filename": "monzo-march-2026.pdf",
                      "pages": 3,
                      "metadata": {
                        "applicationId": "app_8841"
                      },
                      "collection": null,
                      "livemode": true,
                      "created": 1785372094,
                      "issuer": {
                        "name": "Monzo",
                        "domain": "monzo.com"
                      },
                      "currency": "GBP",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4412",
                          "name": null,
                          "currency": "GBP",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "totals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "statedTotals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "openingBalance": 1204.11,
                          "closingBalance": 1602.56,
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 3240,
                              "debits": 2841.55
                            }
                          ],
                          "transactions": [
                            {
                              "date": "2026-03-04",
                              "description": "TESCO STORES 3412",
                              "payee": "Tesco",
                              "amount": 42.1,
                              "direction": "debit",
                              "category": "groceries"
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": true,
                        "issues": []
                      },
                      "recurring": [
                        {
                          "payee": "Spotify",
                          "category": "subscriptions",
                          "amount": 11.99,
                          "cadence": "monthly",
                          "occurrences": 1,
                          "lastDate": "2026-03-12",
                          "account": 0
                        }
                      ],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Monzo Statements",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 3,
                        "billablePages": 3
                      }
                    }
                  },
                  "test_bank": {
                    "summary": "Test key, X-Test-Scenario: bank",
                    "value": {
                      "id": "doc_test_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "livemode": false,
                      "created": 1775121240,
                      "issuer": {
                        "name": "Monzo",
                        "domain": "monzo.com"
                      },
                      "currency": "GBP",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4412",
                          "name": null,
                          "currency": "GBP",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "statedTotals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "openingBalance": 1204.11,
                          "closingBalance": 1602.56,
                          "transactions": [
                            {
                              "date": "2026-03-01",
                              "description": "RENT - GARDNER LETTINGS",
                              "payee": "Gardner Lettings",
                              "amount": 1450,
                              "direction": "debit",
                              "category": "housing"
                            },
                            {
                              "date": "2026-03-02",
                              "description": "THAMES WATER LTD",
                              "payee": "Thames Water",
                              "amount": 38.2,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-03",
                              "description": "TFL TRAVEL CHARGE",
                              "payee": "TfL",
                              "amount": 27.4,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-04",
                              "description": "TESCO STORES 3412",
                              "payee": "Tesco",
                              "amount": 42.1,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-06",
                              "description": "SAINSBURYS SMKTS CD 4412",
                              "payee": "Sainsbury's",
                              "amount": 61.85,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-09",
                              "description": "BRITISH GAS",
                              "payee": "British Gas",
                              "amount": 94,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-11",
                              "description": "ACME LTD SALARY MAR",
                              "payee": "Acme Ltd",
                              "amount": 3200,
                              "direction": "credit",
                              "category": "income"
                            },
                            {
                              "date": "2026-03-12",
                              "description": "SPOTIFY UK",
                              "payee": "Spotify",
                              "amount": 11.99,
                              "direction": "debit",
                              "category": "subscriptions"
                            },
                            {
                              "date": "2026-03-15",
                              "description": "AMEX PAYMENT REF 8842",
                              "payee": null,
                              "amount": 620,
                              "direction": "debit",
                              "category": "card_repayment"
                            },
                            {
                              "date": "2026-03-18",
                              "description": "ASDA SUPERSTORE 2210",
                              "payee": "Asda",
                              "amount": 78.42,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-20",
                              "description": "PRET A MANGER 114",
                              "payee": "Pret A Manger",
                              "amount": 8.65,
                              "direction": "debit",
                              "category": "dining"
                            },
                            {
                              "date": "2026-03-21",
                              "description": "ARGOS RETAIL REFUND",
                              "payee": "Argos",
                              "amount": 40,
                              "direction": "credit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-22",
                              "description": "SHELL MOTORWAY M4",
                              "payee": "Shell",
                              "amount": 62.14,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-24",
                              "description": "EE LIMITED",
                              "payee": "EE",
                              "amount": 26,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-25",
                              "description": "ARGOS RETAIL 1180",
                              "payee": "Argos",
                              "amount": 135,
                              "direction": "debit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-27",
                              "description": "ODEON CINEMAS LTD",
                              "payee": "Odeon",
                              "amount": 21.5,
                              "direction": "debit",
                              "category": "entertainment"
                            },
                            {
                              "date": "2026-03-29",
                              "description": "UBER *TRIP HELP.UBER",
                              "payee": "Uber",
                              "amount": 14.3,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-30",
                              "description": "JOHN LEWIS PLC",
                              "payee": "John Lewis",
                              "amount": 150,
                              "direction": "debit",
                              "category": "shopping"
                            }
                          ],
                          "totals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 3240,
                              "debits": 2841.55
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": true,
                        "issues": []
                      },
                      "status": "succeeded",
                      "error": null,
                      "filename": null,
                      "pages": 3,
                      "metadata": {},
                      "collection": null,
                      "recurring": [
                        {
                          "payee": "Spotify",
                          "category": "subscriptions",
                          "amount": 11.99,
                          "cadence": "monthly",
                          "occurrences": 1,
                          "lastDate": "2026-03-12",
                          "account": 0
                        }
                      ],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Monzo Statements",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 3,
                        "billablePages": 0
                      }
                    }
                  },
                  "test_credit_card": {
                    "summary": "Test key, X-Test-Scenario: credit_card",
                    "value": {
                      "id": "doc_test_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "livemode": false,
                      "created": 1775121240,
                      "issuer": {
                        "name": "Chase",
                        "domain": "chase.com"
                      },
                      "currency": "USD",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "credit_card",
                          "last4": "8842",
                          "name": null,
                          "currency": "USD",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "statedTotals": {
                            "credits": 644.99,
                            "debits": 1102.55
                          },
                          "openingBalance": 812.44,
                          "closingBalance": 1270,
                          "transactions": [
                            {
                              "date": "2026-03-02",
                              "description": "AMAZON MKTPLACE PMTS",
                              "payee": "Amazon",
                              "amount": 129.99,
                              "direction": "debit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-05",
                              "description": "SHELL OIL 574123",
                              "payee": "Shell",
                              "amount": 58.2,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-07",
                              "description": "WHOLE FOODS MKT 10241",
                              "payee": "Whole Foods",
                              "amount": 143.86,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-09",
                              "description": "PAYMENT THANK YOU - WEB",
                              "payee": null,
                              "amount": 620,
                              "direction": "credit",
                              "category": "card_repayment"
                            },
                            {
                              "date": "2026-03-11",
                              "description": "DELTA AIR LINES 0062",
                              "payee": "Delta",
                              "amount": 412.3,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-14",
                              "description": "NETFLIX.COM",
                              "payee": "Netflix",
                              "amount": 22.99,
                              "direction": "debit",
                              "category": "subscriptions"
                            },
                            {
                              "date": "2026-03-16",
                              "description": "CVS/PHARMACY #4412",
                              "payee": "CVS",
                              "amount": 36.41,
                              "direction": "debit",
                              "category": "health"
                            },
                            {
                              "date": "2026-03-17",
                              "description": "AMAZON MKTPLACE REFUND",
                              "payee": "Amazon",
                              "amount": 24.99,
                              "direction": "credit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-19",
                              "description": "STARBUCKS STORE 00118",
                              "payee": "Starbucks",
                              "amount": 9.75,
                              "direction": "debit",
                              "category": "dining"
                            },
                            {
                              "date": "2026-03-23",
                              "description": "THE HOME DEPOT #6612",
                              "payee": "The Home Depot",
                              "amount": 214.05,
                              "direction": "debit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-28",
                              "description": "UBER EATS",
                              "payee": "Uber Eats",
                              "amount": 41.6,
                              "direction": "debit",
                              "category": "dining"
                            },
                            {
                              "date": "2026-03-30",
                              "description": "APPLE.COM/BILL",
                              "payee": "Apple",
                              "amount": 33.4,
                              "direction": "debit",
                              "category": "subscriptions"
                            }
                          ],
                          "totals": {
                            "credits": 644.99,
                            "debits": 1102.55
                          },
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 644.99,
                              "debits": 1102.55
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": true,
                        "issues": []
                      },
                      "status": "succeeded",
                      "error": null,
                      "filename": null,
                      "pages": 4,
                      "metadata": {},
                      "collection": null,
                      "recurring": [],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Chase Statement Production",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 4,
                        "billablePages": 0
                      }
                    }
                  },
                  "test_multi_account": {
                    "summary": "Test key, X-Test-Scenario: multi_account",
                    "value": {
                      "id": "doc_test_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "livemode": false,
                      "created": 1775121240,
                      "issuer": {
                        "name": "Capital One",
                        "domain": "capitalone.com"
                      },
                      "currency": "USD",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4410",
                          "name": null,
                          "currency": "USD",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "statedTotals": {
                            "credits": 4120,
                            "debits": 3855.12
                          },
                          "openingBalance": 2410.88,
                          "closingBalance": 2675.76,
                          "transactions": [
                            {
                              "date": "2026-03-01",
                              "description": "MORTGAGE PMT NATIONSTAR",
                              "payee": "Nationstar",
                              "amount": 1980,
                              "direction": "debit",
                              "category": "housing"
                            },
                            {
                              "date": "2026-03-03",
                              "description": "PAYROLL ACME CORP",
                              "payee": "Acme Corp",
                              "amount": 4000,
                              "direction": "credit",
                              "category": "income"
                            },
                            {
                              "date": "2026-03-05",
                              "description": "TRANSFER TO SAVINGS 8821",
                              "payee": null,
                              "amount": 500,
                              "direction": "debit",
                              "category": "internal_transfer"
                            },
                            {
                              "date": "2026-03-08",
                              "description": "CAPITAL ONE CRD PMT",
                              "payee": null,
                              "amount": 620,
                              "direction": "debit",
                              "category": "card_repayment"
                            },
                            {
                              "date": "2026-03-12",
                              "description": "KROGER #442",
                              "payee": "Kroger",
                              "amount": 186.22,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-14",
                              "description": "COMCAST CABLE COMM",
                              "payee": "Comcast",
                              "amount": 89.99,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-17",
                              "description": "ZELLE FROM J MILLER",
                              "payee": "J Miller",
                              "amount": 120,
                              "direction": "credit",
                              "category": "other"
                            },
                            {
                              "date": "2026-03-19",
                              "description": "GEICO AUTO INS",
                              "payee": "GEICO",
                              "amount": 142.1,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-23",
                              "description": "SHELL SERVICE STATION",
                              "payee": "Shell",
                              "amount": 61.4,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-27",
                              "description": "TARGET T-1129",
                              "payee": "Target",
                              "amount": 275.41,
                              "direction": "debit",
                              "category": "shopping"
                            }
                          ],
                          "totals": {
                            "credits": 4120,
                            "debits": 3855.12
                          },
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 4120,
                              "debits": 3855.12
                            }
                          ]
                        },
                        {
                          "type": "bank",
                          "last4": "8821",
                          "name": "360 Performance Savings",
                          "currency": "USD",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": false,
                          "statedTotals": null,
                          "openingBalance": null,
                          "closingBalance": null,
                          "transactions": [
                            {
                              "date": "2026-03-05",
                              "description": "TRANSFER FROM CHECKING 4410",
                              "payee": null,
                              "amount": 500,
                              "direction": "credit",
                              "category": "internal_transfer"
                            },
                            {
                              "date": "2026-03-31",
                              "description": "INTEREST PAID",
                              "payee": null,
                              "amount": 1.42,
                              "direction": "credit",
                              "category": "income"
                            }
                          ],
                          "totals": {
                            "credits": 501.42,
                            "debits": 0
                          },
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 501.42,
                              "debits": 0
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": true,
                        "issues": []
                      },
                      "status": "succeeded",
                      "error": null,
                      "filename": null,
                      "pages": 5,
                      "metadata": {},
                      "collection": null,
                      "recurring": [],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Capital One eStatements",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 5,
                        "billablePages": 0
                      }
                    }
                  },
                  "test_unreconciled": {
                    "summary": "Test key, X-Test-Scenario: unreconciled",
                    "value": {
                      "id": "doc_test_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "livemode": false,
                      "created": 1775121240,
                      "issuer": {
                        "name": "Monzo",
                        "domain": "monzo.com"
                      },
                      "currency": "GBP",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4412",
                          "name": null,
                          "currency": "GBP",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "statedTotals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "openingBalance": 1204.11,
                          "closingBalance": 1602.56,
                          "transactions": [
                            {
                              "date": "2026-03-01",
                              "description": "RENT - GARDNER LETTINGS",
                              "payee": "Gardner Lettings",
                              "amount": 1450,
                              "direction": "debit",
                              "category": "housing"
                            },
                            {
                              "date": "2026-03-02",
                              "description": "THAMES WATER LTD",
                              "payee": "Thames Water",
                              "amount": 38.2,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-03",
                              "description": "TFL TRAVEL CHARGE",
                              "payee": "TfL",
                              "amount": 27.4,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-04",
                              "description": "TESCO STORES 3412",
                              "payee": "Tesco",
                              "amount": 42.1,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-06",
                              "description": "SAINSBURYS SMKTS CD 4412",
                              "payee": "Sainsbury's",
                              "amount": 61.85,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-09",
                              "description": "BRITISH GAS",
                              "payee": "British Gas",
                              "amount": 94,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-11",
                              "description": "ACME LTD SALARY MAR",
                              "payee": "Acme Ltd",
                              "amount": 3200,
                              "direction": "credit",
                              "category": "income"
                            },
                            {
                              "date": "2026-03-12",
                              "description": "SPOTIFY UK",
                              "payee": "Spotify",
                              "amount": 11.99,
                              "direction": "debit",
                              "category": "subscriptions"
                            },
                            {
                              "date": "2026-03-15",
                              "description": "AMEX PAYMENT REF 8842",
                              "payee": null,
                              "amount": 620,
                              "direction": "debit",
                              "category": "card_repayment"
                            },
                            {
                              "date": "2026-03-18",
                              "description": "ASDA SUPERSTORE 2210",
                              "payee": "Asda",
                              "amount": 78.42,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-20",
                              "description": "PRET A MANGER 114",
                              "payee": "Pret A Manger",
                              "amount": 8.65,
                              "direction": "debit",
                              "category": "dining"
                            },
                            {
                              "date": "2026-03-21",
                              "description": "ARGOS RETAIL REFUND",
                              "payee": "Argos",
                              "amount": 40,
                              "direction": "credit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-22",
                              "description": "SHELL MOTORWAY M4",
                              "payee": "Shell",
                              "amount": 62.14,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-24",
                              "description": "EE LIMITED",
                              "payee": "EE",
                              "amount": 26,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-25",
                              "description": "ARGOS RETAIL 1180",
                              "payee": "Argos",
                              "amount": 135,
                              "direction": "debit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-27",
                              "description": "ODEON CINEMAS LTD",
                              "payee": "Odeon",
                              "amount": 21.5,
                              "direction": "debit",
                              "category": "entertainment"
                            },
                            {
                              "date": "2026-03-29",
                              "description": "UBER *TRIP HELP.UBER",
                              "payee": "Uber",
                              "amount": 14.3,
                              "direction": "debit",
                              "category": "transport"
                            }
                          ],
                          "totals": {
                            "credits": 3240,
                            "debits": 2691.55
                          },
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 3240,
                              "debits": 2691.55
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": false,
                        "issues": [
                          "Closing balance 1602.56 does not follow from opening balance 1204.11 and the rows returned (difference 150.00)."
                        ]
                      },
                      "status": "succeeded",
                      "error": null,
                      "filename": null,
                      "pages": 3,
                      "metadata": {},
                      "collection": null,
                      "recurring": [
                        {
                          "payee": "Spotify",
                          "category": "subscriptions",
                          "amount": 11.99,
                          "cadence": "monthly",
                          "occurrences": 1,
                          "lastDate": "2026-03-12",
                          "account": 0
                        }
                      ],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Monzo Statements",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 3,
                        "billablePages": 0
                      }
                    }
                  },
                  "test_suspicious": {
                    "summary": "Test key, X-Test-Scenario: suspicious",
                    "value": {
                      "id": "doc_test_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "livemode": false,
                      "created": 1775121240,
                      "issuer": {
                        "name": "Monzo",
                        "domain": "monzo.com"
                      },
                      "currency": "GBP",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4412",
                          "name": null,
                          "currency": "GBP",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "statedTotals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "openingBalance": 1204.11,
                          "closingBalance": 1602.56,
                          "transactions": [
                            {
                              "date": "2026-03-01",
                              "description": "RENT - GARDNER LETTINGS",
                              "payee": "Gardner Lettings",
                              "amount": 1450,
                              "direction": "debit",
                              "category": "housing"
                            },
                            {
                              "date": "2026-03-02",
                              "description": "THAMES WATER LTD",
                              "payee": "Thames Water",
                              "amount": 38.2,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-03",
                              "description": "TFL TRAVEL CHARGE",
                              "payee": "TfL",
                              "amount": 27.4,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-04",
                              "description": "TESCO STORES 3412",
                              "payee": "Tesco",
                              "amount": 42.1,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-06",
                              "description": "SAINSBURYS SMKTS CD 4412",
                              "payee": "Sainsbury's",
                              "amount": 61.85,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-09",
                              "description": "BRITISH GAS",
                              "payee": "British Gas",
                              "amount": 94,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-11",
                              "description": "ACME LTD SALARY MAR",
                              "payee": "Acme Ltd",
                              "amount": 3200,
                              "direction": "credit",
                              "category": "income"
                            },
                            {
                              "date": "2026-03-12",
                              "description": "SPOTIFY UK",
                              "payee": "Spotify",
                              "amount": 11.99,
                              "direction": "debit",
                              "category": "subscriptions"
                            },
                            {
                              "date": "2026-03-15",
                              "description": "AMEX PAYMENT REF 8842",
                              "payee": null,
                              "amount": 620,
                              "direction": "debit",
                              "category": "card_repayment"
                            },
                            {
                              "date": "2026-03-18",
                              "description": "ASDA SUPERSTORE 2210",
                              "payee": "Asda",
                              "amount": 78.42,
                              "direction": "debit",
                              "category": "groceries"
                            },
                            {
                              "date": "2026-03-20",
                              "description": "PRET A MANGER 114",
                              "payee": "Pret A Manger",
                              "amount": 8.65,
                              "direction": "debit",
                              "category": "dining"
                            },
                            {
                              "date": "2026-03-21",
                              "description": "ARGOS RETAIL REFUND",
                              "payee": "Argos",
                              "amount": 40,
                              "direction": "credit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-22",
                              "description": "SHELL MOTORWAY M4",
                              "payee": "Shell",
                              "amount": 62.14,
                              "direction": "debit",
                              "category": "transport"
                            },
                            {
                              "date": "2026-03-24",
                              "description": "EE LIMITED",
                              "payee": "EE",
                              "amount": 26,
                              "direction": "debit",
                              "category": "utilities"
                            },
                            {
                              "date": "2026-03-25",
                              "description": "ARGOS RETAIL 1180",
                              "payee": "Argos",
                              "amount": 135,
                              "direction": "debit",
                              "category": "shopping"
                            },
                            {
                              "date": "2026-03-27",
                              "description": "ODEON CINEMAS LTD",
                              "payee": "Odeon",
                              "amount": 21.5,
                              "direction": "debit",
                              "category": "entertainment"
                            },
                            {
                              "date": "2026-03-29",
                              "description": "UBER *TRIP HELP.UBER",
                              "payee": "Uber",
                              "amount": 14.3,
                              "direction": "debit",
                              "category": "transport"
                            }
                          ],
                          "totals": {
                            "credits": 3240,
                            "debits": 2691.55
                          },
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 3240,
                              "debits": 2691.55
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": false,
                        "issues": [
                          "Closing balance 1602.56 does not follow from opening balance 1204.11 and the rows returned (difference 150.00)."
                        ]
                      },
                      "status": "succeeded",
                      "error": null,
                      "filename": null,
                      "pages": 3,
                      "metadata": {},
                      "collection": null,
                      "recurring": [
                        {
                          "payee": "Spotify",
                          "category": "subscriptions",
                          "amount": 11.99,
                          "cadence": "monthly",
                          "occurrences": 1,
                          "lastDate": "2026-03-12",
                          "account": 0
                        }
                      ],
                      "authenticity": {
                        "risk": "high",
                        "signals": [
                          {
                            "code": "edited_with_software",
                            "message": "The PDF was last written by Adobe Acrobat Pro, not by the bank's statement system."
                          },
                          {
                            "code": "modified_after_creation",
                            "message": "The PDF was modified 9 days after it was created."
                          },
                          {
                            "code": "balances_do_not_reconcile",
                            "message": "The printed balances do not follow from the transactions (difference 150.00)."
                          }
                        ],
                        "producer": "Adobe Acrobat Pro 2024",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-10T19:44:03.000Z"
                      },
                      "usage": {
                        "pages": 3,
                        "billablePages": 0
                      }
                    }
                  }
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/vnd.intu.qbo": {
                "schema": {
                  "type": "string"
                }
              },
              "application/x-ofx": {
                "schema": {
                  "type": "string"
                }
              },
              "application/qif": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "description": "With `async`: the document with `status: \"processing\"`. Also a replay of one still being read. `X-Billable-Pages` is what will be billed if the read succeeds.",
            "headers": {
              "Location": {
                "$ref": "#/components/headers/Location"
              },
              "X-Billable-Pages": {
                "$ref": "#/components/headers/X-Billable-Pages"
              },
              "Idempotent-Replayed": {
                "$ref": "#/components/headers/Idempotent-Replayed"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingDocument"
                },
                "example": {
                  "id": "doc_8c1d40e97a2b5f3e6d0c9a71",
                  "object": "document",
                  "livemode": true,
                  "created": 1785372094,
                  "status": "processing",
                  "error": null,
                  "filename": "hsbc-2025.pdf",
                  "pages": 84,
                  "metadata": {},
                  "collection": null,
                  "issuer": null,
                  "currency": null,
                  "period": null,
                  "accounts": [],
                  "recurring": [],
                  "verification": null,
                  "authenticity": null,
                  "usage": {
                    "pages": 84,
                    "billablePages": 84
                  }
                }
              }
            }
          },
          "400": {
            "description": "`empty_body`: The request body was empty. Nothing was read and nothing was charged.\n\n`missing_file`: A multipart request with no part named file. Send the statement in a part named file.\n\n`invalid_body`: The body could not be read. A multipart body that does not parse, or a collection request that is not a JSON object or a form.\n\n`invalid_metadata`: metadata is not a JSON object of strings, or is over its limits. Up to 20 keys of 1 to 40 characters, each value up to 500 characters. The message names the key at fault.\n\n`unknown_format`: The format query parameter is not json, csv, ofx, qbo or qif. Nothing was read and nothing was charged.\n\n`format_requires_sync`: A format other than json was asked for with async. Send async requests as JSON. When the document is done, fetch it as JSON and convert it, or send it again without async.\n\n`test_scenario_on_live_key`: X-Test-Scenario was sent with a live key. Live keys read real documents and bill for them, so the header is refused. Nothing was read and nothing was charged. Usually a service deployed with its test configuration.\n\n`unknown_test_scenario`: X-Test-Scenario named a scenario that does not exist. The message lists every valid value. See Test mode for the table.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "empty_body": {
                    "summary": "The request body was empty.",
                    "value": {
                      "error": {
                        "code": "empty_body",
                        "message": "The request body was empty."
                      }
                    }
                  },
                  "missing_file": {
                    "summary": "A multipart request with no part named file.",
                    "value": {
                      "error": {
                        "code": "missing_file",
                        "message": "A multipart request with no part named file."
                      }
                    }
                  },
                  "invalid_body": {
                    "summary": "The body could not be read.",
                    "value": {
                      "error": {
                        "code": "invalid_body",
                        "message": "The body could not be read."
                      }
                    }
                  },
                  "invalid_metadata": {
                    "summary": "metadata is not a JSON object of strings, or is over its limits.",
                    "value": {
                      "error": {
                        "code": "invalid_metadata",
                        "message": "metadata is not a JSON object of strings, or is over its limits."
                      }
                    }
                  },
                  "unknown_format": {
                    "summary": "The format query parameter is not json, csv, ofx, qbo or qif.",
                    "value": {
                      "error": {
                        "code": "unknown_format",
                        "message": "The format query parameter is not json, csv, ofx, qbo or qif."
                      }
                    }
                  },
                  "format_requires_sync": {
                    "summary": "A format other than json was asked for with async.",
                    "value": {
                      "error": {
                        "code": "format_requires_sync",
                        "message": "A format other than json was asked for with async."
                      }
                    }
                  },
                  "test_scenario_on_live_key": {
                    "summary": "X-Test-Scenario was sent with a live key.",
                    "value": {
                      "error": {
                        "code": "test_scenario_on_live_key",
                        "message": "X-Test-Scenario was sent with a live key."
                      }
                    }
                  },
                  "unknown_test_scenario": {
                    "summary": "X-Test-Scenario named a scenario that does not exist.",
                    "value": {
                      "error": {
                        "code": "unknown_test_scenario",
                        "message": "X-Test-Scenario named a scenario that does not exist."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "`free_pages_exhausted`: The free pages are used up and no payment method is on file. Add a payment method in the console's Billing page and the same key keeps working. Nothing needs redeploying.\n\n`not_enough_free_pages`: The file has more pages than the free pages left, and no payment method is on file. A file is never read in part. The error carries pages, the file's page count. Add a payment method, or send a shorter file.\n\n`monthly_cap_reached`: This file would take the account past its pages for the calendar month. The cap is a safety limit. There is nothing to buy: email support with your volume and we raise it. The error carries pages, the file's page count.\n\n`canceled`: Billing for this account was cancelled. Add a payment method in the console's Billing page to reactivate. Keys are kept, so nothing needs reissuing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "free_pages_exhausted": {
                    "summary": "The free pages are used up and no payment method is on file.",
                    "value": {
                      "error": {
                        "code": "free_pages_exhausted",
                        "message": "The 200 free pages are used up. Add a payment method in the console to continue at $0.08 per page.",
                        "pages": 3
                      }
                    }
                  },
                  "not_enough_free_pages": {
                    "summary": "The file has more pages than the free pages left, and no payment method is on file.",
                    "value": {
                      "error": {
                        "code": "not_enough_free_pages",
                        "message": "This file has 12 pages and 7 free pages are left. Add a payment method in the console to continue at $0.08 per page.",
                        "pages": 12
                      }
                    }
                  },
                  "monthly_cap_reached": {
                    "summary": "This file would take the account past its pages for the calendar month.",
                    "value": {
                      "error": {
                        "code": "monthly_cap_reached",
                        "message": "This file would pass this month's limit of 25,000 pages (24,998 used). Contact support to raise it.",
                        "pages": 3
                      }
                    }
                  },
                  "canceled": {
                    "summary": "Billing for this account was cancelled.",
                    "value": {
                      "error": {
                        "code": "canceled",
                        "message": "Billing for this account has been cancelled. Add a payment method in the console to reactivate."
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_key_in_use`: A request with this Idempotency-Key is still being processed. Nothing was read or charged by this request. Retry shortly with the same key to receive the first request's result.\n\n`idempotency_key_not_replayable`: The key succeeded but its result can no longer be returned. reason is expired when the key is over 24 hours old or the document has since been deleted, and too_large when the response could not be stored. The error carries documentId. Retry with a new key only if you want the file read and charged again.\n\n`document_processing`: The document is still being read. Returned by DELETE on a document whose status is processing, and by a csv, ofx, qbo or qif request for a document that has not succeeded. Wait for it to finish.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "idempotency_key_in_use": {
                    "summary": "A request with this Idempotency-Key is still being processed.",
                    "value": {
                      "error": {
                        "code": "idempotency_key_in_use",
                        "message": "A request with this Idempotency-Key is still being processed."
                      }
                    }
                  },
                  "idempotency_key_not_replayable": {
                    "summary": "The key succeeded but its result can no longer be returned.",
                    "value": {
                      "error": {
                        "code": "idempotency_key_not_replayable",
                        "message": "The key succeeded but its result can no longer be returned.",
                        "documentId": "doc_5f2a9c4b1e77d0a3c8b6e412",
                        "reason": "expired"
                      }
                    }
                  },
                  "document_processing": {
                    "summary": "The document is still being read.",
                    "value": {
                      "error": {
                        "code": "document_processing",
                        "message": "The document is still being read."
                      }
                    }
                  }
                }
              }
            }
          },
          "411": {
            "description": "`length_required`: The request has no Content-Length header. Send the file with its size in Content-Length. HTTP clients do this for a file; a streamed body without a length is refused before it is read.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "length_required": {
                    "summary": "The request has no Content-Length header.",
                    "value": {
                      "error": {
                        "code": "length_required",
                        "message": "The request has no Content-Length header."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "`file_too_large`: Over 50MB. Refused as soon as the size is known. Split the statement or export a smaller range.\n\n`too_many_pages`: Over 60 pages in a synchronous request, or over 500 at all. Nothing was charged. The error carries pages and limit. Send a file over the synchronous limit with async=true. Over the async limit, request a shorter date range from the bank.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "file_too_large": {
                    "summary": "Over 50MB.",
                    "value": {
                      "error": {
                        "code": "file_too_large",
                        "message": "The file exceeds the 50MB limit."
                      }
                    }
                  },
                  "too_many_pages": {
                    "summary": "Over 60 pages in a synchronous request, or over 500 at all.",
                    "value": {
                      "error": {
                        "code": "too_many_pages",
                        "message": "Over 60 pages in a synchronous request, or over 500 at all.",
                        "pages": 84,
                        "limit": 60
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "`unsupported_media_type`: Not a file type the API reads. Decided from the file itself, whatever content type you declare. Send a PDF, a JPEG or PNG photo of a statement, or a CSV, OFX or QIF export, as a raw body or a multipart part named file.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "unsupported_media_type": {
                    "summary": "Not a file type the API reads.",
                    "value": {
                      "error": {
                        "code": "unsupported_media_type",
                        "message": "Not a file type the API reads."
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "`not_a_bank_statement`: Readable, but not a statement. A payslip, a receipt, an invoice, a loan history or a damaged file. Usually the right thing to show whoever uploaded it.\n\n`password_required`: The PDF is password-protected. Not charged. Send the password in a multipart part named password and retry. Many issuers in India and Pakistan protect every statement this way, usually with the holder's date of birth or part of their PAN.\n\n`incorrect_password`: The password sent does not open the PDF. Not charged. Ask whoever supplied the file for the right password.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_a_bank_statement": {
                    "summary": "Readable, but not a statement.",
                    "value": {
                      "error": {
                        "code": "not_a_bank_statement",
                        "message": "This document does not look like a bank or card statement.",
                        "documentId": "doc_5f2a9c4b1e77d0a3c8b6e412"
                      }
                    }
                  },
                  "password_required": {
                    "summary": "The PDF is password-protected.",
                    "value": {
                      "error": {
                        "code": "password_required",
                        "message": "This PDF is password-protected. Send its password in a `password` part."
                      }
                    }
                  },
                  "incorrect_password": {
                    "summary": "The password sent does not open the PDF.",
                    "value": {
                      "error": {
                        "code": "incorrect_password",
                        "message": "The password sent does not open this PDF."
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "`too_many_concurrent_requests`: More than 4 synchronous reads in flight at once. There is no per-minute limit. Wait a couple of seconds and retry with the same idempotency key, or send with async=true, which waits its turn instead.\n\n`too_many_test_requests`: More than 120 test requests in one minute. Test mode only. Live requests are unaffected. Wait for the next minute.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "too_many_concurrent_requests": {
                    "summary": "More than 4 synchronous reads in flight at once.",
                    "value": {
                      "error": {
                        "code": "too_many_concurrent_requests",
                        "message": "At most 4 documents may be in flight at once. Retry shortly."
                      }
                    }
                  },
                  "too_many_test_requests": {
                    "summary": "More than 120 test requests in one minute.",
                    "value": {
                      "error": {
                        "code": "too_many_test_requests",
                        "message": "More than 120 test requests in one minute."
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "`parse_failed`: Our error. Nothing is charged and no free pages are spent. Retry with the same key; if the same file fails three times, send us the documentId.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "parse_failed": {
                    "summary": "Our error.",
                    "value": {
                      "error": {
                        "code": "parse_failed",
                        "message": "The document could not be parsed. It has not been charged."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listDocuments",
        "tags": [
          "Documents"
        ],
        "summary": "List documents",
        "description": "Stored documents of the key's mode, newest first, in every state. Documents leave the list when your retention period ends or when you delete them.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/documents#list-documents"
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "1 to 100. Out-of-range values are clamped.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "description": "A document `id`. Returns the documents created before it. Pass the last `id` of a page to get the next.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "collection",
            "in": "query",
            "description": "A `col_` id. Only documents uploaded through it.",
            "schema": {
              "type": "string",
              "pattern": "^col_(test_)?[0-9a-f]{24}$"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "processing",
                "succeeded",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of documents.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": "doc_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "status": "succeeded",
                      "error": null,
                      "filename": "monzo-march-2026.pdf",
                      "pages": 3,
                      "metadata": {
                        "applicationId": "app_8841"
                      },
                      "collection": null,
                      "livemode": true,
                      "created": 1785372094,
                      "issuer": {
                        "name": "Monzo",
                        "domain": "monzo.com"
                      },
                      "currency": "GBP",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4412",
                          "name": null,
                          "currency": "GBP",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "totals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "statedTotals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "openingBalance": 1204.11,
                          "closingBalance": 1602.56,
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 3240,
                              "debits": 2841.55
                            }
                          ],
                          "transactions": [
                            {
                              "date": "2026-03-04",
                              "description": "TESCO STORES 3412",
                              "payee": "Tesco",
                              "amount": 42.1,
                              "direction": "debit",
                              "category": "groceries"
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": true,
                        "issues": []
                      },
                      "recurring": [
                        {
                          "payee": "Spotify",
                          "category": "subscriptions",
                          "amount": 11.99,
                          "cadence": "monthly",
                          "occurrences": 1,
                          "lastDate": "2026-03-12",
                          "account": 0
                        }
                      ],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Monzo Statements",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 3,
                        "billablePages": 3
                      }
                    },
                    {
                      "id": "doc_8c1d40e97a2b5f3e6d0c9a71",
                      "object": "document",
                      "livemode": true,
                      "created": 1785372094,
                      "status": "processing",
                      "error": null,
                      "filename": "hsbc-2025.pdf",
                      "pages": 84,
                      "metadata": {},
                      "collection": null,
                      "issuer": null,
                      "currency": null,
                      "period": null,
                      "accounts": [],
                      "recurring": [],
                      "verification": null,
                      "authenticity": null,
                      "usage": {
                        "pages": 84,
                        "billablePages": 84
                      }
                    }
                  ],
                  "hasMore": true
                }
              }
            }
          },
          "400": {
            "description": "`invalid_status`: The status filter on a list is not processing, succeeded or failed. Omit it to list every document.\n\n`invalid_starting_after`: starting_after on a list names no document or collection of this key's mode. It was deleted or its retention ended. List again from the first page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_status": {
                    "summary": "The status filter on a list is not processing, succeeded or failed.",
                    "value": {
                      "error": {
                        "code": "invalid_status",
                        "message": "The status filter on a list is not processing, succeeded or failed."
                      }
                    }
                  },
                  "invalid_starting_after": {
                    "summary": "starting_after on a list names no document or collection of this key's mode.",
                    "value": {
                      "error": {
                        "code": "invalid_starting_after",
                        "message": "starting_after on a list names no document or collection of this key's mode."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`collection_not_found`: No collection with that id on this account and mode. Also returned by a document list filtered on an unknown collection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "collection_not_found": {
                    "summary": "No collection with that id on this account and mode.",
                    "value": {
                      "error": {
                        "code": "collection_not_found",
                        "message": "No collection with that id on this account and mode."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The document's `id`.",
          "schema": {
            "type": "string",
            "pattern": "^doc_(test_)?[0-9a-f]{24}$"
          },
          "example": "doc_5f2a9c4b1e77d0a3c8b6e412"
        }
      ],
      "get": {
        "operationId": "getDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Get a document",
        "description": "The document in whatever state it is in. Poll this after an async `202` until `status` is `succeeded` or `failed`. Fetching is free.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/documents#get-a-document"
        },
        "responses": {
          "200": {
            "description": "The document.",
            "headers": {
              "X-Billable-Pages": {
                "$ref": "#/components/headers/X-Billable-Pages"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                },
                "examples": {
                  "succeeded": {
                    "value": {
                      "id": "doc_5f2a9c4b1e77d0a3c8b6e412",
                      "object": "document",
                      "status": "succeeded",
                      "error": null,
                      "filename": "monzo-march-2026.pdf",
                      "pages": 3,
                      "metadata": {
                        "applicationId": "app_8841"
                      },
                      "collection": null,
                      "livemode": true,
                      "created": 1785372094,
                      "issuer": {
                        "name": "Monzo",
                        "domain": "monzo.com"
                      },
                      "currency": "GBP",
                      "period": {
                        "year": 2026,
                        "month": 3
                      },
                      "accounts": [
                        {
                          "type": "bank",
                          "last4": "4412",
                          "name": null,
                          "currency": "GBP",
                          "period": {
                            "year": 2026,
                            "month": 3
                          },
                          "primary": true,
                          "totals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "statedTotals": {
                            "credits": 3240,
                            "debits": 2841.55
                          },
                          "openingBalance": 1204.11,
                          "closingBalance": 1602.56,
                          "months": [
                            {
                              "month": "2026-03",
                              "credits": 3240,
                              "debits": 2841.55
                            }
                          ],
                          "transactions": [
                            {
                              "date": "2026-03-04",
                              "description": "TESCO STORES 3412",
                              "payee": "Tesco",
                              "amount": 42.1,
                              "direction": "debit",
                              "category": "groceries"
                            }
                          ]
                        }
                      ],
                      "verification": {
                        "reconciled": true,
                        "issues": []
                      },
                      "recurring": [
                        {
                          "payee": "Spotify",
                          "category": "subscriptions",
                          "amount": 11.99,
                          "cadence": "monthly",
                          "occurrences": 1,
                          "lastDate": "2026-03-12",
                          "account": 0
                        }
                      ],
                      "authenticity": {
                        "risk": "low",
                        "signals": [],
                        "producer": "Monzo Statements",
                        "createdAt": "2026-04-01T06:02:11.000Z",
                        "modifiedAt": "2026-04-01T06:02:11.000Z"
                      },
                      "usage": {
                        "pages": 3,
                        "billablePages": 3
                      }
                    }
                  },
                  "processing": {
                    "value": {
                      "id": "doc_8c1d40e97a2b5f3e6d0c9a71",
                      "object": "document",
                      "livemode": true,
                      "created": 1785372094,
                      "status": "processing",
                      "error": null,
                      "filename": "hsbc-2025.pdf",
                      "pages": 84,
                      "metadata": {},
                      "collection": null,
                      "issuer": null,
                      "currency": null,
                      "period": null,
                      "accounts": [],
                      "recurring": [],
                      "verification": null,
                      "authenticity": null,
                      "usage": {
                        "pages": 84,
                        "billablePages": 84
                      }
                    }
                  },
                  "failed": {
                    "value": {
                      "id": "doc_8c1d40e97a2b5f3e6d0c9a71",
                      "object": "document",
                      "livemode": true,
                      "created": 1785372094,
                      "status": "failed",
                      "error": {
                        "code": "not_a_bank_statement",
                        "message": "This document does not look like a bank or card statement."
                      },
                      "filename": "hsbc-2025.pdf",
                      "pages": 84,
                      "metadata": {},
                      "collection": null,
                      "issuer": null,
                      "currency": null,
                      "period": null,
                      "accounts": [],
                      "recurring": [],
                      "verification": null,
                      "authenticity": null,
                      "usage": {
                        "pages": 84,
                        "billablePages": 0
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`document_not_found`: No document with that id on this account and mode. A test key cannot see live documents, and a live key cannot see test ones. Documents are deleted when your retention period ends, or when you DELETE them.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "document_not_found": {
                    "summary": "No document with that id on this account and mode.",
                    "value": {
                      "error": {
                        "code": "document_not_found",
                        "message": "No document with that id on this account and mode."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Delete a document",
        "description": "Deletes the stored result, and the original file of a collection upload, now. It cannot be undone. A document still being read returns `409 document_processing`.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/documents#delete-a-document"
        },
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeletedDocument"
                },
                "example": {
                  "id": "doc_5f2a9c4b1e77d0a3c8b6e412",
                  "object": "document",
                  "deleted": true
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`document_not_found`: No document with that id on this account and mode. A test key cannot see live documents, and a live key cannot see test ones. Documents are deleted when your retention period ends, or when you DELETE them.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "document_not_found": {
                    "summary": "No document with that id on this account and mode.",
                    "value": {
                      "error": {
                        "code": "document_not_found",
                        "message": "No document with that id on this account and mode."
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "`document_processing`: The document is still being read. Returned by DELETE on a document whose status is processing, and by a csv, ofx, qbo or qif request for a document that has not succeeded. Wait for it to finish.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "document_processing": {
                    "summary": "The document is still being read.",
                    "value": {
                      "error": {
                        "code": "document_processing",
                        "message": "The document is still being read."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/file": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The document's `id`.",
          "schema": {
            "type": "string",
            "pattern": "^doc_(test_)?[0-9a-f]{24}$"
          },
          "example": "doc_5f2a9c4b1e77d0a3c8b6e412"
        }
      ],
      "get": {
        "operationId": "getDocumentFile",
        "tags": [
          "Documents"
        ],
        "summary": "Download the original file",
        "description": "The file exactly as the applicant uploaded it, for a document that came through a collection. A document you sent directly has no stored file and returns `404 file_not_kept`.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/documents#download-the-original-file"
        },
        "responses": {
          "200": {
            "description": "The file.",
            "headers": {
              "Content-Disposition": {
                "description": "`attachment` with the uploaded filename.",
                "schema": {
                  "type": "string"
                }
              },
              "X-Document-Id": {
                "$ref": "#/components/headers/X-Document-Id"
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`document_not_found`: No document with that id on this account and mode. A test key cannot see live documents, and a live key cannot see test ones. Documents are deleted when your retention period ends, or when you DELETE them.\n\n`file_not_kept`: The document has no stored file. Only files uploaded through a collection are kept. Use the copy you sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "document_not_found": {
                    "summary": "No document with that id on this account and mode.",
                    "value": {
                      "error": {
                        "code": "document_not_found",
                        "message": "No document with that id on this account and mode."
                      }
                    }
                  },
                  "file_not_kept": {
                    "summary": "The document has no stored file.",
                    "value": {
                      "error": {
                        "code": "file_not_kept",
                        "message": "The document has no stored file."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/collections": {
      "post": {
        "operationId": "createCollection",
        "tags": [
          "Collections"
        ],
        "summary": "Create a collection",
        "description": "Creates a hosted upload link to send an applicant. Each upload is read as a document of this account and billed per page. Up to 24 files per collection.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/collections#create-a-collection"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80,
                    "description": "Who the statements are for, as you will recognise it."
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 600,
                    "description": "Shown to the applicant above the upload box."
                  },
                  "metadata": {
                    "$ref": "#/components/schemas/Metadata",
                    "description": "Copied onto every document uploaded."
                  },
                  "redirectUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "An `https` URL the applicant is sent to after they submit."
                  },
                  "expiresInDays": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30,
                    "default": 14
                  }
                }
              },
              "example": {
                "name": "Jane Smith remortgage",
                "message": "Please upload your last three months of statements for every current account.",
                "metadata": {
                  "applicationId": "app_8841"
                },
                "redirectUrl": "https://broker.example.com/applications/8841/done"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  },
                  "metadata": {
                    "type": "string",
                    "description": "A JSON object of strings."
                  },
                  "redirectUrl": {
                    "type": "string"
                  },
                  "expiresInDays": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The collection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                },
                "example": {
                  "id": "col_3b9e0c7a51d24f88a6c1e290",
                  "object": "collection",
                  "livemode": true,
                  "created": 1785372094,
                  "name": "Jane Smith remortgage",
                  "message": "Please upload your last three months of statements for every current account.",
                  "url": "https://statementbear.com/r/q7Hx2LmN0pRtVb9kZc4WdYe1",
                  "status": "open",
                  "submittedAt": null,
                  "expiresAt": 1786581694,
                  "redirectUrl": "https://broker.example.com/applications/8841/done",
                  "metadata": {
                    "applicationId": "app_8841"
                  },
                  "documents": []
                }
              }
            }
          },
          "400": {
            "description": "`invalid_body`: The body could not be read. A multipart body that does not parse, or a collection request that is not a JSON object or a form.\n\n`invalid_collection`: A collection field is missing or out of range. name is required. redirectUrl must be https. expiresInDays is a whole number from 1 to 30. The message says which.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_body": {
                    "summary": "The body could not be read.",
                    "value": {
                      "error": {
                        "code": "invalid_body",
                        "message": "The body could not be read."
                      }
                    }
                  },
                  "invalid_collection": {
                    "summary": "A collection field is missing or out of range.",
                    "value": {
                      "error": {
                        "code": "invalid_collection",
                        "message": "A collection field is missing or out of range."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listCollections",
        "tags": [
          "Collections"
        ],
        "summary": "List collections",
        "description": "Collections of the key's mode, newest first.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/collections#list-collections"
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "1 to 100. Out-of-range values are clamped.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "starting_after",
            "in": "query",
            "description": "A collection `id`. Returns the collections created before it. Pass the last `id` of a page to get the next.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of collections.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionList"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": "col_3b9e0c7a51d24f88a6c1e290",
                      "object": "collection",
                      "livemode": true,
                      "created": 1785372094,
                      "name": "Jane Smith remortgage",
                      "message": "Please upload your last three months of statements for every current account.",
                      "url": "https://statementbear.com/r/q7Hx2LmN0pRtVb9kZc4WdYe1",
                      "status": "open",
                      "submittedAt": null,
                      "expiresAt": 1786581694,
                      "redirectUrl": "https://broker.example.com/applications/8841/done",
                      "metadata": {
                        "applicationId": "app_8841"
                      },
                      "documents": []
                    }
                  ],
                  "hasMore": false
                }
              }
            }
          },
          "400": {
            "description": "`invalid_starting_after`: starting_after on a list names no document or collection of this key's mode. It was deleted or its retention ended. List again from the first page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid_starting_after": {
                    "summary": "starting_after on a list names no document or collection of this key's mode.",
                    "value": {
                      "error": {
                        "code": "invalid_starting_after",
                        "message": "starting_after on a list names no document or collection of this key's mode."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/collections/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "description": "The collection's `id`.",
          "schema": {
            "type": "string",
            "pattern": "^col_(test_)?[0-9a-f]{24}$"
          },
          "example": "col_3b9e0c7a51d24f88a6c1e290"
        }
      ],
      "get": {
        "operationId": "getCollection",
        "tags": [
          "Collections"
        ],
        "summary": "Get a collection",
        "description": "The collection, with `documents` listing every upload so far.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/collections#get-a-collection"
        },
        "responses": {
          "200": {
            "description": "The collection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                },
                "example": {
                  "id": "col_3b9e0c7a51d24f88a6c1e290",
                  "object": "collection",
                  "livemode": true,
                  "created": 1785372094,
                  "name": "Jane Smith remortgage",
                  "message": "Please upload your last three months of statements for every current account.",
                  "url": "https://statementbear.com/r/q7Hx2LmN0pRtVb9kZc4WdYe1",
                  "status": "open",
                  "submittedAt": null,
                  "expiresAt": 1786581694,
                  "redirectUrl": "https://broker.example.com/applications/8841/done",
                  "metadata": {
                    "applicationId": "app_8841"
                  },
                  "documents": []
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`collection_not_found`: No collection with that id on this account and mode. Also returned by a document list filtered on an unknown collection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "collection_not_found": {
                    "summary": "No collection with that id on this account and mode.",
                    "value": {
                      "error": {
                        "code": "collection_not_found",
                        "message": "No collection with that id on this account and mode."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "closeCollection",
        "tags": [
          "Collections"
        ],
        "summary": "Close a collection",
        "description": "Stops the link taking uploads and returns the collection with `status: \"closed\"`. Documents already uploaded are kept for your retention period. Closing twice returns the same collection.",
        "externalDocs": {
          "url": "https://statementbear.com/docs/api/collections#close-a-collection"
        },
        "responses": {
          "200": {
            "description": "The closed collection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Collection"
                },
                "example": {
                  "id": "col_3b9e0c7a51d24f88a6c1e290",
                  "object": "collection",
                  "livemode": true,
                  "created": 1785372094,
                  "name": "Jane Smith remortgage",
                  "message": "Please upload your last three months of statements for every current account.",
                  "url": "https://statementbear.com/r/q7Hx2LmN0pRtVb9kZc4WdYe1",
                  "status": "closed",
                  "submittedAt": null,
                  "expiresAt": 1786581694,
                  "redirectUrl": "https://broker.example.com/applications/8841/done",
                  "metadata": {
                    "applicationId": "app_8841"
                  },
                  "documents": []
                }
              }
            }
          },
          "401": {
            "description": "`missing_key`: No Authorization header on the request. Check that your client is sending the header. It is a separate code from invalid_key so the two cases are easy to tell apart in a log.\n\n`invalid_key`: The key is unknown or has been revoked. Revoking a key in the console applies to the next request. Check the value before assuming the key was revoked: a typo returns the same code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "missing_key": {
                    "summary": "No Authorization header on the request.",
                    "value": {
                      "error": {
                        "code": "missing_key",
                        "message": "No Authorization header on the request."
                      }
                    }
                  },
                  "invalid_key": {
                    "summary": "The key is unknown or has been revoked.",
                    "value": {
                      "error": {
                        "code": "invalid_key",
                        "message": "The key is unknown or has been revoked."
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`collection_not_found`: No collection with that id on this account and mode. Also returned by a document list filtered on an unknown collection.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "collection_not_found": {
                    "summary": "No collection with that id on this account and mode.",
                    "value": {
                      "error": {
                        "code": "collection_not_found",
                        "message": "No collection with that id on this account and mode."
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "document.succeeded": {
      "post": {
        "operationId": "webhook_document_succeeded",
        "tags": [
          "Webhooks"
        ],
        "summary": "A read finished",
        "description": "Sent when a read finishes: async, synchronous and collection uploads alike. `data.object` is the complete document.",
        "security": [],
        "parameters": [
          {
            "name": "StatementBear-Signature",
            "in": "header",
            "required": true,
            "description": "`t=<unix seconds>,v1=<hex>`. Join `t`, a full stop and the raw body, compute HMAC-SHA256 of it keyed with the endpoint's whole `whsec_` secret as lowercase hex, and compare with `v1` in constant time. Reject the event when `t` is more than five minutes from your clock.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Event"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "document.succeeded"
                      },
                      "data": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "$ref": "#/components/schemas/SucceededDocument"
                          }
                        }
                      }
                    }
                  }
                ]
              },
              "example": {
                "id": "evt_0e4c7b91a2d35f86c1b0a9e4",
                "object": "event",
                "type": "document.succeeded",
                "created": 1785372131,
                "livemode": true,
                "data": {
                  "object": {
                    "id": "doc_5f2a9c4b1e77d0a3c8b6e412",
                    "object": "document",
                    "status": "succeeded",
                    "error": null,
                    "filename": "monzo-march-2026.pdf",
                    "pages": 3,
                    "metadata": {
                      "applicationId": "app_8841"
                    },
                    "collection": null,
                    "livemode": true,
                    "created": 1785372094,
                    "issuer": {
                      "name": "Monzo",
                      "domain": "monzo.com"
                    },
                    "currency": "GBP",
                    "period": {
                      "year": 2026,
                      "month": 3
                    },
                    "accounts": [
                      {
                        "type": "bank",
                        "last4": "4412",
                        "name": null,
                        "currency": "GBP",
                        "period": {
                          "year": 2026,
                          "month": 3
                        },
                        "primary": true,
                        "totals": {
                          "credits": 3240,
                          "debits": 2841.55
                        },
                        "statedTotals": {
                          "credits": 3240,
                          "debits": 2841.55
                        },
                        "openingBalance": 1204.11,
                        "closingBalance": 1602.56,
                        "months": [
                          {
                            "month": "2026-03",
                            "credits": 3240,
                            "debits": 2841.55
                          }
                        ],
                        "transactions": [
                          {
                            "date": "2026-03-04",
                            "description": "TESCO STORES 3412",
                            "payee": "Tesco",
                            "amount": 42.1,
                            "direction": "debit",
                            "category": "groceries"
                          }
                        ]
                      }
                    ],
                    "verification": {
                      "reconciled": true,
                      "issues": []
                    },
                    "recurring": [
                      {
                        "payee": "Spotify",
                        "category": "subscriptions",
                        "amount": 11.99,
                        "cadence": "monthly",
                        "occurrences": 1,
                        "lastDate": "2026-03-12",
                        "account": 0
                      }
                    ],
                    "authenticity": {
                      "risk": "low",
                      "signals": [],
                      "producer": "Monzo Statements",
                      "createdAt": "2026-04-01T06:02:11.000Z",
                      "modifiedAt": "2026-04-01T06:02:11.000Z"
                    },
                    "usage": {
                      "pages": 3,
                      "billablePages": 3
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledge within 10 seconds. Any other status, a timeout or a connection error is retried up to 8 times over about three days, with the same body and event `id`."
          }
        }
      }
    },
    "document.failed": {
      "post": {
        "operationId": "webhook_document_failed",
        "tags": [
          "Webhooks"
        ],
        "summary": "A read failed",
        "description": "Sent when a read fails after the document was created: every async failure, and a synchronous read that failed partway. A request refused before a document exists sends no event.",
        "security": [],
        "parameters": [
          {
            "name": "StatementBear-Signature",
            "in": "header",
            "required": true,
            "description": "`t=<unix seconds>,v1=<hex>`. Join `t`, a full stop and the raw body, compute HMAC-SHA256 of it keyed with the endpoint's whole `whsec_` secret as lowercase hex, and compare with `v1` in constant time. Reject the event when `t` is more than five minutes from your clock.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Event"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "document.failed"
                      },
                      "data": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "$ref": "#/components/schemas/PendingDocument"
                          }
                        }
                      }
                    }
                  }
                ]
              },
              "example": {
                "id": "evt_0e4c7b91a2d35f86c1b0a9e4",
                "object": "event",
                "type": "document.failed",
                "created": 1785372131,
                "livemode": true,
                "data": {
                  "object": {
                    "id": "doc_8c1d40e97a2b5f3e6d0c9a71",
                    "object": "document",
                    "livemode": true,
                    "created": 1785372094,
                    "status": "failed",
                    "error": {
                      "code": "not_a_bank_statement",
                      "message": "This document does not look like a bank or card statement."
                    },
                    "filename": "hsbc-2025.pdf",
                    "pages": 84,
                    "metadata": {},
                    "collection": null,
                    "issuer": null,
                    "currency": null,
                    "period": null,
                    "accounts": [],
                    "recurring": [],
                    "verification": null,
                    "authenticity": null,
                    "usage": {
                      "pages": 84,
                      "billablePages": 0
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledge within 10 seconds. Any other status, a timeout or a connection error is retried up to 8 times over about three days, with the same body and event `id`."
          }
        }
      }
    },
    "collection.submitted": {
      "post": {
        "operationId": "webhook_collection_submitted",
        "tags": [
          "Webhooks"
        ],
        "summary": "An applicant sent everything",
        "description": "Sent when an applicant presses the button saying they have sent everything. `data.object` is the collection.",
        "security": [],
        "parameters": [
          {
            "name": "StatementBear-Signature",
            "in": "header",
            "required": true,
            "description": "`t=<unix seconds>,v1=<hex>`. Join `t`, a full stop and the raw body, compute HMAC-SHA256 of it keyed with the endpoint's whole `whsec_` secret as lowercase hex, and compare with `v1` in constant time. Reject the event when `t` is more than five minutes from your clock.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Event"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "collection.submitted"
                      },
                      "data": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "$ref": "#/components/schemas/Collection"
                          }
                        }
                      }
                    }
                  }
                ]
              },
              "example": {
                "id": "evt_0e4c7b91a2d35f86c1b0a9e4",
                "object": "event",
                "type": "collection.submitted",
                "created": 1785372131,
                "livemode": true,
                "data": {
                  "object": {
                    "id": "col_3b9e0c7a51d24f88a6c1e290",
                    "object": "collection",
                    "livemode": true,
                    "created": 1785372094,
                    "name": "Jane Smith remortgage",
                    "message": "Please upload your last three months of statements for every current account.",
                    "url": "https://statementbear.com/r/q7Hx2LmN0pRtVb9kZc4WdYe1",
                    "status": "submitted",
                    "submittedAt": 1785459000,
                    "expiresAt": 1786581694,
                    "redirectUrl": "https://broker.example.com/applications/8841/done",
                    "metadata": {
                      "applicationId": "app_8841"
                    },
                    "documents": []
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledge within 10 seconds. Any other status, a timeout or a connection error is retried up to 8 times over about three days, with the same body and event `id`."
          }
        }
      }
    },
    "test": {
      "post": {
        "operationId": "webhook_test",
        "tags": [
          "Webhooks"
        ],
        "summary": "A test event",
        "description": "Sent once, never retried, when you press Send test event in the console.",
        "security": [],
        "parameters": [
          {
            "name": "StatementBear-Signature",
            "in": "header",
            "required": true,
            "description": "`t=<unix seconds>,v1=<hex>`. Join `t`, a full stop and the raw body, compute HMAC-SHA256 of it keyed with the endpoint's whole `whsec_` secret as lowercase hex, and compare with `v1` in constant time. Reject the event when `t` is more than five minutes from your clock.",
            "schema": {
              "type": "string",
              "pattern": "^t=\\d+,v1=[0-9a-f]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Event"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "const": "test"
                      },
                      "data": {
                        "type": "object",
                        "properties": {
                          "object": {
                            "type": "object",
                            "required": [
                              "message"
                            ],
                            "properties": {
                              "message": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                ]
              },
              "example": {
                "id": "evt_0e4c7b91a2d35f86c1b0a9e4",
                "object": "event",
                "type": "test",
                "created": 1785372131,
                "livemode": true,
                "data": {
                  "object": {
                    "message": "A test event from the StatementBear console."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Acknowledge within 10 seconds. Any other status, a timeout or a connection error is retried up to 8 times over about three days, with the same body and event `id`."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sb_live_... or sb_test_...",
        "description": "An API key from the console. `sb_live_` keys read and bill; `sb_test_` keys return fixtures and are never billed."
      }
    },
    "headers": {
      "X-Billable-Pages": {
        "description": "Pages billed for this document. `0` on a test key and when the pages came from your free pages. On a `202`, what will be billed if the read succeeds.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      },
      "Idempotent-Replayed": {
        "description": "`true` when the body is the stored document of an earlier request with the same `Idempotency-Key`.",
        "schema": {
          "type": "string",
          "enum": [
            "true"
          ]
        }
      },
      "Location": {
        "description": "The document's URL, `/api/v1/documents/{id}`.",
        "schema": {
          "type": "string"
        }
      },
      "X-Document-Id": {
        "description": "The document's `id`, on a file response.",
        "schema": {
          "type": "string"
        }
      },
      "Allow": {
        "description": "The methods the path supports.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "MethodNotAllowed": {
        "description": "`method_not_allowed`: The method is not supported on this path. The response carries an Allow header listing the methods that are.",
        "headers": {
          "Allow": {
            "$ref": "#/components/headers/Allow"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "method_not_allowed": {
                "summary": "The method is not supported on this path.",
                "value": {
                  "error": {
                    "code": "method_not_allowed",
                    "message": "The method is not supported on this path."
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Period": {
        "type": "object",
        "required": [
          "year",
          "month"
        ],
        "properties": {
          "year": {
            "type": "integer"
          },
          "month": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          }
        }
      },
      "Metadata": {
        "type": "object",
        "description": "Your own key-value pairs. Up to 20 keys of 1 to 40 characters, each value a string of up to 500.",
        "maxProperties": 20,
        "propertyNames": {
          "minLength": 1,
          "maxLength": 40
        },
        "additionalProperties": {
          "type": "string",
          "maxLength": 500
        }
      },
      "Transaction": {
        "type": "object",
        "required": [
          "date",
          "description",
          "payee",
          "amount",
          "direction",
          "category"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "YYYY-MM-DD. The date printed against the row. The posting date on most statements and the transaction date on some. The document does not say which, so we return what is printed."
          },
          "description": {
            "type": "string",
            "description": "The payee line as printed. Not normalised. Includes the branch, reference and city where the issuer prints them. When the issuer prints no description for a row, it is the category's name."
          },
          "payee": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who was paid, or who paid in, as a person would name them. The brand for a business, the name for a person, the employer for a salary: \"BP\" for \"CARD PURCHASE WITH PIN BP#88736971615 COLUMBUS OH\". Null for fees, interest, cash, moves between the account holder's own accounts, lines that name nobody, and lines we could not name. Fall back to `description` when it is null."
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "description": "Always positive. direction carries the sign. Never negative, in any currency, on any account type. Negate when direction is debit for a signed figure."
          },
          "direction": {
            "type": "string",
            "enum": [
              "credit",
              "debit"
            ],
            "description": "Read from the document, never from the payee name. Issuers encode it four ways: a sign on the amount, a section heading owning the rows beneath it, paired debit and credit columns, or a CR marker against a default. A trailing minus means money out on a bank statement and money in on a card statement."
          },
          "category": {
            "type": "string",
            "enum": [
              "income",
              "housing",
              "utilities",
              "groceries",
              "dining",
              "transport",
              "entertainment",
              "shopping",
              "subscriptions",
              "health",
              "education",
              "savings",
              "card_repayment",
              "internal_transfer",
              "fees",
              "other"
            ],
            "description": "One of a fixed set. A hint for a first cut at spending mix. Not a merchant category code and not derived from one. Do not reconcile it against MCC data or use it where a regulator expects a defined taxonomy."
          }
        }
      },
      "MonthTotals": {
        "type": "object",
        "required": [
          "month",
          "credits",
          "debits"
        ],
        "properties": {
          "month": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}$",
            "description": "YYYY-MM."
          },
          "credits": {
            "type": "number",
            "minimum": 0
          },
          "debits": {
            "type": "number",
            "minimum": 0
          }
        }
      },
      "Account": {
        "type": "object",
        "required": [
          "type",
          "last4",
          "name",
          "currency",
          "period",
          "primary",
          "totals",
          "statedTotals",
          "openingBalance",
          "closingBalance",
          "months",
          "transactions"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "bank",
              "credit_card"
            ],
            "description": "bank covers any deposit account: current, checking, savings. Decides how to read credits. On a credit card they are the repayment and merchant refunds, so counting them as income inflates it."
          },
          "last4": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last four of the account or card number, when it is printed. Null when the issuer prints no account or card number, or prints only a masked one."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account's own name, e.g. \"360 Performance Savings\". Null when the issuer prints the product name at the top of the page, which is usual on a single-account statement."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "ISO 4217. The account's amounts and balances are in this currency. The document's currency, except for a ledger kept in another one, such as a US dollar cash account printed beside a Canadian dollar one under the same number. Do not add amounts across accounts in different currencies."
          },
          "period": {
            "$ref": "#/components/schemas/Period",
            "description": "The month this account's statement is dated. On a file holding several monthly statements for one account, an entry can hold rows from more than one month. Use accounts[].months, or each transaction's date."
          },
          "primary": {
            "type": "boolean",
            "description": "The account the issuer printed first. Exactly one per document. Only the primary account returns opening and closing balances. Every account is checked against its own printed balances: see verification."
          },
          "totals": {
            "type": "object",
            "required": [
              "credits",
              "debits"
            ],
            "properties": {
              "credits": {
                "type": "number",
                "minimum": 0
              },
              "debits": {
                "type": "number",
                "minimum": 0
              }
            },
            "description": "Our sum of the rows: { credits, debits }, both positive. Summed from the transactions in this response, so it always agrees with them."
          },
          "statedTotals": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "credits",
              "debits"
            ],
            "properties": {
              "credits": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "debits": {
                "type": [
                  "number",
                  "null"
                ]
              }
            },
            "description": "What the statement itself prints, exactly as printed. Use it to check our extraction against the document. It is not comparable across issuers: Amex's spend total is net of refunds and most banks' is not."
          },
          "openingBalance": {
            "type": [
              "number",
              "null"
            ],
            "description": "Opening balance, when the issuer prints one. With closingBalance it is the strongest check available, because the transactions have to account for the movement between them exactly."
          },
          "closingBalance": {
            "type": [
              "number",
              "null"
            ],
            "description": "Closing balance, when the issuer prints one. Null on secondary accounts and on issuers that print no balances. On a credit card it is the balance owed, printed positive."
          },
          "months": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthTotals"
            },
            "description": "Money in and out per calendar month: { month, credits, debits }. month is YYYY-MM, oldest first, one entry per month the rows fall in. Summed from this account's transactions, so the entries add up to totals."
          },
          "transactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Transaction"
            }
          }
        }
      },
      "RecurringPayment": {
        "type": "object",
        "required": [
          "payee",
          "category",
          "amount",
          "cadence",
          "occurrences",
          "lastDate",
          "account"
        ],
        "properties": {
          "payee": {
            "type": "string",
            "description": "Who is paid, as a person would name them. category is from the same fixed set as transactions[].category."
          },
          "category": {
            "type": "string",
            "enum": [
              "income",
              "housing",
              "utilities",
              "groceries",
              "dining",
              "transport",
              "entertainment",
              "shopping",
              "subscriptions",
              "health",
              "education",
              "savings",
              "card_repayment",
              "internal_transfer",
              "fees",
              "other"
            ]
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "description": "The typical amount, positive, in the account's currency. The average of the payments seen, rounded to the cent."
          },
          "cadence": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "weekly",
              "biweekly",
              "monthly",
              "quarterly",
              "yearly",
              null
            ],
            "description": "How often it is paid. Null when it was seen once and the brand sells both a monthly and a yearly plan, so the period cannot be known from one charge."
          },
          "occurrences": {
            "type": "integer",
            "minimum": 1,
            "description": "How many times it appears in this document. Counted in this document only. Other documents you send are never combined with it."
          },
          "lastDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "account": {
            "type": "integer",
            "minimum": 0,
            "description": "Index into accounts of the account that pays it. 0 is the first entry in accounts."
          }
        }
      },
      "Verification": {
        "type": "object",
        "required": [
          "reconciled",
          "issues"
        ],
        "properties": {
          "reconciled": {
            "type": "boolean"
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What did not add up. Often empty. Written for a person triaging a document. Branch on reconciled; show issues to whoever opens the file."
          }
        }
      },
      "Authenticity": {
        "type": "object",
        "required": [
          "risk",
          "signals",
          "producer",
          "createdAt",
          "modifiedAt"
        ],
        "properties": {
          "risk": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ],
            "description": "high when the file's history and its figures both point at an edit. medium when one of them does. low when neither does, which includes a document whose only signals are duplicate_file or image_only."
          },
          "signals": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "code",
                "message"
              ],
              "properties": {
                "code": {
                  "type": "string",
                  "enum": [
                    "edited_with_software",
                    "modified_after_creation",
                    "balances_do_not_reconcile",
                    "duplicate_file",
                    "image_only"
                  ],
                  "description": "New codes can be added within v1. Treat an unknown one as worth a reviewer's look."
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "description": "{ code, message } per signal found. Often empty. code is one of edited_with_software, modified_after_creation, balances_do_not_reconcile, duplicate_file, image_only. Branch on code; show message to a reviewer."
          },
          "producer": {
            "type": [
              "string",
              "null"
            ],
            "description": "The program the file says made it, as the PDF records it. createdAt and modifiedAt are the PDF's own timestamps, ISO 8601. All three are null when the file records none, and on exports."
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "modifiedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Usage": {
        "type": "object",
        "required": [
          "pages",
          "billablePages"
        ],
        "properties": {
          "pages": {
            "type": "integer",
            "minimum": 0
          },
          "billablePages": {
            "type": "integer",
            "minimum": 0
          }
        },
        "description": "{ pages, billablePages }: pages read, and how many of them are billed. The rest came from your free pages. billablePages is 0 on a test key and on a failed read. While a document is processing it is what will be billed if the read succeeds. X-Billable-Pages carries the same number."
      },
      "DocumentError": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "SucceededDocument": {
        "type": "object",
        "description": "A document whose read is done. Every field is filled.",
        "required": [
          "id",
          "object",
          "status",
          "error",
          "filename",
          "pages",
          "metadata",
          "collection",
          "livemode",
          "created",
          "issuer",
          "currency",
          "period",
          "accounts",
          "verification",
          "recurring",
          "authenticity",
          "usage"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^doc_(test_)?[0-9a-f]{24}$",
            "description": "Our id for this document: doc_ followed by 24 hex characters. Fetch, delete or download it by this id. A test key's ids start doc_test_. Also on the error body of a failed request, so a failure can be traced to the call that produced it. Quote it in any support question."
          },
          "object": {
            "type": "string",
            "const": "document",
            "description": "Always document. Present so responses are discriminable. Lists and webhook events wrap documents, so the type is on every object."
          },
          "filename": {
            "type": [
              "string",
              "null"
            ],
            "description": "The file's name, from the multipart part or X-Filename. Null when the file was sent as a raw body without X-Filename."
          },
          "pages": {
            "type": "integer",
            "minimum": 0,
            "description": "Pages in the file, as billed. A PDF's own page count. A photo is one page. A CSV, OFX or QIF export is one page per 40 rows."
          },
          "metadata": {
            "$ref": "#/components/schemas/Metadata",
            "description": "Your own key-value pairs, echoed back. {} when none were sent. Up to 20 keys of 1 to 40 characters, each value a string of up to 500. Numbers and booleans are stored as strings. A collection's metadata is copied onto every document uploaded through it."
          },
          "collection": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^col_(test_)?[0-9a-f]{24}$",
            "description": "The col_ id the file was uploaded through. Null for a direct upload. Only documents uploaded through a collection keep their original file. See Collections."
          },
          "livemode": {
            "type": "boolean",
            "description": "False when the document came from a test key. A test key returns a fixture and reads nothing. Store this alongside whatever you read the document for: a header is gone by the time somebody is looking at a saved document and asking why the applicant banks with Monzo."
          },
          "created": {
            "type": "integer",
            "description": "When the document was received. Unix seconds. Our clock. The month the document covers is in period."
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "status": {
            "type": "string",
            "const": "succeeded",
            "description": "Whether the read is done. A synchronous 200 is always succeeded. An async request, and a collection upload, starts as processing. While it is processing or failed, every read field is null or empty: issuer, currency, period, verification and authenticity are null, accounts and recurring are empty."
          },
          "error": {
            "type": "null"
          },
          "issuer": {
            "type": "object",
            "required": [
              "name",
              "domain"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "domain": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "The bank as printed, plus its domain for logo lookups. domain is null when the institution's website cannot be identified with confidence. The whole object is null until the read succeeds."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "ISO 4217. The primary account's currency. A statement that keeps a ledger in another currency returns it as an account of its own, with that currency in accounts[].currency."
          },
          "period": {
            "$ref": "#/components/schemas/Period",
            "description": "The month the document covers: { year, month } with month 1-12. Each account carries its own period too. They differ only on a combined file holding several months for one account."
          },
          "accounts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/Account"
            },
            "description": "One entry per account printed in the file. Usually one. Some issuers bill several accounts on one statement. They are kept separate because transfers between them are printed on both sides, so merging them counts each transfer as spending and as income."
          },
          "verification": {
            "$ref": "#/components/schemas/Verification",
            "description": "Our check of the extraction against the document. reconciled: true means we checked and found nothing wrong. false with a non-empty issues array means we found something: treat the figures as unverified. Null until the read succeeds."
          },
          "recurring": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecurringPayment"
            },
            "description": "Payments that repeat across the rows, and known subscriptions seen once. Detected from the transactions in this response. Each payment stays on its own account, so a subscription moved from one card to another is two entries."
          },
          "authenticity": {
            "$ref": "#/components/schemas/Authenticity",
            "description": "Signs that the file was edited or sent before. Null until the read succeeds. Signals to review, never proof of fraud. See Authenticity signals for each code and how to use risk."
          }
        }
      },
      "PendingDocument": {
        "type": "object",
        "description": "A document still being read (`processing`) or whose read failed (`failed`). Every read field is null or empty.",
        "required": [
          "id",
          "object",
          "status",
          "error",
          "filename",
          "pages",
          "metadata",
          "collection",
          "livemode",
          "created",
          "issuer",
          "currency",
          "period",
          "accounts",
          "verification",
          "recurring",
          "authenticity",
          "usage"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^doc_(test_)?[0-9a-f]{24}$",
            "description": "Our id for this document: doc_ followed by 24 hex characters. Fetch, delete or download it by this id. A test key's ids start doc_test_. Also on the error body of a failed request, so a failure can be traced to the call that produced it. Quote it in any support question."
          },
          "object": {
            "type": "string",
            "const": "document",
            "description": "Always document. Present so responses are discriminable. Lists and webhook events wrap documents, so the type is on every object."
          },
          "filename": {
            "type": [
              "string",
              "null"
            ],
            "description": "The file's name, from the multipart part or X-Filename. Null when the file was sent as a raw body without X-Filename."
          },
          "pages": {
            "type": "integer",
            "minimum": 0,
            "description": "Pages in the file, as billed. A PDF's own page count. A photo is one page. A CSV, OFX or QIF export is one page per 40 rows."
          },
          "metadata": {
            "$ref": "#/components/schemas/Metadata",
            "description": "Your own key-value pairs, echoed back. {} when none were sent. Up to 20 keys of 1 to 40 characters, each value a string of up to 500. Numbers and booleans are stored as strings. A collection's metadata is copied onto every document uploaded through it."
          },
          "collection": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^col_(test_)?[0-9a-f]{24}$",
            "description": "The col_ id the file was uploaded through. Null for a direct upload. Only documents uploaded through a collection keep their original file. See Collections."
          },
          "livemode": {
            "type": "boolean",
            "description": "False when the document came from a test key. A test key returns a fixture and reads nothing. Store this alongside whatever you read the document for: a header is gone by the time somebody is looking at a saved document and asking why the applicant banks with Monzo."
          },
          "created": {
            "type": "integer",
            "description": "When the document was received. Unix seconds. Our clock. The month the document covers is in period."
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "status": {
            "type": "string",
            "enum": [
              "processing",
              "failed"
            ]
          },
          "error": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DocumentError"
              },
              {
                "type": "null"
              }
            ],
            "description": "{ code, message } when status is failed. Null otherwise. The same code and message a synchronous request would have returned, so one error handler covers both paths. See Errors."
          },
          "issuer": {
            "type": "null"
          },
          "currency": {
            "type": "null"
          },
          "period": {
            "type": "null"
          },
          "accounts": {
            "type": "array",
            "maxItems": 0
          },
          "verification": {
            "type": "null"
          },
          "recurring": {
            "type": "array",
            "maxItems": 0
          },
          "authenticity": {
            "type": "null"
          }
        }
      },
      "Document": {
        "description": "A document in any state. Branch on `status`.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/SucceededDocument"
          },
          {
            "$ref": "#/components/schemas/PendingDocument"
          }
        ],
        "discriminator": {
          "propertyName": "status",
          "mapping": {
            "succeeded": "#/components/schemas/SucceededDocument",
            "processing": "#/components/schemas/PendingDocument",
            "failed": "#/components/schemas/PendingDocument"
          }
        }
      },
      "DeletedDocument": {
        "type": "object",
        "required": [
          "id",
          "object",
          "deleted"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "document"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "DocumentList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "hasMore"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Document"
            }
          },
          "hasMore": {
            "type": "boolean",
            "description": "True when there are more after this page. Pass the last `id` as `starting_after`."
          }
        }
      },
      "Collection": {
        "type": "object",
        "required": [
          "id",
          "object",
          "livemode",
          "created",
          "name",
          "message",
          "url",
          "status",
          "submittedAt",
          "expiresAt",
          "redirectUrl",
          "metadata",
          "documents"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^col_(test_)?[0-9a-f]{24}$",
            "description": "col_ followed by 24 hex characters. col_test_ on a test key. Filter documents by it with GET /api/v1/documents?collection=."
          },
          "object": {
            "type": "string",
            "const": "collection",
            "description": "Always collection. Lists and webhook events wrap collections, so the type is on every object."
          },
          "livemode": {
            "type": "boolean",
            "description": "False when a test key created it. Uploads to a test collection return the bank fixture and are never billed."
          },
          "created": {
            "type": "integer",
            "description": "When it was created. Unix seconds. expiresAt and submittedAt use the same units."
          },
          "name": {
            "type": "string",
            "maxLength": 80,
            "description": "Who the statements are for, as you will recognise it. Required. Up to 80 characters. Shown in your console."
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 600,
            "description": "Shown to the uploader above the upload box. Up to 600 characters. Say which accounts and months you need."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The hosted page to send the applicant. The link is the applicant's only access, so send it only to them. It stops taking uploads when the collection is closed or expires."
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "submitted",
              "expired",
              "closed"
            ],
            "description": "open until the applicant says they have sent everything. submitted once they press the button on the page. expired after expiresAt. closed after you DELETE it. A closed or expired collection takes no more uploads."
          },
          "submittedAt": {
            "type": [
              "integer",
              "null"
            ],
            "description": "When the applicant said they had sent everything. The collection.submitted event is sent at the same moment."
          },
          "expiresAt": {
            "type": "integer",
            "description": "When the link stops working. Unix seconds. Set by expiresInDays: 1 to 30, default 14."
          },
          "redirectUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Where the applicant is sent after they submit. An https URL. Without one, the page thanks them and they close it."
          },
          "metadata": {
            "$ref": "#/components/schemas/Metadata",
            "description": "Your own key-value pairs, copied onto every document uploaded. Same limits as a document's metadata."
          },
          "documents": {
            "type": "array",
            "maxItems": 24,
            "items": {
              "type": "string",
              "pattern": "^doc_(test_)?[0-9a-f]{24}$"
            },
            "description": "The doc_ ids of every file uploaded so far, oldest first. Up to 24. Fetch each with GET /api/v1/documents/{id}."
          }
        }
      },
      "CollectionList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "hasMore"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Collection"
            }
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "description": "Every error. Branch on `code`: messages get reworded, codes do not.",
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "documentId": {
                "type": "string",
                "description": "Present whenever the request got far enough to allocate one. Quote it in a support question."
              },
              "pages": {
                "type": "integer",
                "description": "The file's page count, on a 402 and on 413 too_many_pages."
              },
              "limit": {
                "type": "integer",
                "description": "The page limit that applied, on 413 too_many_pages."
              },
              "reason": {
                "type": "string",
                "enum": [
                  "expired",
                  "too_large"
                ],
                "description": "On 409 idempotency_key_not_replayable."
              }
            }
          }
        }
      },
      "Event": {
        "type": "object",
        "required": [
          "id",
          "object",
          "type",
          "created",
          "livemode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^evt_[0-9a-f]{24}$",
            "description": "The same on every retry of one event. De-duplicate on it."
          },
          "object": {
            "type": "string",
            "const": "event"
          },
          "type": {
            "type": "string"
          },
          "created": {
            "type": "integer",
            "description": "When the event happened. Unix seconds."
          },
          "livemode": {
            "type": "boolean",
            "description": "False on a test endpoint."
          },
          "data": {
            "type": "object",
            "required": [
              "object"
            ],
            "properties": {
              "object": {
                "description": "The document or collection, as GET would return it at that moment."
              }
            }
          }
        }
      }
    }
  }
}
