Swap

Exchange one cryptocurrency for another directly within your IvoryPay business wallet — no external transfers required.

Base path: /v1/crypto-swap Authentication: API Key (Authorization: <secret-key>)


Endpoints

Method
Path
Description

POST

/v1/crypto-swap/estimate

Preview a swap rate without executing it

POST

/v1/crypto-swap/initiate

Execute a crypto-to-crypto swap


POST /v1/crypto-swap/estimate

Returns the estimated output amount, conversion rate, and fee for a proposed swap. No funds are moved during estimation.

Request

Headers

Authorization: <your-secret-api-key>
Content-Type: application/json

Body

{
  "sourceCurrency": "USDT",
  "targetCurrency": "BTC",
  "amountInSourceCurrency": 100
}
Field
Type
Required
Description

sourceCurrency

string

Yes

Token you want to swap from. See supported tokens.

targetCurrency

string

Yes

Token you want to swap to. Must differ from sourceCurrency.

amountInSourceCurrency

number

Yes

Amount in the source token. Must be a positive number.

Response

Field
Type
Description

sourceCurrency

string

Token being swapped from

targetCurrency

string

Token being swapped to

amountInSourceCurrency

number

Amount you're swapping

amountInTargetCurrency

number

Estimated amount you will receive

feeInSourceCurrency

number

Platform fee deducted from source amount

conversionRate

number

Exchange rate at time of estimation

Error Responses

Status
Message
Cause

400

The source currency must be different from the target currency

Same token for source and target

400

Your <token> wallet is inactive. Please enable.

Wallet is disabled

400

Insufficient balance

Not enough funds for the swap + fee

401

Unauthorized

Missing or invalid API key


POST /v1/crypto-swap/initiate

Executes the swap. Debits amountInSourceCurrency + fee from your source wallet and credits the converted amount to your target wallet.

Request

Headers

Body

Field
Type
Required
Description

sourceCurrency

string

Yes

Token to swap from.

targetCurrency

string

Yes

Token to swap to. Must differ from sourceCurrency.

amountInSourceCurrency

number

Yes

Amount to swap in the source token.

reference

string

Yes

Your unique identifier for this swap. Used for idempotency.

Response

Error Responses

Status
Message
Cause

400

The source currency must be different from the target currency

Same token for source and target

400

Duplicate transaction

A swap with the same reference already exists

400

Insufficient balance

Not enough funds for the swap + fee

400

Unable to retrieve swap conversion

Exchange rate service unavailable

401

Unauthorized

Missing or invalid API key


Swap Lifecycle

Status
Description

PENDING

Swap queued for processing

SUCCESS

Source wallet debited, target wallet credited

FAILED

Swap failed — no funds moved

Swaps are processed asynchronously. Use webhooks to get notified when a swap completes.


Supported Tokens

Value
Name

USDT

Tether USD

USDC

USD Coin

BTC

Bitcoin

ETH

Ethereum

SOL

Solana

Both sourceCurrency and targetCurrency must be tokens supported by your account. Use GET /v1/crypto-transfer/supported/network-tokens to see your enabled tokens.


Fee Structure

The platform fee is calculated dynamically by the conversion service at the time of the request and returned as feeInSourceCurrency in both the estimate and initiate responses. It is deducted from the source currency amount.

Use /v1/crypto-swap/estimate first to preview the exact amounts before executing.


Code Examples

Node.js

cURL

Python

Last updated