Find something... ⌘K

Get integrated / Test

Test scenarios

Force every outcome your product must handle, with a test key, before a real user meets it. Name a scenario, place the order as usual, and the sandbox walks it there by itself. This page lists each scenario, how to force it, and what your app should do when it happens live.

Force an outcome

Name the scenario on the quote: scenario as a query parameter on GET /price or GET /quote, or scenario on the SDK's swap.quote, swap.execute and flow helpers. It stays with the order. You can also name one in the body of POST /orders. A live key ignores scenario. GET /sandbox/scenarios lists them, and simulate works the same way. The samples use the setup from Get a quote.

curlTypeScriptPython
Copy
curl -sG -H "x-maxy-key: $MAXY_API_KEY" "$BASE/quote" \ --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.01 \ -d fromAddress="$WALLET" -d toAddress="$MY_BTC_ADDRESS" -d scenario=refund_available > quote.json

Timing

An order starts when you submit it, or when you place it for a gasless order or a sale. One nobody submits starts by itself 30 seconds after it is placed. Webhooks follow each change within about 15 seconds.

RouteStates, in seconds from the start
Buying BTC, coin to coin, SOL to BTCpending; in_progress at 8; completed at 20
Selling BTC, BTC to SOLpending; awaiting_deposit at 5; in_progress at 15; completed at 27

Every scenario

scenarioName it onWhat happensWhat your app does
successthe quoteThe default: completed, with a sandbox btcTxIdShow the receipt, with btcTxId
refund_availablethe quoterefundable; refunded 15 seconds after GET /orders/{id}/refundOffer the refund: the user's wallet sends it. When it fails
order_expiredthe quoteexpired: an escrow that was never sentSay nothing moved; offer a new quote
order_failedthe quotefailedShow failureReason; send Maxy the order id
order_cancelledthe quotecancelledSay nothing moved
expired_quotethe quote, or POST /orders409 quote_expired, with a fresh quote in details.freshQuoteShow the new amount; the wallet signs again
price_movedthe quote, or POST /orders409 quote_mismatchQuote again
over_capthe quote, or POST /ordersissues.orderCap and steps: null; then 422 order_cap_exceededShow the amounts, keep the button live; on click, offer the cap
unfillablethe quote, or POST /ordersliquidityAvailable: false, no steps; then 422 insufficient_liquidityOn click, offer a smaller amount. A router ranks the next source
too_smallthe price or quote422 amount_out_of_range, with details.minSatsShow the smallest order
insufficient_fundsthe quoteissues.balance; a gasless quote has no steps, the other routes keep theirsShow what is missing. Where there are steps, let the user go on: the wallet refuses a payment it cannot cover
needs_approvalthe quoteissues.allowance and an approve stepSend the approval and wait for it to confirm, then sign
simulation_failsthe quotePOST /orders answers simulation.ok: false with a reasonDo not send the transaction; show the reason
underpaida sale's quoteawaiting_deposit, then expired with rawStatus SANDBOX_UNDERPAIDExplain the short payment: Failed sells
rate_limitedany call429 rate_limited with Retry-After: 5Wait Retry-After seconds, then retry
webhook_replaythe quotecompleted; each webhook event arrives twice with the same idProcess each event id once
payment_replacedthe quotecompleted, then the payment is replaced: a new btcTxId, and an order.payment_replaced webhook with previousBtcTxIdFollow the new btcTxId; report the transfer final at its first confirmation
recipient_declinedthe quote, or POST /orders403 recipient_declinedSay the order cannot be processed; do not retry it. A router skips Maxy for it
jurisdiction_blockedthe quote, or POST /orders403 jurisdiction_blockedSay Maxy does not serve the user's location; do not retry it
open_sells_limita sale's quote, or POST /orders409 open_sells_limitAsk the user to pay or let lapse their open sells first

The order cap and the order size are explained on Keys and limits, and every code on Error codes.

Skip the wait

POST /sandbox/orders/{id}/advance moves a sandbox order to its next state now, or to a later state with { "to": "completed" }; on a buy, { "to": "confirmed" } brings in its payment's first confirmation. A state its scenario does not reach answers 409 order_state, with allowedStates. ORDER_ID is from Track the order.

curl Copy
curl -s -X POST "$BASE/sandbox/orders/$ORDER_ID/advance" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" -d '{ "to": "completed" }'

From a terminal: npx -p maxy-labs maxy sandbox advance <id> --to completed. With the SDK: Test your integration.

Test that you skip Maxy

GET /health?scenario=degraded answers a degraded health, in the same shape, so a router can test the code that skips Maxy while it is degraded.

curl Copy
curl -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE/health?scenario=degraded" | jq '{status, degraded}'
json Copy
{ "status": "degraded", "degraded": true }

Then, on mainnet, run one buy with $5 of USDC and one with 0.002 ETH, and work through the launch checklist.