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",
      "type": "deposit",
      "status": "pending",
      "amount": 123,
      "currency": "<string>",
      "description": "<string>",
      "created_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

{
  "success": true,
  "message": "Swap completed successfully",
  "data": {}
}
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