# An importer buys USD

> Buy exactly the dollars you owe your supplier, with the rate locked and the cost in pesos known before you execute.

[Sandbox · coming soon]

An importer must pay 1,000 USD to a supplier abroad. It needs to know how many pesos that costs before committing, and to receive exactly those dollars in its USD balance.

## The flow

1. Check its COP balance.
2. Quote COP→USD with the term it needs.
3. Execute with `destinationAmount: 1000`: zulu computes the pesos, rounding up.
4. Follow the conversion until `COMPLETED`: the 1,000 USD land in its zulu USD balance.

## 1. Available balance

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

## 2. Quote

**GET /v1/quotes**

```bash
curl "https://sandbox.zulu.com.co/v1/quotes?from=COP&to=USD" \
  -H "Authorization: Bearer $ZULU_ACCESS_TOKEN" \
  -H "X-API-Key: $ZULU_API_KEY"
```

```javascript
const response = await fetch('https://sandbox.zulu.com.co/v1/quotes?from=COP&to=USD', {
  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/quotes?from=COP&to=USD",
    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())
```

At factor 3973.70, receiving 1,000 USD costs ceil(100,000 × 397,370 / 10⁴) = 3,973,700 COP. Show it to the user before executing; you have 30 seconds.

## 3. Execute by the destination amount

**POST /v1/transactions**

```bash
curl https://sandbox.zulu.com.co/v1/transactions \
  -H "Authorization: Bearer $ZULU_ACCESS_TOKEN" \
  -H "X-API-Key: $ZULU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "quote": "EQ-COPXUSDX-261124150405-SBX7Q",
  "destinationAmount": 1000
}'
```

```javascript
const response = await fetch('https://sandbox.zulu.com.co/v1/transactions', {
  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({
    "quote": "EQ-COPXUSDX-261124150405-SBX7Q",
    "destinationAmount": 1000
  }),
});

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

```python
import os

import requests

response = requests.post(
    "https://sandbox.zulu.com.co/v1/transactions",
    headers={
        "Authorization": f"Bearer {os.environ['ZULU_ACCESS_TOKEN']}",
        "X-API-Key": os.environ["ZULU_API_KEY"],
    },
    json={
        "quote": "EQ-COPXUSDX-261124150405-SBX7Q",
        "destinationAmount": 1000,
    },
    timeout=30,
)
print(response.status_code, response.json())
```

**Response 201**

```json
{
  "transactionId": "SBX-OR-NPTRFI261124W8D3QF-2K",
  "type": "FX",
  "status": "IN_PROGRESS",
  "originCurrency": "COP",
  "originAmount": 3973700,
  "destinationCurrency": "USD",
  "destinationAmount": 1000,
  "factor": 3973.7,
  "factorFormula": "COP/USD",
  "settlementTerm": "SAME_DAY",
  "settlementDate": "2026-11-24"
}
```

## 4. Follow it to settlement

Listen to the `TRANSACTIONS` webhook or read the conversion. When it is `COMPLETED`, the dollars are in your USD balance.

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

## What can go wrong

| Response                                            | What to do                                                                                                    |
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `422 quote "…" is expired`                          | More than 30 seconds passed: quote again and show the cost again.                                             |
| `422 insufficient COP balance to convert …`         | Fund your COP balance (with a [PSE link](https://developers.zulu.com.co/en/docs/pay-in/pse.md), for example). |
| `422 … is below the minimum` or `above the maximum` | Fit the amount to the FX limits.                                                                              |

| HTTP | error | cause | Description |
| --- | --- | --- | --- |
| 422 | `UnprocessableEntityApiError` | `quote "%s" is expired` | The quote expired (it lives 30 seconds). Request a new one. |
| 422 | `UnprocessableEntityApiError` | `quote "%s" has already been used` | Each quote serves a single conversion. |
| 422 | `UnprocessableEntityApiError` | `insufficient %s balance to convert %.2f` | The balance of the origin currency is not enough. |
| 422 | `UnprocessableEntityApiError` | `%s amount %.2f is below the minimum of %.2f` | One side of the conversion is below the minimum (`GET /v1/limits`). |
| 422 | `UnprocessableEntityApiError` | `%s amount %.2f is above the maximum of %.2f` | One side of the conversion exceeds the maximum (`GET /v1/limits`). |
