Skip to main content
POST
/
v1
/
swaps
Create a new Swap transaction
curl --request POST \
  --url https://sandbox-api.borderless.xyz/v1/swaps \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "fromAccountId": "cm2c4x3cc000019stwv7um4zl",
  "fromAmount": "100.50",
  "fromAsset": "ETH",
  "toAsset": "POL",
  "passphrase": "my-secure-passphrase",
  "toAddress": "0xE79a68B87544ed42Cc5aA805bb056201e7942D3A"
}
'
{
  "id": "<string>",
  "expiredAt": "2023-11-07T05:31:56Z",
  "fromAmountUSD": "<string>",
  "toAmountUSD": "<string>",
  "estimatedCostsUSD": "<string>",
  "steps": [
    {
      "executionDuration": 123,
      "source": {
        "currency": "<string>",
        "chainId": 123,
        "amount": "<string>",
        "amountUSD": "<string>",
        "minAmount": "<string>"
      },
      "destination": {
        "currency": "<string>",
        "chainId": 123,
        "amount": "<string>",
        "amountUSD": "<string>",
        "minAmount": "<string>"
      },
      "estimate": {
        "feeCosts": [
          {
            "amount": "<string>",
            "amountUSD": "<string>",
            "token": "<string>",
            "included": true
          }
        ],
        "gasCosts": [
          {
            "amount": "<string>",
            "amountUSD": "<string>",
            "token": "<string>",
            "included": true
          }
        ]
      }
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
fromAccountId
string
required

The id of the account authorized for smart contract interaction.

Required string length: 25
Example:

"cm2c4x3cc000019stwv7um4zl"

fromAmount
string
required

The amount approved for the smart contract interaction.

Example:

"100.50"

fromAsset
enum<string>
required

The token associated with a specific blockchain for smart contract approval.

Available options:
POL,
USDT_POLYGON,
USDC_POLYGON,
USDM_POLYGON,
ETH,
USDT_ETHEREUM,
USDC_ETHEREUM,
USDM_ETHEREUM,
TRX,
USDT_TRON,
ETH_BASE,
USDC_BASE,
USDM_BASE,
ETH_OPTIMISM,
USDT_OPTIMISM,
USDC_OPTIMISM,
USDM_OPTIMISM,
BTC,
CELO,
CUSD_CELO,
USDC_CELO,
SOL,
USDC_SOLANA,
USDT_SOLANA
Example:

"ETH"

toAsset
enum<string>
required

The target asset to receive from the swap.

Available options:
POL,
USDT_POLYGON,
USDC_POLYGON,
USDM_POLYGON,
ETH,
USDT_ETHEREUM,
USDC_ETHEREUM,
USDM_ETHEREUM,
TRX,
USDT_TRON,
ETH_BASE,
USDC_BASE,
USDM_BASE,
ETH_OPTIMISM,
USDT_OPTIMISM,
USDC_OPTIMISM,
USDM_OPTIMISM,
BTC,
CELO,
CUSD_CELO,
USDC_CELO,
SOL,
USDC_SOLANA,
USDT_SOLANA
passphrase
string

The passphrase for executing the transaction, if required. Learn more at Transaction Signing Documentation.

Example:

"my-secure-passphrase"

toAddress
string

The wallet address where the swapped funds will be credited. If not provided, the funds will be credited to the account that executed the swap.

Example:

"0xE79a68B87544ed42Cc5aA805bb056201e7942D3A"

Response

Successfully created Swap transaction data.

id
string
required

Temporary quote ID for execution via /swaps/quote/execution.

expiredAt
string<date-time>
required

Quote expiration date.

fromAmountUSD
string
required

Amount in USD for the source asset.

toAmountUSD
string
required

Amount in USD for the destination asset.

estimatedCostsUSD
string
required

Estimated costs in USD.

steps
object[]
required

Steps for the swap.