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

# Fund Agent Wallet

> Start a card checkout or get the USDC deposit address to fund an agent wallet

## Overview

Adds funds to the calling agent's wallet in one of two ways.

* `card_checkout` creates a Stripe Checkout session and returns its URL. The operator opens the URL in a browser and pays by card. The wallet is credited when the payment completes.
* `crypto` returns the platform's USDC deposit address on Base, with the network id and the USDC contract address. Send USDC to that address, then confirm the transaction with `POST /v1/agents/wallets/confirm-deposit` (body: `tx_hash`, `expected_amount_atomic`) so the balance is credited.

Free-tier tools need no funding. Only priced tools draw on the wallet.

**Auth:** Requires API key (`danube-api-key` header).

## Body

<ParamField body="method" type="string" required>
  `card_checkout` or `crypto`. Any other value returns a 400.
</ParamField>

<ParamField body="amount_cents" type="integer">
  Amount to charge, in cents. Required for `card_checkout`; minimum 100 (\$1.00). Ignored for `crypto`.
</ParamField>

## Response

Every field is present for both methods. Fields that do not apply to the chosen method are `null`.

<ResponseField name="wallet_id" type="string">USDC wallet id</ResponseField>
<ResponseField name="method" type="string">The method used: `card_checkout` or `crypto`</ResponseField>
<ResponseField name="checkout_url" type="string | null">Stripe Checkout URL to open in a browser. `card_checkout` only.</ResponseField>
<ResponseField name="deposit_address" type="string | null">The platform's USDC deposit address. `crypto` only.</ResponseField>
<ResponseField name="network" type="string | null">Chain id of the deposit network. `eip155:8453` is Base. `crypto` only.</ResponseField>
<ResponseField name="usdc_contract" type="string | null">The USDC token contract on that network. `crypto` only.</ResponseField>
<ResponseField name="balance_usdc" type="string">The wallet balance before this funding, in USDC with six decimals</ResponseField>

## Errors

| Code | Meaning                                                                                        |
| ---- | ---------------------------------------------------------------------------------------------- |
| 400  | `amount_cents` missing or below 100 for `card_checkout`, or an unknown `method`                |
| 401  | Missing or invalid API key                                                                     |
| 503  | Card payments are not configured, or the platform wallet for crypto deposits is not configured |

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.danubeai.com/v1/agents/wallets/fund" \
    -H "danube-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"method": "card_checkout", "amount_cents": 2000}'
  ```

  ```python Python SDK theme={null}
  from danube import DanubeClient

  with DanubeClient(api_key="YOUR_API_KEY") as client:
      result = client.agents.fund_wallet(method="card_checkout", amount_cents=2000)
      print(f"Open in a browser: {result.checkout_url}")

      deposit = client.agents.fund_wallet(method="crypto")
      print(f"Send USDC on {deposit.network} to {deposit.deposit_address}")
  ```

  ```typescript TypeScript SDK theme={null}
  import { DanubeClient } from 'danube';

  const client = new DanubeClient({ apiKey: 'YOUR_API_KEY' });
  const result = await client.agents.fundWallet({ method: 'card_checkout', amountCents: 2000 });
  console.log(`Open in a browser: ${result.checkoutUrl}`);

  const deposit = await client.agents.fundWallet({ method: 'crypto' });
  console.log(`Send USDC on ${deposit.network} to ${deposit.depositAddress}`);
  ```
</RequestExample>

<ResponseExample>
  ```json card_checkout theme={null}
  {
    "wallet_id": "9d3e5b1a-0c2f-4a6b-8e7d-1f2a3b4c5d6e",
    "method": "card_checkout",
    "checkout_url": "https://checkout.stripe.com/c/pay/cs_live_…",
    "deposit_address": null,
    "network": null,
    "usdc_contract": null,
    "balance_usdc": "0.000000"
  }
  ```

  ```json crypto theme={null}
  {
    "wallet_id": "9d3e5b1a-0c2f-4a6b-8e7d-1f2a3b4c5d6e",
    "method": "crypto",
    "checkout_url": null,
    "deposit_address": "0x1234…abcd",
    "network": "eip155:8453",
    "usdc_contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "balance_usdc": "0.000000"
  }
  ```
</ResponseExample>

## MCP Tool

This endpoint is also available as the `fund_agent_wallet` MCP tool:

```python theme={null}
result = await mcp.call_tool("fund_agent_wallet", {"method": "card_checkout", "amount_cents": 2000})
```
