# Payouts and method selection

> The anatomy of POST /v1/transfer, how zulu picks between Bre-B, ACH and manual payment, the order it validates in and what to do with each response.

[Production]

**POST** `/v1/transfer` — Withdraw COP balance · [Production] · [See the reference](https://developers.zulu.com.co/en/reference/create-transfer.md)

## The request

**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": 150000,
  "note": "Pago factura 1234",
  "destination": {
    "entityType": "person",
    "documentType": "CC",
    "documentNumber": "1020304050",
    "firstName": "Luis",
    "lastName": "Gómez",
    "bankAccount": {
      "bankCode": "0007",
      "accountType": "ahorros",
      "accountNumber": "0012345678"
    }
  }
}'
```

```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": 150000,
    "note": "Pago factura 1234",
    "destination": {
      "entityType": "person",
      "documentType": "CC",
      "documentNumber": "1020304050",
      "firstName": "Luis",
      "lastName": "Gómez",
      "bankAccount": {
        "bankCode": "0007",
        "accountType": "ahorros",
        "accountNumber": "0012345678"
      }
    }
  }),
});

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": 150000,
        "note": "Pago factura 1234",
        "destination": {
            "entityType": "person",
            "documentType": "CC",
            "documentNumber": "1020304050",
            "firstName": "Luis",
            "lastName": "Gómez",
            "bankAccount": {
                "bankCode": "0007",
                "accountType": "ahorros",
                "accountNumber": "0012345678",
            },
        },
    },
    timeout=30,
)
print(response.status_code, response.json())
```

- **`amount`**: in COP, as a JSON number, up to 2 decimals. Only a whole-peso amount can go out by online ACH.
- **`note`**: a free comment kept on the withdrawal.
- **`destination`**: the beneficiary (a person with names, or a company with `companyName`) and their account. With `breBKey`, the withdrawal can go out over Bre-B.

The balance holder comes from the access token: you never send it in the body.

## How the method is picked

1. If you send `breBKey` and the amount is within the Bre-B maximum, it goes out by **`BRE_B`**.
2. Otherwise it goes out by online **`ACH`** if the user may disperse by ACH, the bank (`bankCode`) is in the catalog, the account is savings or checking, the amount is in whole pesos and it fits today's caps.
3. In any other case, or if the online transfer could not go out, it goes **`MANUAL`**.

| 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) |
| Online ACH only with whole pesos: an amount with decimals (for example 150000.50) goes `MANUAL`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| Online ACH requires `canUseAchDispersion`, a bank with a 4-digit ACH code, a savings or checking account, up to 250,000,000 COP and room in the daily caps (count and sum). If anything fails, or the dispatch does not queue, the withdrawal goes `MANUAL`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| Initial status: Bre-B `CREATED`; ACH and manual `IN_PROGRESS`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |

## Validation order

zulu validates in this order and answers the first failure, recording nothing:

| Rule | Operations |
| --- | --- |
| A withdrawal amount is rounded to cents (2 decimals), like production's `round2`. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| Dispersion fee = `round(fixed + amount × rate / 100)`. The balance must cover amount + fee, and that total is what `insufficient COP balance to withdraw` shows. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |
| Validation order: verified user (403) → origin entity (422) → verified beneficiary and name (422) → method → balance with the fee (422) → COP account (422) → bank and account type (422) → order and debit → dispatch. The first failure answers; nothing is recorded. | [`createTransfer`](https://developers.zulu.com.co/en/reference/create-transfer.md) |

## The response

**Response 201**

```json
{
  "transactionId": "SBX-OR-NPTRFI261124K7Q2M9-X4",
  "status": "IN_PROGRESS",
  "method": "ACH"
}
```

Keep `transactionId`: with it you read the withdrawal and recognize it in the `TRANSACTIONS` webhook.

## Statuses

| Status        | What it means                                        |
| ------------- | ---------------------------------------------------- |
| `CREATED`     | Withdrawal created; the Bre-B transfer is in flight. |
| `IN_PROGRESS` | Being paid (ACH or manual).                          |
| `SENT`        | The money was sent to the beneficiary's bank.        |
| `COMPLETED`   | Withdrawal completed.                                |
| `REJECTED`    | Withdrawal rejected; `rejectionReason` says why.     |

| Rule | Operations |
| --- | --- |
| 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) |
| A `REJECTED` withdrawal returns the debit to the balance in the sandbox. In production operations performs the reversal. | [`getTransaction`](https://developers.zulu.com.co/en/reference/get-transaction.md), [`advanceTransaction`](https://developers.zulu.com.co/en/reference/advance-transaction.md) |

## Retries without duplicates

Every call creates a new withdrawal. If you get a 5xx or a timeout, do not retry until you know whether the withdrawal was created:

- **In production**, confirm the withdrawal in zulu's customer portal (or with the zulu team) before sending it again: the API read is still [Sandbox · coming soon].
- **In the sandbox**, look it up with `GET /v1/transactions?search=…` (your `note` or the beneficiary's document, bounded to today), or send `Idempotency-Key` and retry with the same key.

## Errors

| HTTP | error | cause | Description |
| --- | --- | --- | --- |
| 400 | `BadRequestApiError` | `error in struct validation` | One or more fields fail their validation. `values` carries one message per field, keyed by its JSON path, naming the Go validator that failed. |
| 400 | `BadRequestApiError` | `invalid json body: %s` | The body is not valid JSON, or a field has the wrong type (a string where a number goes, for example). Answered before the fields are validated. |
| 403 | `ForbiddenApiError` | `the user is not verified` | The user behind the credentials is not verified. In the sandbox: the workspace "verified" setting. |
| 409 | `ResourceConflictApiError` | `idempotency key "%s" is still being processed` | Another call with the same `Idempotency-Key` is still running. Retry in a few seconds to receive its response. |
| 422 | `UnprocessableEntityApiError` | `idempotency key "%s" was used with a different request` | The `Idempotency-Key` was already used in the last 24 hours with a different body or operation. Use a new key for every distinct operation. |
| 422 | `UnprocessableEntityApiError` | `the user does not have an entity to withdraw from` | The user has no entity to withdraw from. |
| 422 | `UnprocessableEntityApiError` | `the beneficiary with document "%s" is not verified` | The beneficiary registered with that document is not verified. Test data: document `1111111111`. |
| 422 | `UnprocessableEntityApiError` | `the name does not match the beneficiary registered with document "%s"` | The name sent shares no word with the registered beneficiary's (format, accents and order are tolerated). Test data: document `2222222222`, registered as "Ana Pérez". |
| 422 | `UnprocessableEntityApiError` | `insufficient COP balance to withdraw %.2f` | The COP balance does not cover the amount plus the dispersion fee. The figure in the message is that sum. |
| 422 | `UnprocessableEntityApiError` | `the user does not have a COP balance account` | The user has no COP balance account. In the sandbox: the workspace "COP account" setting. |
| 422 | `UnprocessableEntityApiError` | `bank with code "%s" is not supported` | The `bankCode` is not an available bank (see `GET /v1/banks`). Test data: `9999`. |
| 422 | `UnprocessableEntityApiError` | `account type "%s" is not supported` | Unsupported account type. Body validation stops it first (400), so in practice it does not appear. |
| 422 | `UnprocessableEntityApiError` | `document type "%s" is not supported` | The `documentType` of a beneficiary being registered is not in the catalog (`GET /v1/document-types`) or does not apply to its entity type (`NIT` is for companies). It is checked on registration, like the bank; an already registered beneficiary keeps its document. |
| 422 | `UnprocessableEntityApiError` | `destination field "%s" is not valid` | A value being registered can not be stored: the account must have 1 to 20 digits (spaces and hyphens are ignored), the document 1 to 20 characters, and names can not be blank (up to 80 characters; the company name up to 200). The message names the field. |
| 500 | `InternalServerApiError` | `unexpected error %s` | The withdrawal failed at an internal step. Check the withdrawal before retrying so the payment is not duplicated. |
