ORCHESTRATION API

POST /quote

Returns one or more quotes for a given asset route and amount, including transaction payloads ready to sign.

This endpoint returns one or more quotes for a given asset route and amount. Each quote includes the expected output amount, estimated fill time, and transaction payloads ready to be signed and submitted to the blockchain.

TypeScript Types: Generate types for this API with a single command. See Type Generation.
API Reference: For detailed schema definitions and interactive testing, see the API Reference.

Request

Endpoint

POST /quote

Headers

Content-Type: application/json
x-api-key: YOUR_API_KEY

Body Parameters

FieldTypeRequiredDescription
routeRouteYesThe source and destination assets, each a { chain, address } pair
amountInstringYesInput amount in the token's smallest unit
senderstringYesThe wallet address sending the input asset
recipientstringNoThe address receiving the output asset (defaults to sender)
maxNumQuotesnumberNoMaximum number of quotes to return (default 1)
providersProvidersParamsNoinclude or exclude lists of providers to constrain routing (set at most one)

Check the API reference for detailed schema definitions.

Example Request

import type { components } from "./m0-swap"; // From type generation

type Quote = components["schemas"]["Quote"];

const response = await fetch("https://gateway.m0.xyz/v1/orchestration/quote", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "YOUR_API_KEY",
  },
  body: JSON.stringify({
    route: {
      source: {
        chain: "Ethereum",
        address: "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b", // M token
      },
      destination: {
        chain: "Base",
        address: "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b", // M token
      },
    },
    amountIn: "1000000", // 1 M (6 decimals)
    sender: "0xYourWalletAddress",
    maxNumQuotes: 1,
  }),
});

const quotes: Quote[] = await response.json();

Example Response

[
  {
    "route": {
      "source": {
        "chain": "Ethereum",
        "address": "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b"
      },
      "destination": {
        "chain": "Base",
        "address": "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b"
      }
    },
    "recipient": "0xYourWalletAddress",
    "amountIn": "1000000",
    "amountOut": "999500",
    "estFillTime": 180,
    "payloads": [
      {
        "provider": "m-wormhole-portal",
        "annotation": "Bridge M from Ethereum to Base",
        "data": {
          "type": "evm",
          "chain": "Ethereum",
          "chainId": 1,
          "to": "0x1234567890abcdef...",
          "data": "0xabcdef...",
          "value": "0"
        }
      }
    ]
  }
]

Error Responses

All errors share the { code, message, requestId } body shape. Branch on code rather than on the HTTP status.

StatusCodeDescription
400BadQuoteRequestMalformed or invalid body (missing fields, same source and destination, both include and exclude set, unsupported asset)
404NoQuotesAvailableThe request was valid but no provider could produce a quote for this route and amount
500QuoteErrorUnexpected internal failure while computing quotes — retrying may succeed

Executing Quote Payloads

Once you have a quote, you can execute its payloads using your preferred chain interface.

Here is an example executing a payload on Base using Viem.

EVM Payload Execution

import type { components } from "./m0-swap"; // From type generation
import { createPublicClient, http } from "viem";
import { base } from "viem/chains";

type EvmPayload = components["schemas"]["EvmPayload"];

async function executeEvmPayload(
  payload: EvmPayload,
  account: ReturnType<typeof privateKeyToAccount>,
) {
  const client = createPublicClient({
    chain: base,
    transport: http(),
  });

  // Send the transaction
  const hash = await client.sendTransaction({
    to: payload.to as `0x${string}`,
    data: payload.data as `0x${string}`,
    value: BigInt(payload.value),
  });

  // Wait for confirmation
  const receipt = await client.waitForTransactionReceipt({
    hash,
    confirmations: 1,
  });

  return { hash, receipt };
}

Filtering Providers

Use the optional providers field to control which liquidity providers are used when generating quotes. You can either include only specific providers or exclude certain ones.

Available Providers

m-swap-facility · m-wormhole-portal · m-hyperlane-portal · m-portal · wormhole-cctp · limit-order · uniswap-v3

Include Only Specific Providers

const body = JSON.stringify({
  route: {
    /* ... */
  },
  amountIn: "1000000",
  sender: "0xYourWalletAddress",
  providers: {
    include: ["m-wormhole-portal", "m-swap-facility"],
  },
});

Exclude Specific Providers

const body = JSON.stringify({
  route: {
    /* ... */
  },
  amountIn: "1000000",
  sender: "0xYourWalletAddress",
  providers: {
    exclude: ["wormhole-cctp"],
  },
});
If both include and exclude are provided, include takes precedence — only the listed providers will be used, and exclude is ignored.

Notes

  • The amountIn parameter should be provided in the token's smallest unit (e.g., for a 6-decimal token, 1000000 represents 1 token)
  • Results are ranked by best amountOut, fastest estFillTime, and fewest payloads (in that order), and the response is capped at maxNumQuotes (default 1)
  • Payloads should be executed in order - wait for each transaction to confirm before sending the next
  • Cross-chain quotes may include multiple payloads (e.g., approve + bridge)
  • The estFillTime is an estimate in seconds for the entire route to complete
Copyright © M0 Foundation 2026