# Bank Statement Formats (MT940, camt, OFX, BAI2) API

> Turn MT940 / MT942, camt.052 / 053 / 054, OFX and BAI2 statements into one JSON transaction schema with balance checks; build pain.001 files.

- Endpoint: `POST https://apibox.io.vn/v1/bank-formats`
- Category: Data & JSON
- HTML docs: https://apibox.io.vn/docs/bank-formats/ (Vietnamese: https://apibox.io.vn/vi/docs/bank-formats/)
- Online tool: https://apibox.io.vn/tools/bank-formats/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send a statement as `text`, a `file` upload or a raw body. The format is detected (or set `from`): SWIFT MT940 / MT942 (with or without the {1:}{2:}{4:} blocks; field 86 in the German ?-structure with SEPA keywords EREF+ / MREF+ / SVWZ+, the /EREF/NAME/IBAN/REMI/ slash structure, or free text), ISO 20022 camt.052 / camt.053 / camt.054 (any version), OFX / QFX 1.x SGML and 2.x XML (bank and credit-card statements) and BAI2 (continuation records, funds types, amounts in minor units).

Every statement becomes `account` (IBAN, number, BIC, currency, owner), opening / closing / available balances and `transactions` with booking and value dates, a signed `amount`, `direction`, bank transaction code with description (ISO 20022 domain / family / sub-family, BAI type codes), bank and customer references, end-to-end ID, mandate and creditor IDs, counterparty name / IBAN / BIC and remittance information. `checks` recomputes opening + transactions = closing and compares stated counts. `format=csv` returns one row per transaction.

`action=pain001` builds an ISO 20022 credit transfer (pain.001.001.09, or `version: "03"`) from JSON `debtor` and `payments`, checking IBANs (country length + mod 97), BICs and amounts; all-EUR / IBAN batches are marked SEPA. `action=iban` checks one IBAN.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `text` | body | string | no |  | Statement content (or send a file / raw body). |
| `file` | body | file | no |  | Statement file (.sta, .mt940, .xml, .ofx, .qfx, .bai). |
| `from` | body|query | string | no |  | Force the input format: `mt940`, `mt942`, `camt`, `ofx`, `bai2`. |
| `format` | body|query | string | no | `json` | `json` or `csv` (parse); `xml` returns the raw pain.001 file. |
| `action` | body|query | string | no | `parse` | `parse`, `pain001` or `iban`. |
| `debtor` | body | object | no |  | pain001: `{name, iban, bic}` of the paying account. |
| `payments` | body | array | no |  | pain001: `[{amount, currency, creditor: {name, iban, bic}, end_to_end_id, remittance \| structured_reference}]` (max 5000). |
| `execution_date` | body | string | no |  | pain001: requested execution date (YYYY-MM-DD). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/bank-formats" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":":20:STMT20261111\n:25:DEUTDEFF/DE89370400440532013000\n:28C:00221/001\n:60F:C261110EUR1250,00\n:61:2611101110D45,50NDDTNONREF//BANKREF001\n:86:/EREF/INV-2026-001/NAME/Stadtwerke Musterstadt/IBAN/DE02120300000000202051/REMI/USTD//Strom November/\n:61:2611111111C1000,00NTRFINV7788//BANKREF002\n:86:/EREF/E2E-7788/NAME/ACME GmbH/IBAN/DE75512108001245126199/REMI/USTD//Invoice 7788/\n:62F:C261111EUR2204,50\n-"}'
```

## Example response

```json
{
  "format": "mt940",
  "statements_count": 1,
  "transactions_count": 2,
  "balance_ok": true,
  "statements": [
    {
      "account": {
        "iban": "DE89370400440532013000",
        "bic": "DEUTDEFF",
        "number": "DE89370400440532013000",
        "currency": "EUR"
      },
      "transactions": [
        {
          "booking_date": "2026-11-10",
          "value_date": "2026-11-10",
          "amount": -45.5,
          "currency": "EUR",
          "direction": "debit",
          "code": "NDDT",
          "bank_reference": "BANKREF001",
          "end_to_end_id": "INV-2026-001",
          "counterparty": {
            "name": "Stadtwerke Musterstadt",
            "iban": "DE02120300000000202051"
          },
          "remittance": "Strom November",
          "description": "/EREF/INV-2026-001/NAME/Stadtwerke Musterstadt/IBAN/DE02120300000000202051/REMI/USTD//Strom November/"
        },
        {
          "booking_date": "2026-11-11",
          "value_date": "2026-11-11",
          "amount": 1000,
          "currency": "EUR",
          "direction": "credit",
          "code": "NTRF",
          "customer_reference": "INV7788",
          "bank_reference": "BANKREF002",
          "end_to_end_id": "E2E-7788",
          "counterparty": {
            "name": "ACME GmbH",
            "iban": "DE75512108001245126199"
          },
          "remittance": "Invoice 7788",
          "description": "…"
        }
      ],
      "statement_id": "STMT20261111",
      "sequence": "00221/001",
      "opening_balance": {
        "amount": 1250,
        "currency": "EUR",
        "date": "2026-11-10",
        "type": "final"
      },
      "closing_balance": {
        "amount": 2204.5,
        "currency": "EUR",
        "date": "2026-11-11",
        "type": "final"
      },
      "period": {
        "from": "2026-11-10",
        "to": "2026-11-11"
      },
      "checks": {
        "transactions": 2,
        "credits": {
          "count": 1,
          "amount": 1000
        },
        "debits": {
          "count": 1,
          "amount": 45.5
        },
        "net": 954.5,
        "computed_closing": 2204.5,
        "balance_ok": true
      }
    }
  ],
  "warnings": []
}
```

## Use cases

- Import statements of foreign bank accounts into an ERP or accounting tool
- Reconcile incoming payments by end-to-end ID or remittance text
- Convert camt.053 / MT940 to CSV for Excel during the MT → ISO 20022 transition
- Generate pain.001 payment batches for upload to a corporate bank portal

## FAQ

### Does it support my bank’s MT940 dialect?

The common field 86 layouts (German ?xx codes with SEPA keywords, slash codes used by Dutch and many European banks, free text) are recognised; unknown layouts keep the full text in description.

### Are statements stored?

No. Files are parsed in memory and nothing is kept after the response.

### Is the pain.001 file accepted by every bank?

It follows the ISO 20022 schema with SEPA rules when applicable; some banks require extra fields (e.g. specific charge bearer or service level), so test with your bank first.
