BAI2 Parser

Parse BAI2 bank statement files

1
Understanding BAI2 Bank Statements
TL;DR

BAI2 is the standard format for electronic bank statements in North America, used for corporate cash management and automated reconciliation.

What is BAI2?

BAI2 (Bank Administration Institute version 2) is the standard file format for electronic delivery of bank statement information in North America. Published in 1986, it provides a structured, machine-readable format that allows corporations to receive account balances, transaction details, and summary information from their banks for automated cash management and reconciliation.

Before BAI2, corporations relied on paper statements or proprietary electronic formats that varied from bank to bank. BAI2 standardized the exchange, enabling treasury management systems (TMS) and enterprise resource planning (ERP) systems to automatically ingest bank data regardless of which bank produced it.

Despite its age, BAI2 remains the dominant format for corporate bank reporting in the United States and Canada. Most major banks offer BAI2 file delivery through their cash management portals, SFTP, or SWIFT FileAct channels.

File Structure

A BAI2 file is a comma-delimited text file organized in a strict hierarchy. Each record starts with a two-digit record type code, and fields are separated by commas with a forward slash (/) as the record terminator.

BAI2 File Record Type Hierarchy A hierarchical tree diagram showing the six BAI2 record types nested from File Header (01) at the top, through Group Header (02), Account Identifier (03), Transaction Detail (16) with optional Continuation (88), Account Trailer (49), Group Trailer (98), and File Trailer (99) at the bottom. 01 File Header Sender, receiver, file date 02 Group Header Bank ID, group status, as-of date 03 Account Identifier Account number, balances (ledger, available), summary codes 16 Transaction Detail Type code, amount, funds type, bank ref, customer ref, text 88 Continuation (Optional) 49 Account Trailer — control totals 98 Group Trailer 99 File Trailer

Transaction Type Codes

The three-digit type code in each Transaction Detail record (16) identifies the nature of the transaction. The first digit indicates the general category (1=credit summary, 2=lockbox, 3=concentration, 4=ACH, 5=check, etc.), and the remaining digits provide specifics.

Type CodeDescriptionCategory
015Lockbox DepositCredit Summary
108Credit item in depositDeposits
165ACH Credit ReceivedACH
175ACH Credit ReturnACH
275Check PaidChecks
295Check ReturnedChecks
395ZBA Credit (Concentration)Concentration
495Incoming Wire TransferWires
555Wire Transfer OutWires
698ACH SettlementSettlement

How BAI2 Parsing Works

Parsing a BAI2 file requires processing records sequentially while maintaining the hierarchical context:

  1. Read the File Header (01) to identify the sender bank and file creation date
  2. Read each Group Header (02) which represents a single bank relationship or branch
  3. Within each group, read Account Identifiers (03) that provide the account number, currency, and summary balances (opening ledger, closing ledger, available)
  4. Process Transaction Details (16) within each account, applying the type code to categorize each transaction as a debit or credit
  5. Handle Continuation records (88) by appending their content to the preceding record
  6. Validate control totals at each trailer level (49, 98, 99) to ensure file integrity

Common Use Cases

  • Cash positioning: Corporate treasurers use BAI2 files to determine available balances across dozens of bank accounts each morning
  • Automated reconciliation: ERP systems (SAP, Oracle) match BAI2 transactions against accounts receivable and accounts payable records
  • Lockbox processing: BAI2 delivers lockbox deposit details, enabling automatic application of customer payments to open invoices
  • Bank fee analysis: Transaction type codes help identify and categorize bank charges for fee benchmarking
  • Audit trail: BAI2 files provide a standardized record of all bank activity for internal and external audit
  • Multi-bank aggregation: Treasury management systems consolidate BAI2 files from multiple banks into a unified cash position view

Try These Examples

Valid BAI2 File Valid

A valid BAI2 file with File Header (01), Group Header (02), Account Identifier (03) showing opening ledger balance of $1,500.00 with lockbox deposit $250.00 and total credits $1,250.00, two Transaction Detail records (16) — an ACH credit of $50.00 and a check paid of $35.00 — Account Trailer (49) with control total matching transaction sum, Group Trailer (98), and File Trailer (99).

01,091000019,0123456789,240315,1200,001,80,2,2/ 02,091000019,0123456789,1,240315,1200,,2/ 03,0123456789012,,010,150000,,,015,25000,,040,125000,/ 16,165,5000,0,240314,,PAYROLL DEPOSIT,/ 16,275,3500,0,240314,,CHECK 001234,/ 49,8500,2/ 98,8500,1,2/ 99,8500,1,2/
Invalid BAI2 File (Totals Mismatch) Invalid

The Account Trailer (49) shows a control total of $9,999.99, which does not match the sum of the opening balance ($1,500.00) and the single transaction ($50.00). BAI2 parsers validate that trailer totals reconcile with the sum of header balances and transaction amounts.

01,091000019,0123456789,240315,1200,001,80,2,2/ 02,091000019,0123456789,1,240315,1200,,2/ 03,0123456789012,,010,150000,,,015,25000,,/ 16,165,5000,0,240314,,PAYROLL DEPOSIT,/ 49,999999,1/ 98,999999,1,1/ 99,999999,1,1/