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

# Bradesco as a data source

> Bring the statement entries and balances of your Bradesco business accounts to Nekt.

Bradesco is one of Brazil's largest banks. This connector uses Bradesco's Balance and Statement API ("Saldo e extrato") to bring your company's accounts to the Catalog: every posted statement entry, the balance at the end of each day with movement, a daily snapshot of the account balances (available balance, total balance and investments), and the entries of the current day and the scheduled ones. It is meant for bank reconciliation and cash management.

> [!NOTE]
>
> The connector only reads data. It never creates, changes or pays anything in Bradesco.

## Prerequisites

Bradesco gives API access to the company itself, so your team prepares the access in the [Bradesco Developers portal](https://developers.bradesco.com.br) before creating the source.

* **A Bradesco business (PJ) account**, checking or savings.
* **A subscription to the "Saldo e extrato" (Balance and statement) product** in the portal, for the environment you will use: Sandbox (approved at once) or Production (approved in up to 48 hours).
* **An application with a credential** for that subscription. When you request the credential, the portal asks for the company's CNPJ, its legal name and the **public part of the company's A1 digital certificate**. The credential gives you a **Client ID** and a **Client Secret**.
* **The same A1 certificate** as a `.pfx` (or `.p12`) file with its password, usually the e-CNPJ. Bradesco requires it on every request (mutual TLS). In production it must be issued by a trusted certificate authority, be valid for 4 months to 3 years, and have the company name and CNPJ in its Common Name.
* **The accounts** to extract: branch (agência) and account number, without the check digits.

> [!WARNING]
>
> Bradesco issues one credential per CNPJ. If your group has accounts in several companies, create one source per company, each with that company's credential, certificate and accounts.

> [!WARNING]
>
> Credentials belong to one environment. Sandbox credentials do not work in production and vice versa. When you move to production, **create a new source** with the production credential; do not switch the environment of a source that already ran in sandbox. When you renew the certificate, request the credential again in the portal (operation "Certificate renewal") and upload the new certificate in the source.

## Configuring Bradesco as a Source

In the [Sources](https://app.nekt.ai/sources) tab, click on the "Add source" button located on the top right of your screen. Then, select the Bradesco option from the list of connectors.

Click **Next** and you'll be prompted to add your access.

### 1. Add account access

The following configurations are available:

* **Environment**: `production` for your real accounts, or `sandbox` to test with Bradesco's test account.
* **Client ID** and **Client Secret**: the credential of your application in the Bradesco Developers portal, for the selected environment.
* **Certificate file (.pfx / .p12)**: the company's A1 certificate file, uploaded exactly as issued. It must be the certificate whose public part you attached to the credential.
* **Certificate password**: the password of the `.pfx` file.
* **Accounts**: the accounts to extract, one per item, written as `BRANCH/ACCOUNT` with digits only and without the check digits. For example, branch 3995 and account 75557-5 become `3995/75557`. For a savings account, add `/CP` at the end (`3995/75557/CP`). All accounts must belong to the company (CNPJ) of the credential.
* **Start date**: the first statement day to extract. Bradesco provides up to ten years of statement; an older date starts at the oldest day available.
* **Lookback days** (advanced, default 5): how many days before the last day read each run reads again, to catch entries the bank posts late or with a retroactive date. The minimum is 5, so a weekend plus a holiday is always covered.
* **Include Invest Fácil in the balance** (advanced, default off): when on, Bradesco returns the balance unified with Invest Fácil; when off, the checking account balance only.

If you prefer to provide the certificate as text instead of uploading the `.pfx` file, use the advanced settings **Client certificate (PEM)** and **Private key (PEM)**. They are used only when no `.pfx` file is uploaded.

Once you're done, click **Next**.

### 2. Select streams

Choose which data streams you want to sync. For faster extractions, select only the streams that are relevant to your analysis.

> Tip: The stream can be found more easily by typing its name.

Select the streams and click **Next**.

### 3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.

* **Layer**: choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
* **Folder**: a folder can be created inside the selected layer to group all tables being created from this new data source.
* **Table name**: we suggest a name, but feel free to customize it. You have the option to add a **prefix** to all tables at once and make this process faster!
* **Sync Type**: you can choose between INCREMENTAL and FULL\_TABLE.
  * Incremental: every time the extraction happens, we'll get only the new data, which is good if, for example, you want to keep every record ever fetched.
  * Full table: every time the extraction happens, we'll get the current state of the data, which is good if, for example, you don't want to have deleted data in your catalog.

> [!WARNING]
>
> Keep **Balances** as INCREMENTAL. It stores one balance snapshot per run, and a full table sync replaces all earlier snapshots with the latest one.

Once you are done configuring, click **Next**.

### 4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters.

To define your [Trigger](https://docs.nekt.com/runs/scheduling-and-triggers.md), consider how often you want data to be extracted from this source. A daily trigger is enough for reconciliation; run it more often if you follow the balance or today's entries during the day.

Optionally, you can define some additional settings:

* Configure Delta Log Retention and determine for how long we should store old states of this table as it gets updated. Read more about this resource [here](https://docs.nekt.com/get-started/core-concepts/resource-control).
* Determine when to execute an **Additional [Full Sync](https://docs.nekt.com/get-started/core-concepts/types-of-sync#additional-full-sync)**. This will complement the incremental data extractions, ensuring that your data is completely synchronized with your source every once in a while. Do not use it for **Balances**: Bradesco only returns the current balance, so a full sync would drop the earlier snapshots.

Once you are ready, click **Next** to finalize the setup.

### 5. Check your new source

You can view your new source on the [Sources](https://app.nekt.ai/sources) page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.

> [!WARNING]
>
> For you to be able to see it on your [Catalog](https://app.nekt.ai/catalog), you need at least one successful source run.

# Streams and Fields

## Available streams

| Stream | Slug | Description |
| - | - | - |
| Statement Entries | `statement_entries` | Posted entries of the statement, with date, amount, direction, description and the balance after each entry, up to yesterday. |
| Daily Balances | `daily_balances` | The balance at the end of each day with movement, with the day's totals. |
| Balances | `balances` | A snapshot of the account balances on every run: one row per balance line (available, total, investments). |
| Pending Entries | `pending_entries` | Entries Bradesco does not list in the statement history yet: the latest closed day, today's entries and the scheduled (future) ones, as of the last run. |

Each run reads the statement from a few days before the last day read (see **Lookback days**) up to yesterday, in Brasília time. Bradesco lists the latest entries separately from the statement history for a day or two (longer over weekends and holidays): until an entry reaches the history it is in **Pending Entries** (status `recent` or `today`), and from then on it is in **Statement Entries**. For a short time the same entry can appear in both tables. Bradesco gives a statement entry no identifier of its own, so Nekt creates `entry_key` from the entry's account, date, document number, transaction code, sign and amount. Two entries identical in all of these on the same day (two equal fees, for example) are told apart by `occurrence`.

> [accordion] Statement Entries
>
> Posted entries of the account statement. Incremental by `entry_date`.
>
> **Identification:**
>
> * `entry_key` - Identifier created by Nekt for the entry (primary key)
> * `occurrence` - Position of the entry among identical entries of the same day
> * `branch_number` / `account_number` - The account, without check digits
> * `account_type` - `cc` (checking) or `cp` (savings)
> * `entry_date` - Entry date (replication key)
> * `served_outside_period` - `true` when Bradesco returned the entry in the statement of a later month than its date (a late posting); such entries are identified apart, so they never merge with an identical entry of the same date
>
> **Entry:**
>
> * `amount` - Amount in BRL, always positive
> * `sign` - `+` for credit, `-` for debit
> * `signed_amount` - Amount with its direction: positive for credits, negative for debits
> * `balance_after_entry` - Account balance right after the entry, negative when overdrawn
> * `transaction_code` - Bank code of the kind of entry (for example 03212 for a Pix transfer)
> * `short_description` / `full_description` - Description of the entry
> * `complementary_text` - Free text added by the product that made the entry (for example the payer of a Pix)
> * `document_number` - Document number of the entry
> * `entry_type_code` - Line type as sent by the bank (02 for posted)
> * `subcode_indicator` / `balance_sign` - Sub-code indicator and sign of the balance after the entry
>
> **Account:**
>
> * `account_check_digit` / `account_holder_name` - Check digit and holder of the account
>
> **Raw data:**
>
> * `raw_payload` - The entry exactly as returned by the bank (JSON)

> [accordion] Daily Balances
>
> One row per account and day with at least one posted entry. Incremental by `balance_date`. Days without movement have no row: the balance is the one of the previous row.
>
> * `branch_number` / `account_number` / `account_type` - The account
> * `balance_date` - Day the balance refers to (replication key)
> * `end_of_day_balance` - Balance after the last entry of the day in BRL, negative when overdrawn
> * `entry_count` - Number of posted entries on the day
> * `total_credits` / `total_debits` - Sum of the day's credits and debits (both positive)
> * `running_balance_consistent` - `true` when each balance of the day equals the previous balance plus the entry amount; `false` flags a day to check against the bank statement
> * `account_check_digit` / `account_holder_name` - Check digit and holder of the account

> [accordion] Balances
>
> One snapshot of the balance returned by Bradesco on every run, with one row per balance line. Each run is its own snapshot, so when the source runs several times a day, use the latest `extracted_at` of each `snapshot_date` for one figure per day. Incremental by `snapshot_date`.
>
> * `snapshot_date` - Day of the snapshot (replication key)
> * `extracted_at` - When Nekt read the balance; the same for every line of a run
> * `branch_number` / `account_number` / `account_type` - The account
> * `balance_section` - `checking_account`, `savings_account` or `investments`
> * `product_code` / `product_name` / `product_short_name` - The balance line, for example 999 "DISPONIVEL", 995 "TOTAL DE RECURSOS", 984 "SALDO TOTAL", 19 "INVEST FACIL BRADESCO"
> * `amount` / `sign` / `signed_amount` - The balance in BRL, its sign, and the balance with its sign
> * `balance_identifier` - 0 plain balance, 1 with automatic redemption, 2 without automatic redemption, 3 in grace period
> * `redemption_composition` - Marker of how the balance takes part in the automatic redemption
> * `account_status` / `automatic_coverage_status` / `account_type_identifier` / `account_ledger_code` - Account details as sent by the bank
> * `return_code` - Bank return code of the section (00 success)
> * `occurrence` - Position among lines with the same product code
> * `account_check_digit` / `account_holder_name` - Check digit and holder of the account
> * `raw_payload` - The balance line exactly as returned by the bank (JSON)

> [accordion] Pending Entries
>
> Entries not in the statement history yet: the latest closed day, the current day and scheduled (future) entries. The table is replaced on every run, so it always shows what is pending now.
>
> * `entry_key` / `occurrence` - Identifier created by Nekt for the entry
> * `branch_number` / `account_number` / `account_type` - The account
> * `pending_status` - `recent` (latest closed day, not in the statement history yet), `today` (entry of the current day) or `future` (scheduled)
> * `entry_date` - Date of the entry, or the date it is scheduled for
> * `extracted_at` - When Nekt read the pending entries
> * Plus the same entry fields as Statement Entries

## Limitations

* **Payment returns and proofs of payment (comprovantes)** are not part of the Balance and Statement API. Bradesco sends them by webhook from its billing and Pix products, which this connector does not cover.
* Bradesco answers at most one year and 5,000 entries per request; the connector reads month by month and splits busier periods on its own. If a single day cannot be read completely, that table is not updated in the run and the run log shows a message, instead of loading part of the day.
* When Bradesco answers with an error code, the affected table is not updated in that run and the run log shows Bradesco's code and message, so no period is skipped silently; the other tables are still loaded. Send that message to Nekt support if it appears.
* If Bradesco returns an entry dated outside the period requested (a late posting), it is loaded with its own date and the run log says how many there were. Entries from an earlier month are marked with `served_outside_period`.
* Nekt checks that the balances of the statement add up from one period to the next. When they do not, the run log shows a warning with both balances and the extraction continues: this is expected with **Include Invest Fácil in the balance** on, or right after a weekend at the start of a month; otherwise compare that period with your bank statement. The table is only left un-updated when the difference comes right after a day for which Bradesco returned exactly 999 lines (the most its count field can show), because that day's list may be incomplete; send that message to Nekt support if it appears. The check does not run in sandbox, whose test data does not add up.
* Bradesco keeps ten years of statement. The balance endpoint only returns today's balance, so **Balances** starts on the day of the first run; for earlier days use **Daily Balances**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.