Overview
The Laso Finance API uses three authentication mechanisms:SIGN-IN-WITH-Xheader forGET /auth. A base64-encoded CAIP-122 signed message that proves wallet ownership. Free.x-paymentheader on the paywalled endpoints (/get-card,/order-gift-card,/get-push-to-card,/order-intl-card,/send-payment,/send-bank-payment). The signed x402 payment payload. The server verifies it, settles the payment, and extracts the payer’s wallet address. An MPP client sends its credential asAuthorization: Payment ...instead; the payer’s wallet is extracted the same way.- Bearer tokens. For authenticated endpoints like
/get-card-data,/get-account-balance, etc. Pass anid_tokenas aBearertoken in theAuthorizationheader.
Getting tokens
CallGET /auth (free) or GET /get-card (which costs the card amount in USDC) to receive auth credentials:
Signing in with SIGN-IN-WITH-X
Build a CAIP-122 message and sign it with your wallet, then send it base64-encoded in theSIGN-IN-WITH-X header. The @x402/extensions/sign-in-with-x package handles the construction and the wrapFetchWithSIWx helper handles the full request flow automatically:
- Domain binding: the signed message’s
domainmust matchlaso.finance. - Nonce uniqueness: each signature can only be used once.
- 5-minute expiry: signatures older than 5 minutes are rejected.
PAYMENT-REQUIRED response header, so the correct recovery is to sign the new challenge and retry. If you receive a 402 after sending a SIGN-IN-WITH-X header, treat it as a verification failure. Do not resend the same payload.
Supported chains:
Using tokens
Pass theid_token as a Bearer token in the Authorization header (the examples write it as $LASO_ID_TOKEN, exported from your saved credentials):
Refreshing tokens
Why tokens expire
Theid_token returned by /auth and /get-card expires after approximately 1 hour (3600 seconds). After expiry, authenticated endpoints like /get-card-data return 401 Unauthorized.
The refresh_token is long-lived and can be used to get a new id_token without paying again.
Refreshing a token
CallPOST /auth with grant_type: "refresh_token" and your refresh_token. This follows the standard OAuth2 pattern and is free: no x402 payment required.
The response returns a new
refresh_token as well. Always store the latest
refresh_token from each response.Proactive refresh
Don’t wait for a401 error. Refresh the token before it expires:
Reactive refresh
Alternatively, catch401 errors and refresh on demand:
Store both tokens
Always persist both theid_token and refresh_token. If you lose the refresh_token, you’ll need to call GET /auth again, which is free but requires signing a fresh SIGN-IN-WITH-X message.
Error responses
Token lifecycle
Getting a login link for humans
If a human wants to see what their agent has been doing (cards, transactions, balances), useGET /get-auth-link to generate a one-time login URL:
auth_url to the human exactly as received; opening it in a browser logs them in to the Laso Finance dashboard as that user. The URL carries a short single-use login code rather than a long token, so it passes through tool-output credential filters intact. Agents should not fetch or open it themselves, since redeeming the code consumes the human’s login. The code expires after 15 minutes, so generate a new link if needed.
How wallet identity works
Your identity in the Laso Finance system is your wallet address:- You call
GET /authwith aSIGN-IN-WITH-Xheader. - The server cryptographically verifies the signature and extracts your wallet address.
- If it’s your first time, an account is created automatically.
- Your
user_idis your wallet address (lowercased). - All tokens and cards are tied to this wallet address.