Swap
A Swap converts funds between different currencies within your own wallets. For example, converting USD in your USD wallet to EUR in your EUR wallet. The conversion happens immediately upon quote acceptance.
Overview
- Create a SWAP Quote — Lock in the exchange rate and fees
- Accept the Quote — Conversion happens immediately
- Webhook Notification — Receive confirmation of the completed swap
Swaps do not require an external beneficiary. Funds move between your own wallets.
Step 1: Create a SWAP Quote
Create a quote with quote_type: "SWAP". The source and target currencies must be different.
Endpoint
POST /api/v1/client/quotes
Authentication
Request Body
Required Parameters
Optional Parameters
Success Response (201 Created)
No
beneficiary_idrequired. A self-beneficiary is automatically created for swaps.
Step 2: Accept the Quote
Accept the quote to execute the swap. The conversion is processed immediately — funds are deducted from your source currency wallet and credited to your target currency wallet.
Endpoint
POST /api/v1/client/quotes/{id}/accept
Authentication
Success Response (200 OK)
No payment instructions are returned for swaps. The conversion uses your existing wallet balance.
Step 3: Webhook Notification
You'll receive a transaction webhook when the swap completes:
Note that sender and recipient are the same user, since funds move between your own wallets.
Preview Exchange Rates
Before creating a swap quote, you can preview estimated rates and fees using the Exchange Rates API:
GET /api/v1/client/exchange-rates
This is optional — actual rates are locked when the quote is created. See Exchange Rates API for details.
Example: Complete Swap Flow
cURL
Step 1: Create swap quote
Step 2: Accept the quote
HTTP
Step 1: Create swap quote
Step 2: Accept the quote
JavaScript
Requirements
- Wallet Balance — You must have sufficient balance in the source currency wallet to cover the amount plus fees.
- Different Currencies — Source and target currencies must be different (e.g., USD to EUR). For same-currency operations, use a Transfer or Withdrawal.
- Wallets for Both Currencies — You must have wallets for both the source and target currencies.
Best Practices
- Preview Rates First — Use the Exchange Rates API to show estimated rates to users before committing to a swap.
- Accept Promptly — Quotes expire after ~30 minutes. Accept before the
valid_untiltimestamp to lock in the displayed rate. - Check Balance — Verify sufficient balance in the source wallet before creating the quote.
- Unique Origin References — Each
origin_referencemust be unique to prevent duplicate swaps. - Track via Webhooks — Use webhooks for real-time confirmation rather than polling.