# Supplier payments

> Pay your suppliers' invoices from your COP balance, with every payment's status in your system and without paying twice.

[Production]

A company pays its suppliers' approved invoices (companies with a NIT) every week from its zulu COP balance.

## The flow

1. Check balance and limits before the batch.
2. One withdrawal per invoice, with the supplier's NIT, their account and the invoice in `note`.
3. Store `transactionId` on the invoice and follow its status.
4. Reconcile: `COMPLETED` closes the invoice; `REJECTED` sends it back to review.

## 1. Before the batch

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

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

The balance must cover every amount plus its dispersion fee. The online ACH daily caps tell you how many payments will go out online; the rest will go `MANUAL`, with no error.

## 2. One withdrawal per invoice

```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": 2500000,
    "note": "FAC-PRV-8812",
    "destination": {
      "entityType": "company",
      "documentType": "NIT",
      "documentNumber": "900123456",
      "companyName": "Acme S.A.S.",
      "bankAccount": { "bankCode": "0051", "accountType": "corriente", "accountNumber": "4567890123" }
    }
  }'
```

- The NIT may go with or without its check digit.
- `companyName` must match the registered one if the supplier already exists.
- Send amounts in whole pesos so they can go out by online ACH.

## 3. Follow each payment

Store `transactionId` on the invoice. The `TRANSACTIONS` webhook tells you about every change; read the transaction for the detail:

**GET** `/v1/transactions/{transactionId}` — Get a transaction · [Sandbox · coming soon] · [See the reference](https://developers.zulu.com.co/en/reference/get-transaction.md)

| Status                | What to do with the invoice                                                                              |
| --------------------- | -------------------------------------------------------------------------------------------------------- |
| `IN_PROGRESS`, `SENT` | Payment in progress.                                                                                     |
| `COMPLETED`           | Paid.                                                                                                    |
| `REJECTED`            | Check `rejectionReason` and the bank details; the debit is reversed (in production, operations does it). |

## 4. Never pay twice

Never send a withdrawal again without knowing whether the previous one was created: read [Payouts and method selection](https://developers.zulu.com.co/en/docs/payout/transfers.md#retries-without-duplicates). If your system retries automatically, do it only in the sandbox with `Idempotency-Key` (preview).

| HTTP | error | cause | Description |
| --- | --- | --- | --- |
| 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 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` | `bank with code "%s" is not supported` | The `bankCode` is not an available bank (see `GET /v1/banks`). Test data: `9999`. |
| 500 | `InternalServerApiError` | `unexpected error %s` | The withdrawal failed at an internal step. Check the withdrawal before retrying so the payment is not duplicated. |
