Retrieve the BAI2 file via SFTP or bank portal download; confirm it begins with a Type-01 File Header record containing sender/receiver routing identifiers and a file creation date-time
Parse each record type in order: 01 File Header, 02 Group Header, 03 Account Identifier and Summary (captures account number, currency, and opening/closing ledger and available balances using three-digit BAI type codes), 16 Transaction Detail (captures amount, text, and bank reference), 49 Account Trailer, 98 Group Trailer, 99 File Trailer — validate that control totals in trailers match summed transaction amounts
Map each three-digit BAI transaction code (e.g., codes in the 100-series for credits, 400-series for debits) to your internal GL account and transaction category; maintain a code-to-category lookup table because banks extend the standard with proprietary codes
Upsert balance records keyed on account number plus value date; write each transaction detail row as an immutable ledger entry with the bank reference as an idempotency key to prevent duplicates on re-ingestion
Emit a reconciliation summary comparing the BAI closing ledger balance against the sum of your internal ledger entries for the same account and date; flag any delta for manual review
Schedule the ingest job after the bank's prior-day file delivery window (typically early morning) and retry with exponential backoff if the file has not yet arrived
Known gotchas
Type-88 continuation records extend a Type-16 transaction detail line beyond 80 characters; parsers that stop at the first delimiter after column 80 will silently truncate transaction text, corrupting reference data used for matching
Banks vary on whether the closing ledger balance (type code 015) or closing available balance (type code 045) appears in the Type-03 record — using the wrong balance type produces a cash position that includes float, overstating immediately available funds
Some banks deliver intraday BAI2 files that contain partial-day data alongside a separate prior-day file; loading both without deduplication on the bank-assigned transaction sequence number results in doubled entries
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp