---
title: "Pay an x402 endpoint from the managed wallet"
method: POST
path: "/agentX402Pay"
tags: ["Agent Wallet"]
---

# Pay an x402 endpoint from the managed wallet

`POST /agentX402Pay`

## Request

- Base URL: `https://laso.finance`
- URL: `https://laso.finance/agentX402Pay`
- Auth: API key in header `Authorization`

Settles an x402 payment on your behalf, so you never build a payment header or hold a private key. Takes either a Laso `route` name or the full `url` of any external x402 endpoint on the open web.

For an external `url`, pin `maxAmountUsdc` plus optionally `expectedAsset` / `expectedNetwork` / `expectedPayTo`; a challenge that exceeds or does not match them is refused.

An external endpoint can settle in USDC on Solana or on Base mainnet (`eip155:8453`), and both are paid from the same balance with nothing to set up. When the Base side cannot cover a Base payment, Laso moves what is needed over from Solana just before signing (usually under 10 seconds, 0.075% of the amount moved). No ETH is needed for gas. Other EVM networks are refused. If an endpoint offers both, pin `expectedNetwork` to choose. Laso routes are always paid on Solana.

The call succeeds as long as the request went out, so check the returned `status` — it is the endpoint's status, not the callable's.

A Firebase callable. Callables wrap the request in `{"data": ...}` and the reply in `{"result": ...}`. Send the `id_token` from `/auth` as a Bearer token. Free.

## Request body

- object
  - `data` object, required
    - `userId` string, required: The Laso user id (the `usr_...` value from /auth).
    - `route` string: A Laso route name, e.g. `send-bank-payment`. Mutually exclusive with `url`.
    - `url` string: Full URL of an external x402 endpoint. Mutually exclusive with `route`.
    - `params` object: Query parameters for the route.
    - `method` string: GET or POST. Defaults to GET.
    - `maxAmountUsdc` number: Required for an external `url`: the most you will pay, in whole USDC. Pin the FEE-INCLUSIVE total, not the amount you requested: most priced routes add a fee on top of `amount` and round it up to the cent, so the 402 challenge costs more than the number you passed in. Take the price from the challenge's `amount` field (atomic units; divide by 1000000 for USDC) rather than recomputing it. A cap derived from the pre-fee amount lands under the real price and refuses your own payment. It can only tighten the account's per-payment spend limit, never raise it.
    - `expectedAsset` string: Refuse the challenge if the asset differs.
    - `expectedNetwork` string: Refuse the challenge if the network differs: `eip155:8453` for Base, `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp` for Solana. Pin it when an endpoint offers both, to choose the network.
    - `expectedPayTo` string: Refuse the challenge if the payee differs.
    - `body` object: JSON body for the paid request, when `method` is POST.

## Response `200`

The paid call's `status`, `body`, and an `error` when the endpoint refused.

- object
  - `result` object

## Other responses

- `400`: A required field is missing or invalid.
- `401`: Missing, invalid, or expired Bearer token.

---

[API](https://skmtc.dev/laso/apis/laso-finance-x402-api.md) · [All operations](https://skmtc.dev/laso/apis/laso-finance-x402-api/llms.txt) · [OpenAPI document](https://skmtc.dev/laso/apis/laso-finance-x402-api/revisions/ff8ce20b49ba?raw)
