# Automatic Bre-B reconciliation

> Receive Bre-B transfers to your keys and assign each one to the right customer automatically, with no spreadsheets or bank statements.

[Sandbox · coming soon]

A company receives Bre-B transfers from many customers to its keys and wants every payment assigned to the right customer without reconciling by hand.

## The flow

1. You register keys per channel (`@acmebilling`, `@acmestore`) to split where the money comes from.
2. Every transfer creates a deposit with the key in `reference` and the `payer` (name and document).
3. The `DEPOSITS` webhook triggers your reconciliation: you match the payer's document against your customer base.
4. A daily sweep recovers anything that did not arrive by webhook.

## 1. Keys per channel

**POST** `/v1/bre-b/keys` — Create a Bre-B key · [Sandbox · coming soon] · [See the reference](https://developers.zulu.com.co/en/reference/create-bre-b-key.md)

Up to 5 keys per workspace. One key per channel tells you where every peso comes from without asking.

## 2. Identify the customer

A key carries no invoice reference: identify the customer by who pays. The deposit carries `payer.documentType` and `payer.documentNumber`:

```js title="reconcile.js"
export async function reconcile(deposit) {
  if (await ledger.has(deposit.depositId)) return; // retries carry the same deposit

  const customer = await customers.findByDocument(deposit.payer.documentType, deposit.payer.documentNumber);

  await ledger.insert({
    depositId: deposit.depositId,
    channel: deposit.reference, // the key that received it
    customerId: customer?.id ?? null,
    amount: deposit.amount,
    status: customer ? 'MATCHED' : 'NEEDS_REVIEW',
  });
}
```

What does not match goes to review: a third party paying for your customer, or a document you do not have yet.

## 3. Daily sweep

**GET** `/v1/deposits` — List deposits · [Sandbox · coming soon] · [See the reference](https://developers.zulu.com.co/en/reference/list-deposits.md)

```bash
curl "https://sandbox.zulu.com.co/v1/deposits?method=BRE_B&dateFrom=2026-11-24&dateTo=2026-11-24&size=100" \
  -H "Authorization: Bearer $ZULU_ACCESS_TOKEN" \
  -H "X-API-Key: $ZULU_API_KEY"
```

Process every page with the same function: since it drops `depositId`s already recorded, the sweep never duplicates.

## 4. Test it with many payers

**POST** `/v1/sandbox/bre-b/transfers/in` — Simulate an incoming Bre-B transfer · [Sandbox only] · [See the reference](https://developers.zulu.com.co/en/reference/simulate-bre-b-transfer-in.md)

Simulate transfers from different payers (one with a customer's document and one unknown) and check that some are assigned and others go to review.

| Rule | Operations |
| --- | --- |
| Bre-B accepts up to 12,110,000 COP per transfer: a withdrawal with `breBKey` and an amount up to 12,110,000 goes Bre-B; above it, ACH and manual payment are evaluated. | [`createQrCode`](https://developers.zulu.com.co/en/reference/create-qr-code.md), [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md), [`simulateBreBTransferIn`](https://developers.zulu.com.co/en/reference/simulate-bre-b-transfer-in.md) |
