Update Linked Wallet Priority
curl --request PUT \
--url https://api.example.com/v1/wallet/internal/card_linked/priority \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-client-key: <x-client-key>' \
--data '
{
"wallets": [
{
"addressId": "<string>",
"priority": 123
}
]
}
'import requests
url = "https://api.example.com/v1/wallet/internal/card_linked/priority"
payload = { "wallets": [
{
"addressId": "<string>",
"priority": 123
}
] }
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'x-client-key': '<x-client-key>',
Authorization: '<authorization>',
'Content-Type': 'application/json'
},
body: JSON.stringify({wallets: [{addressId: '<string>', priority: 123}]})
};
fetch('https://api.example.com/v1/wallet/internal/card_linked/priority', 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/card_linked/priority",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'wallets' => [
[
'addressId' => '<string>',
'priority' => 123
]
]
]),
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/card_linked/priority"
payload := strings.NewReader("{\n \"wallets\": [\n {\n \"addressId\": \"<string>\",\n \"priority\": 123\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.example.com/v1/wallet/internal/card_linked/priority")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"wallets\": [\n {\n \"addressId\": \"<string>\",\n \"priority\": 123\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/wallet/internal/card_linked/priority")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"wallets\": [\n {\n \"addressId\": \"<string>\",\n \"priority\": 123\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true
}
{
"message": "Duplicate priority values not allowed"
}
Wallet
Update Linked Wallet Priority
Update the priority order of card-linked custodial wallets
PUT
/
v1
/
wallet
/
internal
/
card_linked
/
priority
Update Linked Wallet Priority
curl --request PUT \
--url https://api.example.com/v1/wallet/internal/card_linked/priority \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--header 'x-client-key: <x-client-key>' \
--data '
{
"wallets": [
{
"addressId": "<string>",
"priority": 123
}
]
}
'import requests
url = "https://api.example.com/v1/wallet/internal/card_linked/priority"
payload = { "wallets": [
{
"addressId": "<string>",
"priority": 123
}
] }
headers = {
"x-client-key": "<x-client-key>",
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'x-client-key': '<x-client-key>',
Authorization: '<authorization>',
'Content-Type': 'application/json'
},
body: JSON.stringify({wallets: [{addressId: '<string>', priority: 123}]})
};
fetch('https://api.example.com/v1/wallet/internal/card_linked/priority', 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/card_linked/priority",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'wallets' => [
[
'addressId' => '<string>',
'priority' => 123
]
]
]),
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/card_linked/priority"
payload := strings.NewReader("{\n \"wallets\": [\n {\n \"addressId\": \"<string>\",\n \"priority\": 123\n }\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.example.com/v1/wallet/internal/card_linked/priority")
.header("x-client-key", "<x-client-key>")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"wallets\": [\n {\n \"addressId\": \"<string>\",\n \"priority\": 123\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/wallet/internal/card_linked/priority")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-client-key"] = '<x-client-key>'
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"wallets\": [\n {\n \"addressId\": \"<string>\",\n \"priority\": 123\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true
}
{
"message": "Duplicate priority values not allowed"
}
Overview
Update the charging priority of card-linked internal wallets. Priority determines which wallet is charged first during card transactions. Lower priority numbers are charged before higher numbers (priority 1 is charged before priority 2). How Priority Works:- Transaction is initiated
- Platform attempts to charge wallet with priority 1
- If insufficient balance or failure, moves to priority 2
- Process continues until transaction succeeds or all wallets exhausted
Authentication
string
required
Your public API client key
string
required
Bearer token for authentication
Request Body
array
required
Response
boolean
Whether priority update was successful
{
"success": true
}
{
"message": "Duplicate priority values not allowed"
}
Code Examples
curl -X PUT "https://dev.api.baanx.com/v1/wallet/internal/card_linked/priority" \
-H "x-client-key: YOUR_CLIENT_KEY" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"wallets": [
{
"addressId": "7c1839ee-918e-4787-b74f-deeb48ead58b",
"priority": 1
},
{
"addressId": "1693a6da-5945-4461-ba1c-0b9891f78848",
"priority": 2
}
]
}'
import requests
url = "https://dev.api.baanx.com/v1/wallet/internal/card_linked/priority"
headers = {
"x-client-key": "YOUR_CLIENT_KEY",
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
priority_data = {
"wallets": [
{"addressId": "7c1839ee-918e-4787-b74f-deeb48ead58b", "priority": 1},
{"addressId": "1693a6da-5945-4461-ba1c-0b9891f78848", "priority": 2}
]
}
response = requests.put(url, headers=headers, json=priority_data)
if response.status_code == 200:
print("Priority updated successfully!")
interface WalletPriority {
addressId: string;
priority: number;
}
async function updateWalletPriority(
priorities: WalletPriority[]
): Promise<boolean> {
const response = await fetch(
'https://dev.api.baanx.com/v1/wallet/internal/card_linked/priority',
{
method: 'PUT',
headers: {
'x-client-key': 'YOUR_CLIENT_KEY',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({ wallets: priorities })
}
);
const result = await response.json();
return result.success;
}
await updateWalletPriority([
{ addressId: '7c1839ee-918e-4787-b74f-deeb48ead58b', priority: 1 },
{ addressId: '1693a6da-5945-4461-ba1c-0b9891f78848', priority: 2 }
]);
Use Cases
Reorder All Wallets
async function reorderWallets(newOrder) {
const priorities = newOrder.map((addressId, index) => ({
addressId,
priority: index + 1
}));
await updateWalletPriority(priorities);
}
await reorderWallets([
'7c1839ee-918e-4787-b74f-deeb48ead58b',
'1693a6da-5945-4461-ba1c-0b9891f78848',
'a8f3c2e1-445d-4a3b-9c7e-1f2d3e4a5b6c'
]);
Swap Two Wallet Priorities
async function swapWalletPriorities(wallet1, wallet2) {
const temp = wallet1.priority;
await updateWalletPriority([
{ addressId: wallet1.addressId, priority: wallet2.priority },
{ addressId: wallet2.addressId, priority: temp }
]);
}
Move Wallet to Top Priority
async function moveToTopPriority(walletId) {
const linked = await fetch('/v1/wallet/internal/card_linked')
.then(r => r.json());
const priorities = linked
.sort((a, b) => a.priority - b.priority)
.map((w, index) => ({
addressId: w.addressId,
priority: w.addressId === walletId ? 1 : index + 2
}));
await updateWalletPriority(priorities);
}
Important Notes
Update All Wallets: You must provide priority values for ALL linked wallets, not just the ones you want to change. Omitted wallets may lose their linked status.
Unique Priorities: Each wallet must have a unique priority value. Duplicate priorities will result in a validation error.
Sequential Numbering: While not required, it’s recommended to use sequential numbering (1, 2, 3…) for clarity and consistency.
Best Practices
Maintain Sequential Order
function ensureSequentialPriorities(wallets) {
return wallets
.sort((a, b) => a.priority - b.priority)
.map((wallet, index) => ({
...wallet,
priority: index + 1
}));
}
Validate Before Update
function validatePriorities(wallets) {
const priorities = wallets.map(w => w.priority);
const hasDuplicates = new Set(priorities).size !== priorities.length;
if (hasDuplicates) {
throw new Error('Duplicate priorities not allowed');
}
const hasGaps = priorities.length > 0 &&
Math.max(...priorities) !== priorities.length;
if (hasGaps) {
console.warn('Priority sequence has gaps');
}
return true;
}
Related Endpoints
- Get Card-Linked Wallets - View current linked wallets and priorities
- Link Internal Wallet - Add wallet to card payment sources
Was this page helpful?
⌘I