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.
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.
| Route | States, in seconds from the start |
|---|---|
| Buying BTC, coin to coin, SOL to BTC | pending; in_progress at 8; completed at 20 |
| Selling BTC, BTC to SOL | pending; awaiting_deposit at 5; in_progress at 15; completed at 27 |
Every scenario
scenario | Name it on | What happens | What your app does |
|---|---|---|---|
success | the quote | The default: completed, with a sandbox btcTxId | Show the receipt, with btcTxId |
refund_available | the quote | refundable; refunded 15 seconds after GET /orders/{id}/refund | Offer the refund: the user's wallet sends it. When it fails |
order_expired | the quote | expired: an escrow that was never sent | Say nothing moved; offer a new quote |
order_failed | the quote | failed | Show failureReason; send Maxy the order id |
order_cancelled | the quote | cancelled | Say nothing moved |
expired_quote | the quote, or POST /orders | 409 quote_expired, with a fresh quote in details.freshQuote | Show the new amount; the wallet signs again |
price_moved | the quote, or POST /orders | 409 quote_mismatch | Quote again |
over_cap | the quote, or POST /orders | issues.orderCap and steps: null; then 422 order_cap_exceeded | Show the amounts, keep the button live; on click, offer the cap |
unfillable | the quote, or POST /orders | liquidityAvailable: false, no steps; then 422 insufficient_liquidity | On click, offer a smaller amount. A router ranks the next source |
too_small | the price or quote | 422 amount_out_of_range, with details.minSats | Show the smallest order |
insufficient_funds | the quote | issues.balance; a gasless quote has no steps, the other routes keep theirs | Show what is missing. Where there are steps, let the user go on: the wallet refuses a payment it cannot cover |
needs_approval | the quote | issues.allowance and an approve step | Send the approval and wait for it to confirm, then sign |
simulation_fails | the quote | POST /orders answers simulation.ok: false with a reason | Do not send the transaction; show the reason |
underpaid | a sale's quote | awaiting_deposit, then expired with rawStatus SANDBOX_UNDERPAID | Explain the short payment: Failed sells |
rate_limited | any call | 429 rate_limited with Retry-After: 5 | Wait Retry-After seconds, then retry |
webhook_replay | the quote | completed; each webhook event arrives twice with the same id | Process each event id once |
payment_replaced | the quote | completed, then the payment is replaced: a new btcTxId, and an order.payment_replaced webhook with previousBtcTxId | Follow the new btcTxId; report the transfer final at its first confirmation |
recipient_declined | the quote, or POST /orders | 403 recipient_declined | Say the order cannot be processed; do not retry it. A router skips Maxy for it |
jurisdiction_blocked | the quote, or POST /orders | 403 jurisdiction_blocked | Say Maxy does not serve the user's location; do not retry it |
open_sells_limit | a sale's quote, or POST /orders | 409 open_sells_limit | Ask 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 -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 -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE/health?scenario=degraded" | jq '{status, degraded}'
{ "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.