# Pay over Bre-B

> Pay a Bre-B key in seconds, at any hour, resolving the key first to send the recipient's exact data.

[Production]

A withdrawal goes out over Bre-B when you send `breBKey` in `destination` and the amount is within the Bre-B maximum. It arrives in seconds, any day at any hour.

| 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) |
| Initial status: Bre-B `CREATED`; ACH and manual `IN_PROGRESS`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |

## 1. Resolve the key

A key (mobile number, e-mail, document, merchant code or alphanumeric) points to an account. Resolving it gives you its holder and everything `destination` needs, `breBKey` included:

**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)

**GET /v1/bre-b/keys/\{key}**

```bash
curl https://sandbox.zulu.com.co/v1/bre-b/keys/%40luisgomez \
  -H "Authorization: Bearer $ZULU_ACCESS_TOKEN" \
  -H "X-API-Key: $ZULU_API_KEY"
```

```javascript
const response = await fetch('https://sandbox.zulu.com.co/v1/bre-b/keys/%40luisgomez', {
  method: 'GET',
  headers: {
    Authorization: `Bearer ${process.env.ZULU_ACCESS_TOKEN}`,
    'X-API-Key': process.env.ZULU_API_KEY,
  },
});

console.log(response.status, await response.json());
```

```python
import os

import requests

response = requests.get(
    "https://sandbox.zulu.com.co/v1/bre-b/keys/%40luisgomez",
    headers={
        "Authorization": f"Bearer {os.environ['ZULU_ACCESS_TOKEN']}",
        "X-API-Key": os.environ["ZULU_API_KEY"],
    },
    timeout=30,
)
print(response.status_code, response.json())
```

**Response 200**

```json
{
  "key": "@luisgomez",
  "keyType": "ALPHA",
  "status": "ACTIVE",
  "fullName": "Santiago Vargas",
  "entityType": "person",
  "documentType": "CC",
  "documentNumber": "1383497382",
  "bankCode": "0032",
  "bankName": "Banco Caja Social Bcsc",
  "accountType": "ahorros",
  "accountNumber": "0009641366",
  "bankOrgId": "860007335",
  "bankCamera": "TFY"
}
```

Show `fullName` to the payer before confirming: it is how you avoid paying the wrong key. Only an `ACTIVE` or `ACTIVE_BY_CLIENT` key receives payments.

> **Key resolution is a preview**
>
> `GET /v1/bre-b/keys/{key}` exists only in the sandbox today. In production, the Bre-B payout works the same, but you obtain the four `breBKey` fields (`key`, `keyType`, `bankOrgId`, `bankCamera`) on your own.

## 2. Send the withdrawal

Build `destination` from the resolution: the holder's document and name, the account the key points to in `bankAccount` and the four `breBKey` fields.

**POST /v1/transfer**

```bash
curl https://sandbox.zulu.com.co/v1/transfer \
  -H "Authorization: Bearer $ZULU_ACCESS_TOKEN" \
  -H "X-API-Key: $ZULU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "amount": 50000,
  "destination": {
    "entityType": "person",
    "documentType": "CC",
    "documentNumber": "1020304050",
    "firstName": "Luis",
    "lastName": "Gómez",
    "bankAccount": {
      "bankCode": "0007",
      "accountType": "ahorros",
      "accountNumber": "0012345678"
    },
    "breBKey": {
      "key": "@luisgomez",
      "keyType": "ALPHA",
      "bankOrgId": "890903938",
      "bankCamera": "TFY"
    }
  }
}'
```

```javascript
const response = await fetch('https://sandbox.zulu.com.co/v1/transfer', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.ZULU_ACCESS_TOKEN}`,
    'X-API-Key': process.env.ZULU_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "amount": 50000,
    "destination": {
      "entityType": "person",
      "documentType": "CC",
      "documentNumber": "1020304050",
      "firstName": "Luis",
      "lastName": "Gómez",
      "bankAccount": {
        "bankCode": "0007",
        "accountType": "ahorros",
        "accountNumber": "0012345678"
      },
      "breBKey": {
        "key": "@luisgomez",
        "keyType": "ALPHA",
        "bankOrgId": "890903938",
        "bankCamera": "TFY"
      }
    }
  }),
});

console.log(response.status, await response.json());
```

```python
import os

import requests

response = requests.post(
    "https://sandbox.zulu.com.co/v1/transfer",
    headers={
        "Authorization": f"Bearer {os.environ['ZULU_ACCESS_TOKEN']}",
        "X-API-Key": os.environ["ZULU_API_KEY"],
    },
    json={
        "amount": 50000,
        "destination": {
            "entityType": "person",
            "documentType": "CC",
            "documentNumber": "1020304050",
            "firstName": "Luis",
            "lastName": "Gómez",
            "bankAccount": {
                "bankCode": "0007",
                "accountType": "ahorros",
                "accountNumber": "0012345678",
            },
            "breBKey": {
                "key": "@luisgomez",
                "keyType": "ALPHA",
                "bankOrgId": "890903938",
                "bankCamera": "TFY",
            },
        },
    },
    timeout=30,
)
print(response.status_code, response.json())
```

**Response 201**

```json
{
  "transactionId": "SBX-OR-NPTRFI2611243HWD8T-6P",
  "status": "CREATED",
  "method": "BRE_B"
}
```

## When Bre-B does not go out

If the Bre-B transfer fails, the withdrawal is not lost: it is left for manual payment and the response is `{status: CREATED, method: MANUAL}`. Above the Bre-B maximum, zulu evaluates online ACH and manual payment.

| Field | Value | Effect | Operations |
| --- | --- | --- | --- |
| `destination.bankAccount.accountNumber` | `0000000001` | The withdrawal goes out by ACH (`IN_PROGRESS`), reaches `SENT` and ends `REJECTED`; the debit is reversed and a webhook is sent for each change. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md), [`getTransaction`](https://developers.zulu.com.co/en/reference/get-transaction.md), [`advanceTransaction`](https://developers.zulu.com.co/en/reference/advance-transaction.md) |
| `destination.bankAccount.accountNumber` | `0000000002` | The ACH dispatch does not queue: the withdrawal continues as a manual payment and answers `{status: IN_PROGRESS, method: MANUAL}`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| `destination.breBKey.key` | `@failbreb` | The Bre-B transfer fails: the withdrawal is left for manual payment and answers `{status: CREATED, method: MANUAL}`, as in production. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| `destination.documentNumber` | `1111111111` | The beneficiary is registered but not verified: 422 `the beneficiary with document "1111111111" is not verified`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| `destination.documentNumber` | `2222222222` | The beneficiary is already registered as "Ana Pérez". A name sharing a word (regardless of accents, case or order) passes; any other answers 422 `the name does not match the beneficiary registered with document "2222222222"`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| `destination.bankAccount.bankCode` | `9999` | The bank is not in the catalog: 422 `bank with code "9999" is not supported`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |

With key `@failbreb` you trigger the manual fallback in the sandbox; with `@notfound` and `@bloqueada`, the resolution's cases.

## Resolution errors

| HTTP | error | cause | Description |
| --- | --- | --- | --- |
| 404 | `NotFoundApiError` | `bre-b key "%s" not found` | The key does not exist (in your workspace, or in the Bre-B directory when resolving it). Test data: `@notfound`. |
