> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baanx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update External Wallet Priority

> Update the priority order of external wallets for transaction funding

Update the priority order of external wallets for transaction funding. When a transaction is initiated, wallets are checked sequentially in this order until one with sufficient balance is found to fund the entire transaction. Only one wallet funds each transaction — partial funding from multiple wallets is not supported.

### Authentication

<ParamField header="x-client-key" type="string" required>
  Your public API client key
</ParamField>

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication
</ParamField>

### Request Body

<ParamField body="wallets" type="array" required>
  Array of wallet priority updates

  <Expandable title="Wallet Priority Object">
    <ParamField body="id" type="number" required>
      Wallet priority ID from GET response
    </ParamField>

    <ParamField body="priority" type="number" required>
      New priority value (lower numbers = higher priority)
    </ParamField>
  </Expandable>
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Whether priority update was successful
</ResponseField>

<ResponseExample>
  ```json 200 - Success theme={null} theme={null}
  {
    "success": true
  }
  ```

  ```json 401 - Authentication Error theme={null} theme={null}
  {
    "message": "Not authenticated"
  }
  ```

  ```json 422 - Validation Error theme={null} theme={null}
  {
    "message": "Invalid priority configuration"
  }
  ```
</ResponseExample>

<CodeGroup>
  ```bash cURL theme={null} theme={null}
  curl -X PUT "https://dev.api.baanx.com/v1/wallet/external/priority" \
    -H "x-client-key: YOUR_CLIENT_KEY" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "wallets": [
        {
          "id": 552,
          "priority": 1
        },
        {
          "id": 551,
          "priority": 2
        }
      ]
    }'
  ```

  ```python Python theme={null} theme={null}
  import requests

  url = "https://dev.api.baanx.com/v1/wallet/external/priority"
  headers = {
      "x-client-key": "YOUR_CLIENT_KEY",
      "Authorization": "Bearer YOUR_ACCESS_TOKEN",
      "Content-Type": "application/json"
  }

  current = requests.get(url, headers=headers).json()

  updated_priorities = []
  for index, wallet in enumerate(current):
      updated_priorities.append({
          "id": wallet['id'],
          "priority": index + 1
      })

  data = {"wallets": updated_priorities}
  response = requests.put(url, headers=headers, json=data)

  if response.status_code == 200:
      print("Priority updated successfully!")
  ```

  ```typescript TypeScript theme={null} theme={null}
  async function updateExternalWalletPriority(
    priorities: Array<{ id: number; priority: number }>
  ): Promise<boolean> {
    const response = await fetch(
      'https://dev.api.baanx.com/v1/wallet/external/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 updateExternalWalletPriority([
    { id: 552, priority: 1 },
    { id: 551, priority: 2 }
  ]);
  ```
</CodeGroup>

## Important Notes

<Warning>
  **Single-Wallet Funding**: Only ONE wallet funds each transaction. The platform checks wallets in priority order and uses the first one with sufficient balance to cover the ENTIRE transaction cost. Partial funding from multiple wallets is NOT supported.
</Warning>

<Note>
  **Update All Wallets**: You must provide priority values for ALL registered external wallets. Partial updates may result in unexpected behavior.
</Note>

<Warning>
  **Unique Priorities**: Each wallet must have a unique priority value. Duplicate priorities will cause validation errors.
</Warning>

<Tip>
  **Transaction Failure**: If ALL priority wallets have insufficient balance to cover the full transaction cost, the transaction will fail. Ensure at least one wallet always has adequate funds.
</Tip>

## Related Endpoints

* [Get External Wallet Priority](/api-reference/wallet/external-priority-get) - View current priority order
* [Get External Wallets](/api-reference/wallet/external) - View all registered external wallets
* [Withdraw from Credit Wallet](/api-reference/wallet/credit-withdraw) - Uses priority order for destination wallet
* [Withdraw from Reward Wallet](/api-reference/wallet/reward-withdraw) - Uses priority order for destination wallet
