# BAI2 & OFX/QFX Bank Statement to JSON & camt.053 Bridge (`bifrost-data/bai2-ofx-bank-statement-bridge`) Actor

Stateless, zero-retention corporate banking & accounting bridge: parse, audit, and convert BAI2 lockbox/cash-management files and OFX/QFX (SGML v1 & XML v2) bank or credit-card statements into normalized JSON and ISO 20022 camt.053.001.08 XML with Decimal control-total checks.

- **URL**: https://apify.com/bifrost-data/bai2-ofx-bank-statement-bridge.md
- **Developed by:** [SEOK HOON HONG](https://apify.com/bifrost-data) (community)
- **Categories:** Developer tools, Business, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.40 / 1,000 verified bai2 / ofx account statement bridges

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## BAI2 & OFX/QFX Bank Statement to JSON & ISO 20022 `camt.053` Bridge

> **10-Second Summary**: Convert legacy **US corporate `BAI2` cash-management/lockbox files (`01`–`99`)** and **`OFX 1.x / 2.x` & `QFX` bank or corporate card downloads** into **clean JSON, Excel/CSV rows, and ISO 20022 `camt.053.001.08` XML**—with automatic `Decimal` trailer control-total reconciliation.
>
> - **100% Zero-Retention RAM (`0` External Network Calls)**: Built for accounting teams, lockbox AR automation, NetSuite/QuickBooks imports, and Make/Zapier/n8n flows.
> - **Predictable Pay-Per-Event (`$8.00 / 1,000`)**: `$0.008` per verified account statement; corrupted or truncated files cost **$0.00**.

Stateless, **zero-retention (pure volatile RAM, 0-byte disk storage, 0 external HTTP calls)** corporate treasury and accounting statement parser, mathematical control-total auditor, and **ISO 20022 `camt.053.001.08`** converter for **ERP reconciliation (`SAP`, `NetSuite`, `Dynamics 365`, `QuickBooks`, `Xero`), workflow automation (`n8n`, `Make`, `Zapier`), and AI FinOps agents**.

### Why Corporate Treasury, FinOps & Accounting Teams Use This Actor

1. **Parse & Mathematically Audit Corporate `BAI2` Cash-Management Files (`X9.121` / `BTRS`)**:
   - Decodes full multi-group, multi-account `BAI2` transmissions (`01` File Header, `02` Group Header, `03` Account Summary Status, `16` Transaction Detail, `88` Continuation lines, `49` Account Trailer, `98` Group Trailer, `99` File Trailer).
   - Verifies exact `Decimal` **Account Control Totals (`49`)**, **Group Control Totals (`98`)**, **File Control Totals (`99`)**, physical record counts, and `Opening Ledger (010) + Credits - Debits == Closing Ledger (015)` math.
   - Maps standard BAI Type Codes (`115` Lockbox Deposit, `165` Preauthorized ACH Credit, `175` Check Deposit, `195` Incoming Wire, `275` Zero-Balance Credit, `455` Preauthorized ACH Debit, `475` Check Paid, `495` Outgoing Wire, `575` Zero-Balance Debit) and scales minor units automatically by ISO 4217 currency (`USD`/`EUR`/`GBP` 2 decimals, `JPY`/`KRW` 0 decimals, `KWD`/`BHD`/`OMR` 3 decimals).
2. **Normalize Both Legacy `OFX 1.x` (Unclosed SGML) & `OFX 2.x` (XML) / `QFX` Downloads**:
   - Handles both bank checking/savings (`<BANKMSGSRSV1>` / `<STMTRS>`) and corporate credit-card (`<CREDITCARDMSGSRSV1>` / `<CCSTMTRS>`) statements without tripping over unclosed SGML tags (`<TRNTYPE>DEBIT`) or timezone-suffixed timestamps (`20261123120000[-5:EST]`).
   - Detects duplicate `<FITID>` transaction IDs and blocks XXE/DTD XML entity bombs upfront.
3. **Instant `ISO 20022 camt.053.001.08` XML Treasury Upgrade**:
   - Converts every verified `BAI2` or `OFX/QFX` account statement into canonical `urn:iso:std:iso:20022:tech:xsd:camt.053.001.08` XML (`<BkToCstmrStmt>`, `<Bal>` `OPBD`/`CLBD`/`CLAV`, `<Ntry>` `CRDT`/`DBIT`, `<AddtlNtryInf>`) so North American bank feeds plug directly into modern ISO 20022 ERP pipelines alongside European `MT940` feeds.

### Explicit Deterministic Scope Boundary & Zero-Waste Billing

- **100% Deterministic Standard Math & Grammar**: Operates strictly on official `BAI2` (`01`–`99`) record definitions and the royalty-free [Open Financial Exchange Specification](https://www1.scotiaconnect.scotiabank.com/help/secured/en_US/Official_OFX_File_Specification_v202.pdf). Bank-specific free-text memos inside `88` continuation lines or `<MEMO>` tags are preserved verbatim in `raw_narrative` and `<AddtlNtryInf>`.
- **Zero Disk Retention & Optional Account Masking**: All payloads execute in `256 MB` volatile RAM (`0 Bytes` written to disk), with optional `mask_account_numbers` (`******4300`) for zero-PII AI agent pipelines.
- **Fair Pay-Per-Event Pricing**: Event `verified-bank-statement` (`$0.008` per verified account statement = `$8.00 / 1,000` statements). Unparseable syntax errors and duplicate statements are skipped at **$0.00**.

### Monorepo Deployment (`ballostark-wq/agent-pickaxe-factory`)

- Folder path in GitHub monorepo: `actors/act-012-bai2-ofx-statement-bridge`
- Automated CI gate: `python3 -m src --selftest` (`python3 src/main.py --selftest`) -> `apify push --force` via `.github/workflows/deploy-actors.yml` (`v1.2`).

### Sample Output Record

```json
{
  "source_format": "BAI2",
  "account_id": "8800194300",
  "currency": "USD",
  "opening_balance": "250000.00",
  "closing_balance": "264250.50",
  "total_credits": "18500.50",
  "total_debits": "4250.00",
  "transaction_count": 4,
  "control_totals_reconciled": true,
  "ledger_rollforward_reconciled": true,
  "is_valid": true,
  "validation_findings": []
}
```

### Transparent Pay-Per-Event Pricing

- **Actor Start**: `$0.00005`
- **Verified Bank / Card Statement (`verified-bank-statement`)**: `$0.008` per verified account statement (`$8.00` per 1,000 statements). Unparseable inputs cost `$0.00`.

### More Zero-Maintenance B2B Finance, Procurement & Security Tools by `bifrost-data`

| Actor | Business Use Case | Pricing |
| :--- | :--- | :--- |
| [ISO 20022 pain.001, pacs.008 & camt.053 JSON Bridge](https://apify.com/bifrost-data/iso20022-payment-statement-bridge) | Audit 2026 SEPA/Swiss SPS structured addresses, IBAN Mod-97 & convert MT940 to camt.053 | `$8.00 / 1k` |
| [cXML SAP Ariba & Coupa Order, ASN & Invoice JSON Bridge](https://apify.com/bifrost-data/cxml-ariba-coupa-procurement-bridge) | Convert SAP Ariba & Coupa cXML Purchase Orders, ASNs & Invoices to JSON or cXML XML | `$8.00 / 1k` |
| [SWIFT MT103 & MT202 to ISO 20022 CBPR+ pacs.008 Bridge](https://apify.com/bifrost-data/swift-mt103-cbpr-pacs008-wire-bridge) | Decode MT103 wire proofs, screen fake MT103 red flags, audit 32A/33B fees & emit pacs.008 | `$8.00 / 1k` |
| [Palo Alto PAN-OS, GlobalProtect & Cortex CVE Scraper](https://apify.com/bifrost-data/paloalto-panos-security-advisories-scraper) | Track PAN-OS CVSS v4/v3 scores, fixed hotfix releases, CISA KEV & Threat IDs | `$2.20 / 1k` |
| [Red Hat Security Advisories, RHSA, CSAF & CVE Scraper](https://apify.com/bifrost-data/redhat-security-advisories-scraper) | Export RHEL, OpenShift & Ansible RHSA errata, CSAF VEX states & backport fixes | `$2.20 / 1k` |

# Actor input Schema

## `format_mode` (type: `string`):

Choose 'auto_detect' to automatically route mixed BAI2 (01/02/03/16/49/88/98/99) and OFX/QFX (SGML v1.x or XML v2.x) payloads, or lock to 'bai2_only' / 'ofx_qfx_only'.

## `statements` (type: `array`):

Array of raw UTF-8 BAI2 transmission files or OFX/QFX bank/credit-card statement strings. Processed 100% in volatile RAM with 0-byte disk retention and 0 external network calls.

## `strict_control_totals` (type: `boolean`):

Verify exact Decimal equality on BAI2 Account (49), Group (98), and File (99) control totals and record counts, plus opening + net movement == closing ledger checks and OFX FITID uniqueness.

## `include_camt053_xml` (type: `boolean`):

Emit canonical urn:iso:std:iso:20022:tech:xsd:camt.053.001.08 BankToCustomerStatement XML for direct ERP / SAP / NetSuite / Treasury import alongside normalized JSON.

## `mask_account_numbers` (type: `boolean`):

When enabled, masks account identifiers in JSON and generated camt.053 XML (e.g., '\*\*\*\*\*\*4300') for zero-PII AI agent and analytics pipelines.

## `max_items` (type: `integer`):

Upper bound on verified account statement records emitted in a single run (1-1000).

## Actor input object example

```json
{
  "format_mode": "auto_detect",
  "statements": [
    "01,021000021,ACMETREASURY,261123,2359,0001,80,1,2/\n02,ACMETREASURY,021000021,1,261123,2359,USD,2/\n03,8800194300,USD,010,25000000,,,015,26425050,,,100,1850050,2,,400,425000,2,/\n16,195,1500000,0,FED20261123001,INV-2026-8801,INCOMING FEDWIRE FROM GLOBAL RETAIL CORP/\n88,ORIG: GLOBAL RETAIL CORP OBI: ENTERPRISE LICENSE Q4/\n16,115,350050,0,LBX2026112309,LOCKBOX-4412,LOCKBOX BATCH DEPOSIT CHICAGO/\n16,455,175000,0,ACH2026112377,AWS-NOV-2026,PREAUTHORIZED ACH DEBIT CLOUD INFRA/\n16,475,250000,0,CHK00009841,9841,CHECK PAID VENDOR SETTLEMENT/\n49,55975150,7/\n98,55975150,1,9/\n99,55975150,1,11/"
  ],
  "strict_control_totals": true,
  "include_camt053_xml": true,
  "mask_account_numbers": false,
  "max_items": 25
}
```

# Actor output Schema

## `statements` (type: `string`):

Schema-verified BAI2 and OFX/QFX account statements with exact Decimal control-total reconciliation, typed transactions, preserved narratives, and ISO 20022 camt.053.001.08 XML.

## `runMetrics` (type: `string`):

Execution telemetry including parsed accounts, malformed $0 skips, and PPE billing counts.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "statements": [
        "01,021000021,ACMETREASURY,261123,2359,0001,80,1,2/\n02,ACMETREASURY,021000021,1,261123,2359,USD,2/\n03,8800194300,USD,010,25000000,,,015,26425050,,,100,1850050,2,,400,425000,2,/\n16,195,1500000,0,FED20261123001,INV-2026-8801,INCOMING FEDWIRE FROM GLOBAL RETAIL CORP/\n88,ORIG: GLOBAL RETAIL CORP OBI: ENTERPRISE LICENSE Q4/\n16,115,350050,0,LBX2026112309,LOCKBOX-4412,LOCKBOX BATCH DEPOSIT CHICAGO/\n16,455,175000,0,ACH2026112377,AWS-NOV-2026,PREAUTHORIZED ACH DEBIT CLOUD INFRA/\n16,475,250000,0,CHK00009841,9841,CHECK PAID VENDOR SETTLEMENT/\n49,55975150,7/\n98,55975150,1,9/\n99,55975150,1,11/"
    ],
    "max_items": 25
};

// Run the Actor and wait for it to finish
const run = await client.actor("bifrost-data/bai2-ofx-bank-statement-bridge").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "statements": ["""01,021000021,ACMETREASURY,261123,2359,0001,80,1,2/
02,ACMETREASURY,021000021,1,261123,2359,USD,2/
03,8800194300,USD,010,25000000,,,015,26425050,,,100,1850050,2,,400,425000,2,/
16,195,1500000,0,FED20261123001,INV-2026-8801,INCOMING FEDWIRE FROM GLOBAL RETAIL CORP/
88,ORIG: GLOBAL RETAIL CORP OBI: ENTERPRISE LICENSE Q4/
16,115,350050,0,LBX2026112309,LOCKBOX-4412,LOCKBOX BATCH DEPOSIT CHICAGO/
16,455,175000,0,ACH2026112377,AWS-NOV-2026,PREAUTHORIZED ACH DEBIT CLOUD INFRA/
16,475,250000,0,CHK00009841,9841,CHECK PAID VENDOR SETTLEMENT/
49,55975150,7/
98,55975150,1,9/
99,55975150,1,11/"""],
    "max_items": 25,
}

# Run the Actor and wait for it to finish
run = client.actor("bifrost-data/bai2-ofx-bank-statement-bridge").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "statements": [
    "01,021000021,ACMETREASURY,261123,2359,0001,80,1,2/\\n02,ACMETREASURY,021000021,1,261123,2359,USD,2/\\n03,8800194300,USD,010,25000000,,,015,26425050,,,100,1850050,2,,400,425000,2,/\\n16,195,1500000,0,FED20261123001,INV-2026-8801,INCOMING FEDWIRE FROM GLOBAL RETAIL CORP/\\n88,ORIG: GLOBAL RETAIL CORP OBI: ENTERPRISE LICENSE Q4/\\n16,115,350050,0,LBX2026112309,LOCKBOX-4412,LOCKBOX BATCH DEPOSIT CHICAGO/\\n16,455,175000,0,ACH2026112377,AWS-NOV-2026,PREAUTHORIZED ACH DEBIT CLOUD INFRA/\\n16,475,250000,0,CHK00009841,9841,CHECK PAID VENDOR SETTLEMENT/\\n49,55975150,7/\\n98,55975150,1,9/\\n99,55975150,1,11/"
  ],
  "max_items": 25
}' |
apify call bifrost-data/bai2-ofx-bank-statement-bridge --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bifrost-data/bai2-ofx-bank-statement-bridge"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/t7fGl4kaLfkGlAOjY/builds/pm9EQfvPl90BxaIxb/openapi.json
