Skip to main content
POST
/
wallet
/
swap
Swap Currency
curl --request POST \
  --url https://api.rolla.xyz/api/v1/external/wallet/swap \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "fromCurrency": "USD",
  "toCurrency": "NGN",
  "fromAmount": 1000,
  "description": "<string>",
  "rateToken": "<string>"
}
'
{
  "success": true,
  "message": "Swap completed successfully",
  "data": {
    "transaction": {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "transaction_type": "deposit",
      "status": "pending",
      "description": "<string>",
      "external_reference": "<string>",
      "fee_amount": 123,
      "source_amount": 123,
      "destination_amount": 123,
      "source_currency": "<string>",
      "destination_currency": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "updated_at": "2023-11-07T05:31:56Z"
    },
    "fromAmount": 1000,
    "toAmount": 1550000,
    "rate": 1550
  }
}
Swap funds from one currency to another at the current exchange rate. Use a rateToken from the /wallet/rates endpoint to lock in a specific rate.

Example Request

curl -X POST "https://api.rolla.xyz/api/v1/external/wallet/swap" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "fromCurrency": "USD",
    "toCurrency": "NGN",
    "fromAmount": 1000,
    "description": "Convert USD to NGN",
    "rateToken": "rt_abc123def456"
  }'

Example Response

{
  "status": 200,
  "success": true,
  "message": "Swap completed successfully",
  "data": {
    "transaction": {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "transaction_type": "swap",
      "status": "completed",
      "description": "Convert USD to NGN",
      "external_reference": null,
      "fee_amount": 0,
      "source_amount": 1000,
      "destination_amount": 1405399,
      "source_currency": "USD",
      "destination_currency": "NGN",
      "exchange_rate": 1405.3992,
      "created_at": "2024-01-15T10:30:00.000Z",
      "updated_at": "2024-01-15T10:30:05.000Z"
    }
  }
}
The fromCurrency and toCurrency must be different. If you don’t provide a rateToken, the swap will execute at the current market rate which may differ from the last quoted rate.

Authorizations

X-API-Key
string
header
required

Your Rolla API key

Body

application/json
fromCurrency
string
required

Source currency code

Required string length: 3
Example:

"USD"

toCurrency
string
required

Destination currency code (must differ from fromCurrency)

Required string length: 3
Example:

"NGN"

fromAmount
number
required

Amount to swap from source currency

Example:

1000

description
string

Optional description

Maximum string length: 500
rateToken
string

Rate token from /wallet/rates to lock in a specific rate

Response

Swap completed successfully

success
boolean
Example:

true

message
string
Example:

"Swap completed successfully"

data
object