> ## 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.

# Link Wallet to Card

> Link a custodial wallet to the card as a payment source

Link a custodial wallet to the card as a payment source. Each user can link up to 5 wallets.

### 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="addressId" type="string" required>
  Wallet addressId from GET /v1/wallet/internal response
</ParamField>

### Response

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

<ResponseExample>
  ```json 201 - Created theme={null} theme={null}
  {
    "success": true
  }
  ```

  ```json 422 - Validation Error theme={null} theme={null}
  {
    "message": "Maximum 5 wallets can be linked"
  }
  ```
</ResponseExample>

<CodeGroup>
  ```bash cURL theme={null} theme={null}
  curl -X POST "https://dev.api.baanx.com/v1/wallet/internal/card_linked" \
    -H "x-client-key: YOUR_CLIENT_KEY" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "addressId": "7c1839ee-918e-4787-b74f-deeb48ead58b"
    }'
  ```

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

  all_wallets = requests.get(
      "https://dev.api.baanx.com/v1/wallet/internal",
      headers=headers
  ).json()

  usdc_wallet = next(w for w in all_wallets if w['currency'] == 'usdc')

  link_data = {"addressId": usdc_wallet['addressId']}
  response = requests.post(
      "https://dev.api.baanx.com/v1/wallet/internal/card_linked",
      headers=headers,
      json=link_data
  )

  if response.status_code == 201:
      print("Wallet linked to card successfully!")
  ```

  ```typescript TypeScript theme={null} theme={null}
  async function linkWalletToCard(addressId: string): Promise<boolean> {
    const response = await fetch(
      'https://dev.api.baanx.com/v1/wallet/internal/card_linked',
      {
        method: 'POST',
        headers: {
          'x-client-key': 'YOUR_CLIENT_KEY',
          'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ addressId })
      }
    );

    const result = await response.json();
    return result.success;
  }
  ```
</CodeGroup>

## Related Endpoints

* [List Card-Linked Wallets](/api-reference/wallet/internal-card-linked-get) - View currently linked wallets
* [Unlink Wallet from Card](/api-reference/wallet/internal-card-linked-delete) - Remove a wallet from card payment sources
* [Get Internal Wallets](/api-reference/wallet/internal) - View all available wallets to link
