# Order routes

The routes that place an order and act on it. Maxy never signs or sends: each answers what the user's wallet does next. Each takes a secret or a publishable key. Samples continue from [Sign](https://maxy.co/docs/buy-btc#sign) (`quote.json`, `INTENT_SIG`); answers are real sandbox answers, trimmed.

## POST /orders

The body: the quote's `order` and the signatures its `steps` asked for, keyed by step id.

| Field | Required | Meaning |
| --- | --- | --- |
| `order` | yes | The quote's `order`, unchanged |
| `signatures` | per route | `evm-btc-escrow`, `evm-btc-bridge` and `btc-evm`: `intent`. `evm-btc-gasless`: `witness`, and `permit` when asked. `sol-btc`: `quote`. `btc-sol` and `cross-evm`: none |
| `externalId`, `externalCustomerId` | no | Your own ids, stored as given and returned on the order |
| `partnerFeeBps`, `partnerFeeRecipient`, `partnerFeeToken` | no | The quote's partner fee; a different one is `invalid_partner_fee` |
| `scenario` | no | Test keys only: [Test scenarios](https://maxy.co/docs/test-scenarios) |

With an `Idempotency-Key`, a retry gets the first answer (`Idempotent-Replayed: true`); another body under it is `409 idempotency_conflict`, so key on the signatures too, as the SDKs do:

```sh
curl -s -X POST "$BASE/orders" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \
  -H "Idempotency-Key: $(jq -r .quoteId quote.json):s$(printf %s "$INTENT_SIG" | shasum -a 256 | cut -c1-16)" \
  -d "$(jq -c --arg sig "$INTENT_SIG" '{order: .order, signatures: {intent: $sig}, externalId: "inv-1042"}' quote.json)" > placed.json
```

```json
{
  "orderId": "0x53414e44424f58a49f0bbb2d2bcbf46eb1bd3426e8ce29151d06ec8bcdc327d0",
  "route": "evm-btc-escrow",
  "expiresAt": 1795143713,
  "expiresAtIso": "2026-11-20T03:01:53.000Z",
  "refundAt": 1795143713,
  "transaction": { "chainId": 8453, "from": "0x8Ee2E7ceC006347C829a031D9F8eecBfA92B69cB", "to": "0x0000000000000000000000000000000000000000", "data": "0x4d4158592053414e44…", "value": "0", "gas": "1", "simulatedHash": "0x53414e44424f58126a0b…", "simulated": true, "sandbox": true },
  "simulation": { "ok": true },
  "next": { "method": "POST", "path": "/orders/submit", "body": { "order": "…", "signatures": { "intent": "0x66b0c535…" }, "txHash": "<transaction.simulatedHash>" } },
  "sandbox": true
}
```

| Route | Answer | Then |
| --- | --- | --- |
| `evm-btc-escrow` | `transaction` to send and its `simulation`; with a fee, `partnerFee.transaction` too | Send it, then `POST /orders/submit`, then the fee: [Partner fees](https://maxy.co/docs/partner-fees) |
| `evm-btc-gasless` | `submitted: true`: the solver opens the escrow | Track the order |
| `evm-btc-bridge` | The swap leg's `transaction`, then `escrow.transaction` | [Any token to BTC](https://maxy.co/docs/any-token-to-btc) |
| `btc-evm` | The payout locked, and `next`: the deposit route | `GET /orders/{id}/deposit` |
| `sol-btc` | `steps`: the deposit to sign | `POST /orders/{id}/steps` |
| `btc-sol` | `steps`: the open to sign | `POST /orders/{id}/steps` |
| `cross-evm` | `transaction` to send | `POST /orders/submit` |

If `simulation.ok` is `false`, do not send the transaction. A sandbox transaction is never sent: use its `simulatedHash`.

## POST /orders/submit

After the escrow or bridge transaction is sent: tells the solver at once. An escrow opened inside a contract is not seen on chain, so a contract always calls this: [From a contract](https://maxy.co/docs/opening-an-escrow-from-a-contract). Body: `next.body` from `POST /orders`, with `txHash` (on `evm-btc-bridge`, first `bridgeTxHash`).

```sh
curl -s -X POST "$BASE/orders/submit" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \
  -d "$(jq -c --arg tx "$(jq -r .transaction.simulatedHash placed.json)" '.next.body + {txHash: $tx}' placed.json)"
```

```json
{
  "orderId": "0x53414e44424f58a49f0bbb2d2bcbf46eb1bd3426e8ce29151d06ec8bcdc327d0",
  "route": "evm-btc-escrow",
  "notified": true,
  "status": "/status?orderId=0x53414e44424f58a49f0bbb2d2bcbf46eb1bd3426e8ce29151d06ec8bcdc327d0&chainId=8453&route=evm-btc-escrow",
  "sandbox": true
}
```

## POST /orders/{id}/signature

`POST /orders` with the order id in the path and one `signature`: `{ order, signature }`. Use `signatures` for a route with two.

## POST /orders/{id}/cancel

The transaction that takes back an escrow no solver has committed to, for the user's wallet to send, while a buy is `pending`.

Parameters: `chainId` (required) and `from` (default the maker).

A fresh order, not yet submitted, with the [Buy BTC](https://maxy.co/docs/buy-btc) setup:

```sh
curl -sG -H "x-maxy-key: $MAXY_API_KEY" "$BASE/quote" --data-urlencode "from=ETH on base" -d to=BTC -d amount=0.004 \
  -d fromAddress="$WALLET" -d toAddress="$MY_BTC_ADDRESS" > fresh.json
SIG=$(cast wallet sign --private-key "$TEST_WALLET_KEY" --data "$(jq -c '.steps[] | select(.id == "intent") | .typedData' fresh.json)")
ORDER_ID=$(curl -s -X POST -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" "$BASE/orders" \
  -d "$(jq -c --arg sig "$SIG" '{order: .order, signatures: {intent: $sig}}' fresh.json)" | jq -r .orderId)
curl -s -X POST -H "x-maxy-key: $MAXY_API_KEY" "$BASE/orders/$ORDER_ID/cancel?chainId=8453"
```

```json
{
  "orderId": "0x53414e44424f5815f86ca4ae8d7a410a16951c05d78f483e7c75555ea684d324",
  "state": "pending",
  "cancellable": true,
  "function": "cancelBuyEscrow",
  "allowedStates": ["pending"],
  "explanation": "Takes back the escrow: no solver has committed yet. Sandbox: nothing to send; the order now reads cancelled.",
  "transaction": { "chainId": 8453, "to": "0x0000000000000000000000000000000000000000", "data": "0x4d4158592053414e44…", "value": "0", "simulated": true },
  "sandbox": true
}
```

After a solver commits: `409 order_state`; the order then pays out, or refunds after its deadline.

## GET /orders/{id}/refund

The transaction that takes an expired escrow back to the user, for the user's wallet to send. Parameters: `chainId` (required) and `from`. Before the deadline it answers `refundable: false`, a `reason` and `unlocksAt`. Flow: [When it fails](https://maxy.co/docs/when-it-fails#refunds).

## Selling BTC: deposit, claim, bridge

| Route | Parameters | Answers |
| --- | --- | --- |
| `GET /orders/{id}/deposit` | The query in `next.path` from `POST /orders` | `ready: false` and `retryAfterSeconds` while the payout locks; then `address`, `sats`, `bitcoinUri`, `expiresAt`, read from the settler |
| `GET /orders/{id}/claim` | `chainId`; `btcTxid` and `from` optional | The proof as a transaction any wallet may send; the payout still goes only to the user |
| `GET /orders/{id}/bridge` | `chainId`, `toChainId`, `toToken`; `toAddress` optional | For a coin with no settler: the bridge transaction, once the settler has paid (to Tron or Sui: LI.FI's, to `toAddress` there) |
| `GET /orders/{id}/bridge?route=btc-sol` | `outMint`, `wallet`, `solPayoutRaw`, from the quote's `swap` step | BTC to a Solana coin no settler pays: the Solana swap of the paid SOL, checked, for the wallet to sign |

The sample reads `sell.json` from [Sell BTC](https://maxy.co/docs/sell-btc).

```sh
curl -s -H "x-maxy-key: $MAXY_API_KEY" "$BASE$(jq -r .next.path sell.json)"
```

```json
{
  "orderId": "0x53414e44424f584474e48333e1992976d077d8f06addf17b97781dad85d7a34d",
  "route": "btc-evm",
  "state": "NONE",
  "ready": false,
  "reason": "The solver is locking the payout in the settler. Do not send BTC. Ask again in a few seconds.",
  "retryAfterSeconds": 3,
  "sandbox": true
}
```

`409` from the deposit route (window closed, or paid out) or `422 deposit_address_unverified` (the escrow does not match the order): **do not pay**.

## Solana: GET and POST /orders/{id}/steps

A Solana order's state and what the wallet signs next. `GET` takes `route` (`sol-btc` or `btc-sol`). `POST` takes `{ order, signatures, transaction }`: the signed transaction, base64, which Maxy checks against the deposit it built before sending it. The flow: [Pay with SOL](https://maxy.co/docs/pay-with-sol).

## Errors

| HTTP | `code` | When |
| --- | --- | --- |
| 400 | `invalid_input` | The order was changed, a signature is malformed, or a field is missing |
| 400 | `wallet_mismatch` | Signed by a wallet other than the quote's |
| 409 | `quote_expired` | The quote is over 60 seconds old. `details.freshQuote` holds a new quote for the same swap |
| 409 | `quote_mismatch`, `order_state`, `idempotency_conflict` | The price moved; not allowed in this state; a reused `Idempotency-Key` |
| 422 | `order_cap_exceeded`, `insufficient_liquidity`, `insufficient_funds` | Over your cap; Maxy cannot fill this size now; the wallet holds too little |

---
Source: https://maxy.co/docs/order-routes (Maxy Docs › API reference › Routes)
