Skip to content
developers

FX / Use cases

Treasury: quote and execute

Show a locked rate to an approver, execute it within its life and handle expiry, terms and limits without surprises.

Sandbox · coming soon

A treasury desk wants a person to approve every conversion while seeing the exact rate, and the system to execute it only if the approval arrives in time.

The flow

  1. The system quotes and shows factor, both amounts and a countdown to expiresAt.
  2. The person approves.
  3. The system executes with an Idempotency-Key tied to the approval.
  4. If the quote expired, it quotes again and asks to approve the new rate.

1. Quote and compute before executing

Compute the other side with integers, like zulu does, to show exactly what will be executed:

preview.js

const f2 = (factor) => {
  const [whole, fraction = ''] = String(factor).split('.');
  return BigInt(whole) * 100n + BigInt(fraction.padEnd(2, '0'));
};
const roundDiv = (n, d) => (n * 2n + d) / (d * 2n);

// COP → USD by origin amount: cents = round(pesos × 10⁴ / f₂)
export const previewCopToUsdCents = (pesos, factor) => roundDiv(BigInt(pesos) * 10_000n, f2(factor));

2. Pick the term

If you need the funds…Term
Today, before the cutoffSAME_DAY
TomorrowNEXT_DAY
In two business daysSECOND_DAY
LimitValue
REAL FX hours (business days, Bogotá)08:05 – 15:30
Last time to quote SAME_DAY13:00

3. Execute exactly once

cURL

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

If the network drops, retry with the same key: you get the same conversion, not two. A quote already used answers 422.

4. Expiry and limits

RuleOperations
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
A quote lives 30 seconds and serves a single conversion.getQuotecreateFxTransaction
HTTPerrorcauseDescription
422UnprocessableEntityApiErrorquote "%s" is expiredThe quote expired (it lives 30 seconds). Request a new one.
422UnprocessableEntityApiErrorquote "%s" has already been usedEach quote serves a single conversion.
422UnprocessableEntityApiErrororigin 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.
422UnprocessableEntityApiError%s amount %.2f is below the minimum of %.2fOne side of the conversion is below the minimum (GET /v1/limits).
422UnprocessableEntityApiError%s amount %.2f is above the maximum of %.2fOne side of the conversion exceeds the maximum (GET /v1/limits).
422UnprocessableEntityApiErrorthe fx market is closedThe FX market is closed (REAL hours: 08:05–15:30 on Bogotá business days). The sandbox defaults to ALWAYS_OPEN.
422UnprocessableEntityApiErrorSAME_DAY settlement is not available after %sAfter the cutoff SAME_DAY is not available; quote NEXT_DAY or SECOND_DAY.
422UnprocessableEntityApiErroridempotency key "%s" was used with a different requestThe Idempotency-Key was already used in the last 24 hours with a different body or operation. Use a new key for every distinct operation.