> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lead.bank/llms.txt
> Use this file to discover all available pages before exploring further.

# Load Daily Reports

> Pick up the Core Balance and Core Transaction Reports from SFTP, load them into your systems, and check them against each other and the API.

This guide covers how to read the daily reports into your own systems so that new columns do not break your integration. For what's in each file, see [Daily Reports](https://docs.lead.bank/v2/guides/reports/overview.md).

The rules marked **must** are requirements. Lead does not support integrations that skip them.

## Before You Start

You need:

* an SFTP connection with the `bank-reports/` folder (see [SFTP Setup](https://docs.lead.bank/file-reference/sftp-setup.md))
* storage of your own for copies of each file
* a record of the files you've processed, keyed by full file name

## Pick Up New Files

1. List `bank-reports/core-balance/` and `bank-reports/core-transaction/`.
2. Keep only file names that match the full pattern, for example `DATE_core-balance_EPOCH_MS.csv`. Skip any file that does not match.
3. Skip any file name already in your record of processed files.
4. Copy each new file to your own storage. Files stay on SFTP for 180 days.
5. Read each file and load it, as described in the next sections.
6. Add the full file name to your record of processed files.

Take `DATE` and `EPOCH_MS` from the file name. Do not use the file's modified time on SFTP.

## Read the Columns

You must map columns by the header row, not by position. Lead can add a column without notice. Ignore columns you do not recognize, and do not depend on how many columns a file has.

Lead can also add a value to a column with a fixed list of values, such as a new `type`. Route a value you do not recognize to a default or flag it for review. Your integration must not reject a file because of an unrecognized value.

## Check the Files Against Each Other

For each Core Balance, the change in `posted_balance` from one bank day to the next equals the sum of `amount` in the next day's Core Transaction file for that `core_balance_id`.

For example, if a balance ends January 18 at `500000` and ends January 19 at `647500`, the January 19 Core Transaction file has rows for that balance that add up to `147500`.

If the two do not agree, check that you loaded the file with the highest `EPOCH_MS` for both reports. If they still do not agree, contact your Technical Account Manager (TAM).

## Look Up a Row in the API

Every row carries the ID of the matching record in the API:

* Look up `core_balance_id` with the [Core Balances API](https://docs.lead.bank/products/core-balance/overview.md) to get holds, the available balance, and the current posted balance.
* Look up `core_transaction_id` with the [Core Transactions API](https://docs.lead.bank/products/core-transaction/overview.md) to get the full transaction.
* Some `type` values, such as `ach`, have a matching payment record. The [type enum](https://docs.lead.bank/products/core-transaction/core-transaction-object.md#the-type-enum) lists the object for each value.

The API shows the ledger as it is now. A file shows the ledger at the cutoff. A balance from the API can differ from the file because of entries posted after the cutoff.

## Differences From the V1 Reports

While Lead delivers both the V1 and V2 reports, the same day can look different in each:

* **Cutoff:** V2 closes each bank day at a fixed cutoff. A transaction near the end of the day can be in a different day's file in V1 and V2.
* **Interest:** Interest that posts shortly after midnight is in the next bank day's V2 file.
* **Weekends and holidays:** V1 has no file on weekends or bank holidays. That activity is in the next business day's file. V2 has a file for every calendar day.
* **Online banking:** Online banking shows the live ledger, so its balances can differ from the V2 file at the cutoff.

V2 is the source of truth. Report any other difference to your TAM.

## If a File Is Replaced or Missing

If Lead needs to fix a file it already delivered, it sends a replacement: a new file for the same report and `DATE` with a higher `EPOCH_MS`. You pick it up like any other new file, because you track files by full name. Delete the rows you loaded for that report and `DATE`, then load the replacement. You must not merge the two files.

If a `DATE` is missing from your record of processed files, contact your TAM. A bank day with no transactions still gets a file with only the header row, so a missing file is not an empty day.
