Skip to main content
POST
/
v4
/
swap
/
execute_quote
Execute Swap quote
curl --request POST \
  --url 'https://api.moonpay.com/v4/swap/execute_quote?apiKey=' \
  --header 'Content-Type: application/json' \
  --header 'authorization: <authorization>' \
  --data '
{
  "signature": "***",
  "walletAddresses": {
    "destinationWalletAddress": 7.55070758245981e+47,
    "refundWalletAddress": 7.55070758245981e+47,
    "destinationWalletAddressTag": "tag",
    "refundWalletAddressTag": "tag"
  },
  "externalTransactionId": "6ec52bc3-236a-4570-a9e0-743e14818619"
}
'
import requests

url = "https://api.moonpay.com/v4/swap/execute_quote?apiKey="

payload = {
"signature": "***",
"walletAddresses": {
"destinationWalletAddress": 7.55070758245981e+47,
"refundWalletAddress": 7.55070758245981e+47,
"destinationWalletAddressTag": "tag",
"refundWalletAddressTag": "tag"
},
"externalTransactionId": "6ec52bc3-236a-4570-a9e0-743e14818619"
}
headers = {
"authorization": "<authorization>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
signature: '***',
walletAddresses: {
destinationWalletAddress: 7.55070758245981e+47,
refundWalletAddress: 7.55070758245981e+47,
destinationWalletAddressTag: 'tag',
refundWalletAddressTag: 'tag'
},
externalTransactionId: '6ec52bc3-236a-4570-a9e0-743e14818619'
})
};

fetch('https://api.moonpay.com/v4/swap/execute_quote?apiKey=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.moonpay.com/v4/swap/execute_quote?apiKey=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'signature' => '***',
'walletAddresses' => [
'destinationWalletAddress' => 7.55070758245981e+47,
'refundWalletAddress' => 7.55070758245981e+47,
'destinationWalletAddressTag' => 'tag',
'refundWalletAddressTag' => 'tag'
],
'externalTransactionId' => '6ec52bc3-236a-4570-a9e0-743e14818619'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"authorization: <authorization>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.moonpay.com/v4/swap/execute_quote?apiKey="

payload := strings.NewReader("{\n \"signature\": \"***\",\n \"walletAddresses\": {\n \"destinationWalletAddress\": 7.55070758245981e+47,\n \"refundWalletAddress\": 7.55070758245981e+47,\n \"destinationWalletAddressTag\": \"tag\",\n \"refundWalletAddressTag\": \"tag\"\n },\n \"externalTransactionId\": \"6ec52bc3-236a-4570-a9e0-743e14818619\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.moonpay.com/v4/swap/execute_quote?apiKey=")
.header("authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"signature\": \"***\",\n \"walletAddresses\": {\n \"destinationWalletAddress\": 7.55070758245981e+47,\n \"refundWalletAddress\": 7.55070758245981e+47,\n \"destinationWalletAddressTag\": \"tag\",\n \"refundWalletAddressTag\": \"tag\"\n },\n \"externalTransactionId\": \"6ec52bc3-236a-4570-a9e0-743e14818619\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.moonpay.com/v4/swap/execute_quote?apiKey=")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"signature\": \"***\",\n \"walletAddresses\": {\n \"destinationWalletAddress\": 7.55070758245981e+47,\n \"refundWalletAddress\": 7.55070758245981e+47,\n \"destinationWalletAddressTag\": \"tag\",\n \"refundWalletAddressTag\": \"tag\"\n },\n \"externalTransactionId\": \"6ec52bc3-236a-4570-a9e0-743e14818619\"\n}"

response = http.request(request)
puts response.read_body
{
  "baseCurrency": {
    "id": "aaefa32f-161b-42c8-8115-debcbf3d6a2d",
    "createdAt": "2019-05-17T18:24:45.206Z",
    "updatedAt": "2019-05-17T18:24:45.206Z",
    "type": "crypto",
    "name": "USD Coin (ERC-20)",
    "code": "usdc",
    "precision": 2,
    "minBuyAmount": 30,
    "maxBuyAmount": 1000,
    "minSellAmount": 15,
    "maxSellAmount": 100000,
    "addressRegex": "^(0x)[0-9A-Fa-f]{40}$",
    "testnetAddressRegex": "^(0x)[0-9A-Fa-f]{40}$",
    "supportsAddressTag": false,
    "addressTagRegex": null,
    "supportsTestMode": true,
    "isSuspended": false,
    "isSupportedInUs": true,
    "isSellSupported": true,
    "notAllowedUSStates": [
      "LA",
      "VI"
    ],
    "notAllowedCountries": [
      "CA"
    ],
    "metadata": {
      "contractAddress": 0,
      "chainId": "1",
      "networkCode": "ethereum"
    }
  },
  "quoteCurrency": "<string>",
  "baseCurrencyAmount": "1.123",
  "quoteCurrencyAmount": "0.0056",
  "extraFeeAmount": "0.0000005",
  "networkFeeAmount": "0.00039",
  "feeAmount": "0.0002",
  "transactionId": "3ea41bef-cfd7-445c-91cc-853f417d4f1e",
  "status": "completed"
}
{
"message": "<string>",
"type": "<string>"
}

Authorizations

apiKey
string
query
required

Headers

authorization
string
required

A valid customer authentication token in the format 'Bearer [auth token]'.

Body

application/json
signature
string
required

Signature from the GET quote response.

Example:

"***"

walletAddresses
object
required
externalTransactionId
string

A valid Swap transaction ID from your backend. You can use this to associate your transaction with our transaction.

Example:

"6ec52bc3-236a-4570-a9e0-743e14818619"

Response

Successful response — Swap Transaction

baseCurrency
object

Details about the cryptocurrency the customer wants to swap.

quoteCurrency
string

Details about the cryptocurrency the customer will receive.

baseCurrencyAmount
string

A positive string number representing how much crypto the user wants to swap.

Example:

"1.123"

quoteCurrencyAmount
string

A positive string number representing the amount of cryptocurrency the customer will receive. Set when the swap is executed.

Example:

"0.0056"

extraFeeAmount
string

A positive number string representing your extra fee for the transaction. It is added to baseCurrencyAmount, feeAmount and networkFeeAmount when the swap is executed.

Example:

"0.0000005"

networkFeeAmount
string

A positive number string representing the network fee for the transaction. It is added to baseCurrencyAmount, feeAmount and extraFeeAmount when the swap is executed.

Example:

"0.00039"

feeAmount
string

A positive number representing the fee for the transaction.

Example:

"0.0002"

transactionId
string

A valid Swap transaction ID.

Example:

"3ea41bef-cfd7-445c-91cc-853f417d4f1e"

status
enum<string>

The transaction's status. Possible values are completed, failed, waitingForDepositAddressGeneration, waitingForDeposit, executingSwap, reQuoteRequired, screeningWalletAddress, frozen.

Available options:
completed,
failed,
waitingForDepositAddressGeneration,
waitingForDeposit,
executingSwap,
reQuoteRequired,
screeningWalletAddress,
frozen
Example:

"completed"