API Reference
Initialize Swap [POST]

Initialize Swap


https://sandboxapi.onbrails.com/api/v2/wallets/initialize-swap (opens in a new tab)

Initialize a currency swap

📘

Always retrieve a Quote first to lock in the exchange rate, fee, and expiry before initializing a swap.

Body Parameters

ParameterTypeRequired
sourceCurrencystring
amountint32
targetCurrencystring
⚠️

Amounts are in minor units. The amount must always be provided in the lowest denomination of the sourceCurrency — for example, 1 USD is sent as 100 (cents).

Request

Wallets/Initialize Swap [POST]
curl --request POST \
   --url https://sandboxapi.onbrails.com/api/v2/wallets/initialize-swap \
   --header 'Authorization: Bearer YOUR_SECRET_KEY' \
   --header 'accept: application/json' \
   --header 'content-type: application/json' \
   --data '
{
"sourceCurrency": "string",
"amount": 0,
"targetCurrency": "string"
}
'

Responses

🟢 200 - Result example
{
"status": true,
"message": "Quote retrieved successfully",
"data": {
  "sourceAmount": "10",
  "targetAmount": "11500.00",
  "id": "4996aa57-602c-417b-ac51-bee4617d6ddc",
  "fee": "0",
  "amount": "11500.00",
  "createdAt": "2023-12-12T23:11:01.239Z",
  "usdAmount": "10",
  "updatedAt": "2023-12-12T23:11:01.239Z",
  "expiration": "2023-12-12T23:15:11.000Z",
  "sourceCurrency": "usd",
  "targetCurrency": "ngn",
  "expirationInSec": "250",
  "conversionRate": {
    "amount": "1150",
    "currency": "ngn"
  }
}
}