Withdraw from Internal Wallet
curl --request POST \
--url https://api.example.com/v1/wallet/internal/withdraw \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-client-key: <x-client-key>' \
--data '
{
"amount": "<string>",
"recipientAddrss": "<string>",
"recipientMemo": "<string>",
"sourceAddress": "<string>",
"sourceMemo": "<string>",
"currency": "<string>"
}
'import requests
url = "https://api.example.com/v1/wallet/internal/withdraw"
payload = {
"amount": "<string>",
"recipientAddrss": "<string>",
"recipientMemo": "<string>",
"sourceAddress": "<string>",
"sourceMemo": "<string>",
"currency": "<string>"
}
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-key': '<x-client-key>',
Authorization: '<authorization>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: '<string>',
recipientAddrss: '<string>',
recipientMemo: '<string>',
sourceAddress: '<string>',
sourceMemo: '<string>',
currency: '<string>'
})
};
fetch('https://api.example.com/v1/wallet/internal/withdraw', 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.example.com/v1/wallet/internal/withdraw",
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' => '<string>',
'recipientAddrss' => '<string>',
'recipientMemo' => '<string>',
'sourceAddress' => '<string>',
'sourceMemo' => '<string>',
'currency' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"x-client-key: <x-client-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.example.com/v1/wallet/internal/withdraw"
payload := strings.NewReader("{\n \"amount\": \"<string>\",\n \"recipientAddrss\": \"<string>\",\n \"recipientMemo\": \"<string>\",\n \"sourceAddress\": \"<string>\",\n \"sourceMemo\": \"<string>\",\n \"currency\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-key", "<x-client-key>")
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.example.com/v1/wallet/internal/withdraw")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": \"<string>\",\n \"recipientAddrss\": \"<string>\",\n \"recipientMemo\": \"<string>\",\n \"sourceAddress\": \"<string>\",\n \"sourceMemo\": \"<string>\",\n \"currency\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/wallet/internal/withdraw")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": \"<string>\",\n \"recipientAddrss\": \"<string>\",\n \"recipientMemo\": \"<string>\",\n \"sourceAddress\": \"<string>\",\n \"sourceMemo\": \"<string>\",\n \"currency\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true
}
{
"message": "Insufficient balance"
}
{
"message": "Not authenticated"
}
{
"message": "Invalid recipient address format"
}
{
"message": "Internal server error"
}
Wallet
Withdraw from Internal Wallet
Initiate withdrawal from custodial wallet to external blockchain address
POST
/
v1
/
wallet
/
internal
/
withdraw
Withdraw from Internal Wallet
curl --request POST \
--url https://api.example.com/v1/wallet/internal/withdraw \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-client-key: <x-client-key>' \
--data '
{
"amount": "<string>",
"recipientAddrss": "<string>",
"recipientMemo": "<string>",
"sourceAddress": "<string>",
"sourceMemo": "<string>",
"currency": "<string>"
}
'import requests
url = "https://api.example.com/v1/wallet/internal/withdraw"
payload = {
"amount": "<string>",
"recipientAddrss": "<string>",
"recipientMemo": "<string>",
"sourceAddress": "<string>",
"sourceMemo": "<string>",
"currency": "<string>"
}
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-key': '<x-client-key>',
Authorization: '<authorization>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: '<string>',
recipientAddrss: '<string>',
recipientMemo: '<string>',
sourceAddress: '<string>',
sourceMemo: '<string>',
currency: '<string>'
})
};
fetch('https://api.example.com/v1/wallet/internal/withdraw', 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.example.com/v1/wallet/internal/withdraw",
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' => '<string>',
'recipientAddrss' => '<string>',
'recipientMemo' => '<string>',
'sourceAddress' => '<string>',
'sourceMemo' => '<string>',
'currency' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json",
"x-client-key: <x-client-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.example.com/v1/wallet/internal/withdraw"
payload := strings.NewReader("{\n \"amount\": \"<string>\",\n \"recipientAddrss\": \"<string>\",\n \"recipientMemo\": \"<string>\",\n \"sourceAddress\": \"<string>\",\n \"sourceMemo\": \"<string>\",\n \"currency\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-key", "<x-client-key>")
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.example.com/v1/wallet/internal/withdraw")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": \"<string>\",\n \"recipientAddrss\": \"<string>\",\n \"recipientMemo\": \"<string>\",\n \"sourceAddress\": \"<string>\",\n \"sourceMemo\": \"<string>\",\n \"currency\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/wallet/internal/withdraw")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": \"<string>\",\n \"recipientAddrss\": \"<string>\",\n \"recipientMemo\": \"<string>\",\n \"sourceAddress\": \"<string>\",\n \"sourceMemo\": \"<string>\",\n \"currency\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true
}
{
"message": "Insufficient balance"
}
{
"message": "Not authenticated"
}
{
"message": "Invalid recipient address format"
}
{
"message": "Internal server error"
}
Overview
Withdraw funds from a custodial (internal) wallet to an external blockchain address. Specify the source wallet, destination address, amount, and currency. Withdrawals are processed on-chain and may require network confirmations. Use Cases:- Send funds to personal external wallet
- Transfer to exchanges or other platforms
- Withdraw to whitelisted addresses
- Move funds between platforms
- Source internal wallet must have sufficient balance
- For some platforms, destination address may need to be whitelisted
- User must have appropriate verification status
Authentication
string
required
Your public API client key
string
required
Bearer token for authentication
Query Parameters
boolean
default:false
Route to US backend environment
Request Body
string
required
Amount to withdraw (decimal string)
string
required
Destination blockchain address (Note: field name has typo in API)
string
Memo/destination tag for recipient address (required for XRP, Stellar, etc.)
string
required
Source wallet address (obtained from
address field in GET /v1/wallet/internal)string
Source wallet memo (obtained from
addressMemo field in GET /v1/wallet/internal)string
required
Currency code (e.g., āxrpā, āusdcā, āsolā)
Response
boolean
Whether withdrawal was initiated successfully
{
"success": true
}
{
"message": "Insufficient balance"
}
{
"message": "Not authenticated"
}
{
"message": "Invalid recipient address format"
}
{
"message": "Internal server error"
}
Code Examples
curl -X POST "https://dev.api.baanx.com/v1/wallet/internal/withdraw" \
-H "x-client-key: YOUR_CLIENT_KEY" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"amount": "10.5",
"recipientAddrss": "rNxp4h8apvRis6mJf9Sh8C6iRxfrDWN7AA",
"recipientMemo": "12345",
"sourceAddress": "rPEPPER7kfTD9w2To4CQk6UCfuHM9c6GDY",
"sourceMemo": "78",
"currency": "xrp"
}'
import requests
url = "https://dev.api.baanx.com/v1/wallet/internal/withdraw"
headers = {
"x-client-key": "YOUR_CLIENT_KEY",
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
internal_wallet_response = requests.get(
"https://dev.api.baanx.com/v1/wallet/internal",
headers=headers
)
wallets = internal_wallet_response.json()
xrp_wallet = next(w for w in wallets if w['currency'] == 'xrp')
withdrawal_data = {
"amount": "10.5",
"recipientAddrss": "rNxp4h8apvRis6mJf9Sh8C6iRxfrDWN7AA",
"recipientMemo": "12345",
"sourceAddress": xrp_wallet['address'],
"sourceMemo": xrp_wallet['addressMemo'],
"currency": "xrp"
}
response = requests.post(url, headers=headers, json=withdrawal_data)
if response.status_code == 200:
print("Withdrawal initiated successfully!")
else:
error = response.json()
print(f"Error: {error['message']}")
interface WithdrawalRequest {
amount: string;
recipientAddrss: string;
recipientMemo?: string;
sourceAddress: string;
sourceMemo?: string;
currency: string;
}
async function withdrawFromInternal(
sourceWallet: InternalWallet,
recipientAddress: string,
amount: string,
recipientMemo?: string
): Promise<boolean> {
const withdrawalData: WithdrawalRequest = {
amount,
recipientAddrss: recipientAddress,
sourceAddress: sourceWallet.address,
currency: sourceWallet.currency
};
if (recipientMemo) {
withdrawalData.recipientMemo = recipientMemo;
}
if (sourceWallet.addressMemo) {
withdrawalData.sourceMemo = sourceWallet.addressMemo;
}
const response = await fetch(
'https://dev.api.baanx.com/v1/wallet/internal/withdraw',
{
method: 'POST',
headers: {
'x-client-key': 'YOUR_CLIENT_KEY',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify(withdrawalData)
}
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.message);
}
const result = await response.json();
return result.success;
}
Complete Withdrawal Flow
1
Get Internal Wallets
Retrieve available internal wallets
const wallets = await fetch('/v1/wallet/internal')
.then(r => r.json());
const xrpWallet = wallets.find(w => w.currency === 'xrp');
2
Validate Balance
Ensure sufficient balance for withdrawal
const balance = parseFloat(xrpWallet.balance);
const withdrawAmount = 10.5;
if (balance < withdrawAmount) {
throw new Error('Insufficient balance');
}
3
Prepare Withdrawal Data
Collect all required information
const withdrawalData = {
amount: withdrawAmount.toString(),
recipientAddrss: 'rNxp4h8apvRis6mJf9Sh8C6iRxfrDWN7AA',
recipientMemo: '12345',
sourceAddress: xrpWallet.address,
sourceMemo: xrpWallet.addressMemo,
currency: xrpWallet.currency
};
4
Initiate Withdrawal
Execute the withdrawal request
const response = await fetch('/v1/wallet/internal/withdraw', {
method: 'POST',
body: JSON.stringify(withdrawalData)
});
const result = await response.json();
if (result.success) {
console.log('Withdrawal initiated!');
}
5
Monitor Completion
Check wallet history for confirmation
setTimeout(async () => {
const history = await fetch(
`/v1/wallet/history?walletId=${xrpWallet.id}&walletType=INTERNAL&walletCurrency=${xrpWallet.currency}`
).then(r => r.json());
const withdrawal = history.find(tx =>
tx.sign === 'debit' &&
tx.amount === withdrawAmount.toString()
);
if (withdrawal) {
console.log('Withdrawal confirmed!');
}
}, 5000);
Important Notes
Field Name Typo: The recipient address field is named
recipientAddrss (missing an āeā). This is a known API quirk that must be used exactly as shown.Source Address Fields: The
sourceAddress corresponds to the address field and sourceMemo corresponds to the addressMemo field from the GET /v1/wallet/internal response.Memo Requirements: For XRP, Stellar, and other memo-based networks, always include recipient memo if withdrawing to an exchange or custodial service. Missing memos can result in lost funds.
Error Handling
Common Errors
Insufficient Balance{
"message": "Insufficient balance for withdrawal"
}
{
"message": "Invalid recipient address format"
}
{
"message": "Recipient memo required for this network"
}
recipientMemo for XRP, Stellar, and similar networks.
Withdrawal Not Allowed
{
"message": "Withdrawals temporarily disabled"
}
Address Validation
Validate addresses before withdrawal to prevent errors:function validateAddress(address, currency) {
const patterns = {
xrp: /^r[1-9A-HJ-NP-Za-km-z]{25,34}$/,
eth: /^0x[a-fA-F0-9]{40}$/,
solana: /^[1-9A-HJ-NP-Za-km-z]{32,44}$/
};
const pattern = patterns[currency.toLowerCase()];
if (!pattern) {
throw new Error(`Validation pattern not found for ${currency}`);
}
if (!pattern.test(address)) {
throw new Error(`Invalid ${currency.toUpperCase()} address format`);
}
return true;
}
try {
validateAddress('rNxp4h8apvRis6mJf9Sh8C6iRxfrDWN7AA', 'xrp');
console.log('Address is valid');
} catch (error) {
console.error(error.message);
}
import re
def validate_address(address: str, currency: str) -> bool:
patterns = {
'xrp': r'^r[1-9A-HJ-NP-Za-km-z]{25,34}$',
'eth': r'^0x[a-fA-F0-9]{40}$',
'solana': r'^[1-9A-HJ-NP-Za-km-z]{32,44}$'
}
pattern = patterns.get(currency.lower())
if not pattern:
raise ValueError(f"Validation pattern not found for {currency}")
if not re.match(pattern, address):
raise ValueError(f"Invalid {currency.upper()} address format")
return True
validate_address('rNxp4h8apvRis6mJf9Sh8C6iRxfrDWN7AA', 'xrp')
Edge Cases
Minimum Withdrawal Amounts
Networks may have minimum withdrawal thresholds:const minimums = {
xrp: 10,
usdc: 1,
eth: 0.01
};
if (parseFloat(amount) < minimums[currency]) {
throw new Error(`Minimum withdrawal is ${minimums[currency]} ${currency.toUpperCase()}`);
}
Network Fees
Withdrawal amounts should account for network fees:const balance = parseFloat(wallet.balance);
const estimatedFee = 0.1;
const maxWithdrawal = balance - estimatedFee;
console.log(`Maximum withdrawal: ${maxWithdrawal} ${wallet.currency.toUpperCase()}`);
Whitelist Requirements
Some configurations require whitelisted addresses:const whitelistedAddresses = await fetch(
`/v1/wallet/whitelist?currency=${currency}`
).then(r => r.json());
const isWhitelisted = whitelistedAddresses.some(
w => w.walletAddress === recipientAddress
);
if (!isWhitelisted) {
console.warn('Address not whitelisted. Withdrawal may fail.');
}
Related Endpoints
- Get Internal Wallets - List available internal wallets
- Whitelist External Addresses - Manage approved withdrawal destinations
- Get Wallet History - Verify withdrawal completion
Was this page helpful?