# Payroll over Bre-B

> Pay payroll to your employees' Bre-B keys in seconds, confirming each holder before paying, with a fallback that never leaves anyone unpaid.

[Production]

A company pays its employees twice a month. Every employee registered their Bre-B key (their mobile number, their e-mail or an alphanumeric one) and wants the payment within seconds, on a Saturday too.

## The flow

1. Resolve each employee's key and confirm the holder is them.
2. Send one withdrawal per employee with `breBKey`.
3. Follow the statuses: Bre-B completes in seconds; a manual fallback arrives at the next business cutoff.

## 1. Confirm each key

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

Compare the resolution's `documentNumber` and `fullName` with your employee records before paying. If they do not match, do not pay: the key may have changed hands.

> **Resolution in production**
>
> `GET /v1/bre-b/keys/{key}` is a preview. In production, paying the key works the same, but you get the `breBKey` data on your own (from the employee's record, for example).

## 2. One withdrawal per employee

```js title="pay-payroll.js"
export async function payEmployee(employee, resolution, token) {
  const response = await fetch('https://sandbox.zulu.com.co/v1/transfer', {
    method: 'POST',
    headers: { Authorization: `Bearer ${token}`, 'X-API-Key': process.env.ZULU_API_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({
      amount: employee.netPayCop,
      note: `Payroll ${employee.period}`,
      destination: {
        entityType: 'person',
        documentType: resolution.documentType,
        documentNumber: resolution.documentNumber,
        firstName: employee.firstName,
        lastName: employee.lastName,
        bankAccount: { bankCode: resolution.bankCode, accountType: resolution.accountType, accountNumber: resolution.accountNumber },
        breBKey: { key: resolution.key, keyType: resolution.keyType, bankOrgId: resolution.bankOrgId, bankCamera: resolution.bankCamera },
      },
    }),
  });

  return response.json(); // { transactionId, status, method }
}
```

Send the withdrawals one by one or in small groups, and honor `Retry-After` if you get a `429`.

## 3. Statuses and fallback

| Response                          | What it means                                                                                      |
| --------------------------------- | -------------------------------------------------------------------------------------------------- |
| `CREATED` + `BRE_B`               | In flight over Bre-B; completes in seconds.                                                        |
| `CREATED` + `MANUAL`              | Bre-B did not go out: zulu pays it through the traditional channel. The employee gets paid anyway. |
| `IN_PROGRESS` + `ACH` or `MANUAL` | The amount was above the Bre-B maximum and went out another way.                                   |

| 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) |
| Simulated timings: Bre-B `COMPLETED` after 3 s; ACH `SENT` after 30 s and `COMPLETED` after 60 s; manual `SENT` at the next 15:30 business cutoff and `COMPLETED` at 09:00 of the next business day (with Colombian holidays). `advanceTransaction` skips the wait. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md), [`listTransactions`](https://developers.zulu.com.co/en/reference/list-transactions.md), [`getTransaction`](https://developers.zulu.com.co/en/reference/get-transaction.md), [`advanceTransaction`](https://developers.zulu.com.co/en/reference/advance-transaction.md) |

## 4. Test it

In the sandbox, mix into your batch key `@failbreb` (manual fallback), an amount above the Bre-B maximum and document `1111111111` (unverified beneficiary), and check your system reports each case.
