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

# Pay an endpoint from the managed wallet

> Use agentX402Pay to pay a Laso route or any external x402 endpoint from the managed wallet, and agentWalletTransfer to move USDC out.

`agentX402Pay` settles an x402 payment from the managed wallet and returns the endpoint's own response. It works in two modes: `route` for Laso's endpoints, `url` for anyone else's.

Set up the wallet first in the [overview](https://docs.laso.finance/guides/managed-agent-wallet.md).

## Pay a Laso route

```bash theme={null}
curl https://laso.finance/agentX402Pay \
  -H "Authorization: Bearer $LASO_ID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"userId":"usr_...","route":"get-card","params":{"amount":5}}}'
```

Valid `route` values: `get-card`, `order-gift-card`, `order-intl-card`, `get-push-to-card`, `send-payment`. Free endpoints are not routes; call those directly with your Bearer token.

## Pay an external x402 endpoint

```bash theme={null}
curl https://laso.finance/agentX402Pay \
  -H "Authorization: Bearer $LASO_ID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"userId":"usr_...","url":"https://api.example.com/v1/paid-endpoint","note":"Market data for the portfolio summary you asked for"}}'
```

Include a `note` in `url` mode: one sentence on why you are paying and who it is for. It is shown next to the charge in the owner's activity feed. Notes over 300 characters are truncated. `note` is refused with `route`, since Laso purchases are already labeled.

> [!TIP]
>
> Pin the price, asset, network, and receiver on every external payment. See
> [Guardrails](https://docs.laso.finance/guides/managed-wallet-guardrails.md).

### Endpoints that settle on Base

An endpoint that settles in USDC on Base mainnet (network `eip155:8453`, or `base` in x402 v1) is paid the same way as a Solana one, from the same [balance](https://docs.laso.finance/guides/managed-agent-wallet.md#one-balance-on-solana-and-base). Nothing needs setting up first:

* The payment is signed from the account's Base wallet.
* If the Base side cannot cover the price, Laso moves what is needed over from Solana before signing. This usually adds under 10 seconds and costs 0.075% of the amount moved.
* No ETH is needed for gas: the payment is a signed USDC authorization that the endpoint's facilitator submits.
* Other EVM networks are refused.

If an endpoint offers both Solana and Base, the client pays on the first option it supports. Pin `expectedNetwork` to choose: `eip155:8453` for Base, `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` for Solana. USDC on Base is `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` for `expectedAsset`. The same spend limit, guardrails, and funds check apply on Base. Laso routes are paid on Solana; if the Solana side cannot cover one, the difference is pulled back from Base first, so USDC on either side pays for them.

## Request options

Both modes accept:

| Field | Effect |
| - | - |
| `params` | Added to the query string |
| `method` | Defaults to `GET`; set `POST` for services expecting a body |
| `body` | JSON body, used with `method: "POST"` |

## Read the response

The endpoint's response comes back wrapped:

```json theme={null}
{ "result": { "status": 200, "body": { ... }, "txHash": "..." } }
```

`txHash` is the Solana signature of the payment that settled, or the Base transaction hash for a payment made from the Base wallet. It is the same field name `agentWalletTransfer` returns, present whenever a payment settled and absent when nothing was paid.

> [!NOTE]
>
> **Confirm a payment with `txHash`, not with a balance read.** The wallet
> balance that `getAgentWallet` reports is updated by a chain webhook and can
> trail a settled payment by up to a minute. An unchanged balance right after a
> 200 does not mean the payment failed.

> [!WARNING]
>
> **Check the inner `status`, not the HTTP code.** The callable returns HTTP 200
> whenever the call completed, including when the endpoint refused. Treat any
> inner `status` outside 200–299 as a failure.

On a non-2xx, `result.error` is one sentence naming the host, status, and reason, normalized from whatever field the service used.

Before signing anything, `agentX402Pay` compares the wallet's on-chain USDC balance, Solana and Base together, to the price in the 402 challenge. An underfunded payment comes back as an inner 402 whose body is the standard x402 settlement-failure shape with `errorReason: "insufficient_funds"`, and nothing is signed:

```json theme={null}
{
  "result": {
    "status": 402,
    "body": {
      "success": false,
      "errorReason": "insufficient_funds",
      "errorMessage": "This payment costs 500.000000 USDC but the agent wallet holds 9.860000 USDC across Solana and Base. Fund it by sending USDC on Solana to 9sZ… or USDC on Base to 0x4f2…; either network pays for any payment.",
      "payer": "9sZ…",
      "network": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
      "x_laso_guidance": "…what to do next…"
    },
    "error": "laso.finance returned HTTP 402: insufficient_funds. This payment costs 500.000000 USDC but the agent wallet holds 9.860000 USDC across Solana and Base. Fund it by sending USDC on Solana to 9sZ… or USDC on Base to 0x4f2…; either network pays for any payment. Nothing was charged."
  }
}
```

Branch on `body.errorReason`. `settlement_failed` is reserved for a payment that was signed but could not settle on-chain for another reason. A Base payment gets the same check and the same shape. If moving funds to Base fails or takes longer than 45 seconds, the call fails with `unavailable` and nothing is paid to the endpoint; retry it.

An inner 402 almost always means the wallet could not cover the total. Laso fees are charged **on top of** the amount you request, so a wallet holding exactly \$2,000 cannot send a \$2,000 bank payment (it costs \$2,005.00). Nothing is charged for a failed payment, so retrying with a smaller amount is safe.

## Move funds out

`agentWalletTransfer` sends USDC from the managed wallet to any Solana address, or to any USDC address on Base. It draws on the whole balance: if the Solana side is short, the difference is pulled back from Base first, which usually adds about 15 seconds.

```bash theme={null}
curl https://laso.finance/agentWalletTransfer \
  -H "Authorization: Bearer $LASO_ID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"userId":"usr_...","destinationAddress":"SOLANA_ADDRESS","amount":"5"}}'
```

Returns `{ "result": { "transferId": "...", "txHash": "...", "destinationAddress": "...", "destinationNetwork": "solana" } }`.

### Sending to Base

Set `destinationNetwork` to `"base"` and pass a `0x` address. The managed wallet is a Solana wallet, so Laso bridges the USDC to Base over CCTP and it arrives as native USDC at the address you gave.

```bash theme={null}
curl https://laso.finance/agentWalletTransfer \
  -H "Authorization: Bearer $LASO_ID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"userId":"usr_...","destinationAddress":"0xBASE_ADDRESS","destinationNetwork":"base","amount":"5"}}'
```

* `txHash` is the Solana transaction that took the USDC out of the managed wallet, not the Base delivery. The USDC usually lands on Base within a minute of it confirming.
* The minimum is \$1.00, and the maximum is your account's [spend limit](https://docs.laso.finance/guides/managed-wallet-spend-limit.md) per payment.
* The recipient receives the amount less the bridge's 0.01% fee (\$5.00 arrives as \$4.9995).
* If the bridge fails, nothing is burned and the amount is credited to your Laso account balance instead. Withdraw it with `/withdraw` or retry.

## Other tokens in the wallet

The managed wallet can receive any Solana token, so someone may fund it with USDT or SOL instead of USDC. Payments spend USDC only. `getAgentWallet` lists everything the wallet holds under `tokens`, each with `mint` (`native` for SOL), `symbol`, `amount`, and `usd_value`.

**Swap it to USDC** with `agentWalletSwap`. No SOL is needed for fees, and the rate includes a provider fee of up to 0.25% plus the pool's own fee. `slippageBps` caps how far the fill may land from the quote (default 50, maximum 300).

```bash theme={null}
curl https://laso.finance/agentWalletSwap \
  -H "Authorization: Bearer $LASO_ID_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"data":{"userId":"usr_...","fromMint":"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","amount":"10"}}'
```

Returns `{ "result": { "swapId": "...", "status": "succeeded", "fromSymbol": "USDT", "toSymbol": "USDC", "inputAmount": 10, "outputAmount": 9.966, "txHash": "..." } }`. If the swap is still settling after 45 seconds, `status` is `pending`. Swaps keep the money in the wallet, so they do not count against your spend limits.

`toMint` can be any token. `searchSwapTokens` finds one by symbol, name, or mint and marks whether it is verified; an unverified token is often a copy of a real one, so check its mint before buying. `agentWalletSwapQuote` takes the same fields as the swap and returns the estimated and minimum output and each side's dollar value without swapping anything.

**Send it as is** with `agentWalletTransfer` and the token's `mint`. `amount` is in the token's own units and the destination must be a Solana address. The send is valued at the token's market price for your spend limits. If the recipient has no account for that token yet, creating one costs a small rent fee charged in USDC on top.

## Next steps

> [card] [Guardrails](https://docs.laso.finance/guides/managed-wallet-guardrails.md)
>
> Refuse any external challenge that does not match what you agreed to pay.

> [card] [Making a purchase](https://docs.laso.finance/guides/making-a-purchase.md)
>
> The two-step card flow you reach through `agentX402Pay`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.