๐Ÿ‡บ๐Ÿ‡ธ EnglishAPIsSwap (Balance conversion)

Swap (Balance conversion)

Conversion of balance between currencies inside the app (COP โ†” USD, MXN, BRL). It does not send money to bank accounts; it only moves balance between your wallets.

All endpoints require authentication with Authorization: Bearer [TOKEN] and x-api-key.

๐Ÿ”„

Difference from Exchange (FX): Exchange is for cross-border movements (quote and send to bank). Swap is for converting internal balance between your currencies in Colurs.


Overview

What is Swap?

The Swap module lets you convert balance from one currency to another within your Colurs account:

  • USD โ†’ COP, COP โ†’ USD
  • USD โ†’ MXN, MXN โ†’ USD
  • USD โ†’ BRL, BRL โ†’ USD

Balance is debited from the source currency and credited to the destination currency in your wallet.

Two conversion modes

ModeTypical useBehavior
SWAPNatural personsImmediate conversion. Balance is debited and credited instantly in main wallet (MAIN).
QUOTELegal entitiesRequires operator approval. Balance is reserved in quotation wallet (QUOTATION) and credited when approved.

General flow

Create quote

Get the rate and destination amount with POST /quote/ (action SWAP or QUOTE).

Execute conversion

Confirm the operation with POST /swap/ using the quote_id from step 1.

For SWAP the conversion is applied immediately. For QUOTE the balance remains reserved until an operator approves the quote.


Step 1: Create quote

Returns the exchange rate and resulting amount for the conversion. It does not execute the operation.

Endpoint

POST /quote/

Headers

Authorization: Bearer [ACCESS_TOKEN]
x-api-key: [API_KEY]
Content-Type: application/json
Accept: application/json

Request

FieldTypeRequiredDescription
currency_fromstringโœ…Source currency: USD, COP, MXN, BRL
currency_tostringโœ…Destination currency: COP, USD, MXN, BRL
source_amountnumberโœ…Amount to convert in source currency
actionstringโœ…SWAP (immediate) or QUOTE (requires approval)

Success response (200)

200 OK
{
  "message": "OK",
  "data": {
    "id": 688,
    "user": "colurs@colurs.io",
    "currency_from": "USD",
    "currency_to": "COP",
    "rate": 4077.3125550239233,
    "fee_amount": 0.0,
    "fee_iva_amount": 0.0,
    "source_amount": 100000.0,
    "target_amount": 407731250.0,
    "total_paid": 100000.0
  }
}
FieldDescription
idQuote ID. Use in POST /swap/ as quote_id.
rateExchange rate applied
source_amountAmount in source currency
target_amountAmount you will receive in destination currency
fee_amount, fee_iva_amountFees (if any)
๐Ÿ’พ

Save the quote id for the next step. The quote must be used with the same action (SWAP or QUOTE).


Step 2: Execute conversion

Executes the conversion using the quote ID from step 1.

Endpoint

POST /swap/

Headers

Authorization: Bearer [ACCESS_TOKEN]
x-api-key: [API_KEY]
Content-Type: application/json
Accept: application/json

Request

FieldTypeRequiredDescription
quote_idintegerโœ…Quote ID from step 1
actionstringโœ…Same action as in the quote: SWAP or QUOTE
ipstringโœ…Client IP
latitudestringโœ…GPS latitude
longitudestringโœ…GPS longitude

Success response (200)

200 OK
{
  "message": "OK",
  "data": {
    "id": 1688,
    "user": "colurs@colurs.io",
    "currency_from": "USD",
    "currency_to": "COP",
    "rate": 4077.3125550239233,
    "fee_amount": 0.0,
    "fee_iva_amount": 0.0,
    "source_amount": 100000.0,
    "target_amount": 407731250.0
  }
}

With SWAP balance is updated immediately. With QUOTE the amount remains reserved until operator approval.


Supported pairs

PairDescription
USD โ†’ COPUS dollars to Colombian pesos
COP โ†’ USDColombian pesos to US dollars
USD โ†’ MXNUS dollars to Mexican pesos
MXN โ†’ USDMexican pesos to US dollars
USD โ†’ BRLUS dollars to Brazilian reais
BRL โ†’ USDBrazilian reais to US dollars

Rates are updated periodically by the system.


Internal process (summary)

SWAP (immediate)

  1. Balance is debited from the source currency in the main wallet (MAIN).
  2. Balance is credited to the destination currency in the main wallet (MAIN).
  3. Fees are recorded in Colurs fee wallet.

QUOTE (with approval)

  1. Balance is debited from the source currency in the quotation wallet (QUOTATION).
  2. Operator approval is awaited.
  3. On approval, balance is credited to the destination currency in the quotation wallet (QUOTATION).

Each conversion creates balance movements with reason SWAP.

๐Ÿ“Š

You can check your balance per currency with the Balance endpoints to verify balances before and after conversion.