BAI2 Parser
Parse BAI2 bank statement files
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.
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 Code | Description | Category |
|---|---|---|
| 015 | Lockbox Deposit | Credit Summary |
| 108 | Credit item in deposit | Deposits |
| 165 | ACH Credit Received | ACH |
| 175 | ACH Credit Return | ACH |
| 275 | Check Paid | Checks |
| 295 | Check Returned | Checks |
| 395 | ZBA Credit (Concentration) | Concentration |
| 495 | Incoming Wire Transfer | Wires |
| 555 | Wire Transfer Out | Wires |
| 698 | ACH Settlement | Settlement |
How BAI2 Parsing Works
Parsing a BAI2 file requires processing records sequentially while maintaining the hierarchical context:
- Read the File Header (01) to identify the sender bank and file creation date
- Read each Group Header (02) which represents a single bank relationship or branch
- Within each group, read Account Identifiers (03) that provide the account number, currency, and summary balances (opening ledger, closing ledger, available)
- Process Transaction Details (16) within each account, applying the type code to categorize each transaction as a debit or credit
- Handle Continuation records (88) by appending their content to the preceding record
- 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
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/ 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/