# Conversions

> Execute a quote with the origin or the destination amount, understand the rounding and follow the conversion until it settles.

[Sandbox · coming soon]

**POST** `/v1/transactions` — Convert with a quote · [Sandbox · coming soon] · [See the reference](https://developers.zulu.com.co/en/reference/create-fx-transaction.md)

## Execute a quote

Send the `quote` and **one** of the two amounts:

- **`originAmount`**: what you hand over. zulu computes what you receive.
- **`destinationAmount`**: what you want to receive. zulu computes what you hand over, rounding up so you never receive less than asked.

**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",
  "originAmount": 4000000
}'
```

```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",
    "originAmount": 4000000
  }),
});

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",
        "originAmount": 4000000,
    },
    timeout=30,
)
print(response.status_code, response.json())
```

**Response 201**

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

If you send both amounts, they must match the factor exactly; otherwise the answer is `422`.

## How it rounds

zulu never computes with binary decimals: it takes everything to minor units (pesos and cents) and uses integers.

| Rule | Operations |
| --- | --- |
| With f₂ = factor × 100: COP→USD, cents = round(pesos × 10⁴ / f₂); USD→COP, pesos = round(cents × f₂ / 10⁴). With `destinationAmount`, the origin rounds up. Both sides must stay within the limits. | [`createFxTransaction`](https://developers.zulu.com.co/en/reference/create-fx-transaction.md) |

With the quote above's factor 3973.70, f₂ = 397,370:

| Conversion          | Computation                                  | Result        |
| ------------------- | -------------------------------------------- | ------------- |
| 4,000,000 COP → USD | round(4,000,000 × 10⁴ / 397,370) = 100,662 ¢ | 1,006.62 USD  |
| Receive 1,000 USD   | ceil(100,000 × 397,370 / 10⁴) = 3,973,700    | 3,973,700 COP |

Run the same computation in your system with integers (BigInt in JavaScript, `Decimal` or integers in Python) if you need to show the result before executing.

## Statuses

A conversion stays `IN_PROGRESS` until its settlement date and then turns `COMPLETED`; it never goes through `SENT`. The origin is debited when it is created and the destination is credited when it settles.

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

In the sandbox you can settle it without waiting:

**POST** `/v1/sandbox/transactions/{transactionId}/advance` — Advance a transaction · [Sandbox only] · [See the reference](https://developers.zulu.com.co/en/reference/advance-transaction.md)

## 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. |
| 404 | `NotFoundApiError` | `quote "%s" not found` | No quote with that id exists in your workspace. |
| 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` | `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` | `origin or destination amount wasn't calculated with factor "%v"` | You sent `originAmount` and `destinationAmount` and they do not match the quote's factor. Send only one of them. |
| 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`). |
| 422 | `UnprocessableEntityApiError` | `amount %v has too many decimals for %s (max %d)` | The amount has more decimals than its currency allows: COP in whole pesos, USD up to 2 decimals. |
