Execute a swap
curl --request POST \
--url https://api.rach.finance/api/v1/swap/customer/{customerID} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"amount_in": "1000000",
"from_chain": "POL",
"from_token": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"to_chain": "BSC",
"to_token": "0x55d398326f99059fF775485246999027B3197955",
"amount_out_min": "992047"
}
'import requests
url = "https://api.rach.finance/api/v1/swap/customer/{customerID}"
payload = {
"amount_in": "1000000",
"from_chain": "POL",
"from_token": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"to_chain": "BSC",
"to_token": "0x55d398326f99059fF775485246999027B3197955",
"amount_out_min": "992047"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount_in: '1000000',
from_chain: 'POL',
from_token: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
to_chain: 'BSC',
to_token: '0x55d398326f99059fF775485246999027B3197955',
amount_out_min: '992047'
})
};
fetch('https://api.rach.finance/api/v1/swap/customer/{customerID}', 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.rach.finance/api/v1/swap/customer/{customerID}",
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([
'amount_in' => '1000000',
'from_chain' => 'POL',
'from_token' => '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
'to_chain' => 'BSC',
'to_token' => '0x55d398326f99059fF775485246999027B3197955',
'amount_out_min' => '992047'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.rach.finance/api/v1/swap/customer/{customerID}"
payload := strings.NewReader("{\n \"amount_in\": \"1000000\",\n \"from_chain\": \"POL\",\n \"from_token\": \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n \"to_chain\": \"BSC\",\n \"to_token\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amount_out_min\": \"992047\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.rach.finance/api/v1/swap/customer/{customerID}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in\": \"1000000\",\n \"from_chain\": \"POL\",\n \"from_token\": \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n \"to_chain\": \"BSC\",\n \"to_token\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amount_out_min\": \"992047\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.rach.finance/api/v1/swap/customer/{customerID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in\": \"1000000\",\n \"from_chain\": \"POL\",\n \"from_token\": \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n \"to_chain\": \"BSC\",\n \"to_token\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amount_out_min\": \"992047\"\n}"
response = http.request(request)
puts response.read_body{
"status": "pending",
"tx_hash": "0xabc123..."
}Swap
Execute a swap
Executes a token swap from the customer’s WaaS wallet. The routing (on-chain DEX vs cross-chain bridge) is determined automatically — the merchant does not need to know or specify how the swap is fulfilled.
Flow:
- Call
GET /api/v1/swap/quoteto preview the output amounts - Call this endpoint with
amount_out_minset to your slippage floor (fromto_amount_minin the quote) - Check
GET /api/v1/swap/customer/{customerID}/historyor the merchant dashboard for status
The customer wallet must exist (created via POST /api/v1/wallet/customers) and
hold sufficient balance to cover the swap amount plus gas.
POST
/
api
/
v1
/
swap
/
customer
/
{customerID}
Execute a swap
curl --request POST \
--url https://api.rach.finance/api/v1/swap/customer/{customerID} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"amount_in": "1000000",
"from_chain": "POL",
"from_token": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"to_chain": "BSC",
"to_token": "0x55d398326f99059fF775485246999027B3197955",
"amount_out_min": "992047"
}
'import requests
url = "https://api.rach.finance/api/v1/swap/customer/{customerID}"
payload = {
"amount_in": "1000000",
"from_chain": "POL",
"from_token": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"to_chain": "BSC",
"to_token": "0x55d398326f99059fF775485246999027B3197955",
"amount_out_min": "992047"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
amount_in: '1000000',
from_chain: 'POL',
from_token: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
to_chain: 'BSC',
to_token: '0x55d398326f99059fF775485246999027B3197955',
amount_out_min: '992047'
})
};
fetch('https://api.rach.finance/api/v1/swap/customer/{customerID}', 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.rach.finance/api/v1/swap/customer/{customerID}",
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([
'amount_in' => '1000000',
'from_chain' => 'POL',
'from_token' => '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
'to_chain' => 'BSC',
'to_token' => '0x55d398326f99059fF775485246999027B3197955',
'amount_out_min' => '992047'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.rach.finance/api/v1/swap/customer/{customerID}"
payload := strings.NewReader("{\n \"amount_in\": \"1000000\",\n \"from_chain\": \"POL\",\n \"from_token\": \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n \"to_chain\": \"BSC\",\n \"to_token\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amount_out_min\": \"992047\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.rach.finance/api/v1/swap/customer/{customerID}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in\": \"1000000\",\n \"from_chain\": \"POL\",\n \"from_token\": \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n \"to_chain\": \"BSC\",\n \"to_token\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amount_out_min\": \"992047\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.rach.finance/api/v1/swap/customer/{customerID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in\": \"1000000\",\n \"from_chain\": \"POL\",\n \"from_token\": \"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\n \"to_chain\": \"BSC\",\n \"to_token\": \"0x55d398326f99059fF775485246999027B3197955\",\n \"amount_out_min\": \"992047\"\n}"
response = http.request(request)
puts response.read_body{
"status": "pending",
"tx_hash": "0xabc123..."
}Authorizations
Path Parameters
Body
application/json

