> ## Documentation Index
> Fetch the complete documentation index at: https://pond.dflow.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Orders

> Send a spot order with the DFlow Trading API: request, sign, and submit

<Info>
  During development, you can use the [developer endpoints](/get-started/endpoints) without an API key. For production use, [request an API key](/get-started/api-key) for higher rate limits.
</Info>

This recipe sends a SOL → USDC order on DFlow: request an order, sign the returned transaction, and submit it through your RPC.

```mermaid theme={null}
flowchart LR
  A[Request /order] --> B[Sign transaction]
  B --> C[Submit to RPC]
```

<Steps>
  <Step title="Set up">
    Imports, env config, and the wallet/connection used across every step.

    <AccordionGroup>
      <Accordion title="Imports, env, and wallet">
        ```typescript theme={null}
        import "dotenv/config";

        import {
          Connection,
          Keypair,
          VersionedTransaction,
        } from "@solana/web3.js";
        import bs58 from "bs58";

        const DFLOW_TRADE_API_URL = process.env.DFLOW_TRADE_API_URL ?? "https://dev-quote-api.dflow.net";
        const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpoints
        const DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
        const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL ?? "https://api.mainnet-beta.solana.com";

        const SOL_MINT = "So11111111111111111111111111111111111111112";
        const AMOUNT = 10_000_000; // 0.01 SOL (9 decimals)
        const SLIPPAGE_BPS = 50; // 0.5%

        const connection = new Connection(SOLANA_RPC_URL, "confirmed");
        const keypair = Keypair.fromSecretKey(
          bs58.decode(process.env.SOLANA_PRIVATE_KEY ?? "")
        );

        const headers: HeadersInit = {};
        if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Request an order">
    [`GET /order`](/resources/trading-api/order/order) returns a quote and a base64-encoded transaction in one call. Pass `userPublicKey` so DFlow can construct the transaction for you to sign.

    <AccordionGroup>
      <Accordion title="Request an order">
        ```typescript theme={null}
        const params = new URLSearchParams({
          inputMint: SOL_MINT,
          outputMint: DFLOW_SETTLEMENT_MINT,
          amount: AMOUNT.toString(),
          slippageBps: SLIPPAGE_BPS.toString(),
          userPublicKey: keypair.publicKey.toBase58(),
        });

        const orderResponse = await fetch(
          `${DFLOW_TRADE_API_URL}/order?${params}`,
          { headers }
        ).then((r) => r.json());
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Sign and submit">
    Deserialize the returned transaction, sign it with the user's keypair, and submit it through your RPC.

    <AccordionGroup>
      <Accordion title="Sign and submit">
        ```typescript theme={null}
        const tx = VersionedTransaction.deserialize(
          Buffer.from(orderResponse.transaction, "base64")
        );
        tx.sign([keypair]);

        const signature = await connection.sendTransaction(tx);
        const explorerUrl = `https://orbmarkets.io/tx/${signature}`;

        const { value } = await connection.confirmTransaction(signature, "confirmed");

        if (value.err) {
          console.log(`Failed: ${JSON.stringify(value.err)}`);
        } else {
          console.log("Success: trade landed");
        }
        console.log(`  Tx: ${explorerUrl}`);
        ```
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

## Related Resources

<CardGroup cols={2}>
  <Card title="Spot Trading" href="/spot/introduction" icon="arrow-right-arrow-left">
    How spot trading works on DFlow, and when the intent-based path makes sense.
  </Card>

  <Card title="Add Platform Fees" href="/spot/recipes/platform-fees" icon="percent">
    Monetize trades with builder fees.
  </Card>

  <Card title="Add Priority Fees" href="/spot/recipes/priority-fees" icon="bolt">
    Control execution speed with priority fees.
  </Card>

  <Card title="Authenticate Requests" href="/resources/recipes/api-keys" icon="key">
    Authenticate requests for production rate limits.
  </Card>
</CardGroup>

## API Routes

* [`GET /order`](/resources/trading-api/order/order)
