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

# Build order

> Build a buy or sell order — works on both bonding curve and AMM

export const UtxosParamField = ({body = "utxos"}) => <ParamField body={body} type={'"splash-wallet" | string[]'} required>
    UTxO source. Pass `"splash-wallet"` to let the builder resolve wallet UTxOs automatically, or pass `string[]` to provide serialized UTxOs yourself. See <a href="/api-reference/transaction-builder/builder-inputs">UTxO input modes</a>.
  </ParamField>;

Builds an unsigned buy or sell order for any Snekfun token. The endpoint automatically detects where the token is trading and routes the order accordingly — to the bonding curve pre-graduation, or to the Splash DEX AMM pool once the token has graduated. Callers don't need to know which venue the token lives on.

Sign via [`/sign`](/api-reference/transaction-builder/sign), sign and submit via [`/sign-and-submit`](/api-reference/transaction-builder/sign-and-submit), or submit an already signed transaction via [`/submit`](/api-reference/transaction-builder/submit).

**Auth:** Public

## Request body

<ParamField body="assetId" type="string" required>
  Token asset ID in `{policyId}.{hexAssetName}` format.
</ParamField>

<ParamField body="amount" type="string" required>
  Trade amount. For `BUY` this is the lovelace input. For `BUY_WITH_OUTPUT` this is the token amount you want to receive. For `SELL` this is the token amount you want to sell.
</ParamField>

<ParamField body="side" type="string" required>
  One of `BUY`, `BUY_WITH_OUTPUT`, or `SELL`.
</ParamField>

<ParamField body="slippage" type="string" required>
  Slippage bucket. One of `15`, `30`, `50`, `75`, or `infinity`.
</ParamField>

<ParamField body="changeAddress" type="string" required>
  Bech32 change address.
</ParamField>

<UtxosParamField />

## Response

<ResponseField name="cbor" type="string">
  Hex-encoded unsigned transaction CBOR.
</ResponseField>

<ResponseField name="id" type="string">
  Builder transaction ID.
</ResponseField>

<ResponseField name="beacon" type="string">
  Optional order beacon emitted by the builder.
</ResponseField>

<ResponseField name="price" type="object">
  Optional execution price ratio.

  <Expandable title="properties">
    <ResponseField name="numerator" type="string">
      Price numerator.
    </ResponseField>

    <ResponseField name="denominator" type="string">
      Price denominator.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="priceQuote" type="string">
  Quote asset ID used for the computed price.
</ResponseField>

<ResponseField name="priceBase" type="string">
  Base asset ID used for the computed price.
</ResponseField>

<ResponseField name="outputAmount" type="string">
  Output amount as a bigint-safe string.
</ResponseField>

<ResponseField name="inputAmount" type="string">
  Input amount as a bigint-safe string.
</ResponseField>

<ResponseField name="outputAsset" type="string">
  Output asset ID.
</ResponseField>

<ResponseField name="inputAsset" type="string">
  Input asset ID.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://builder.snek.fun/order \
    --header 'Content-Type: application/json' \
    --data '{
      "assetId": "abc123...",
      "amount": "1000000",
      "side": "BUY",
      "slippage": "15",
      "changeAddress": "addr1...",
      "utxos": "splash-wallet"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "order-01...",
    "cbor": "84a500...",
    "beacon": "order-beacon-...",
    "price": { "numerator": "123", "denominator": "456" },
    "priceQuote": ".",
    "priceBase": "fbd4d3c334063ac19566f6ba39b6ec707ea91fa81d0c09201575c10b.44415645",
    "outputAmount": "23750",
    "inputAmount": "1000000",
    "outputAsset": "fbd4d3c334063ac19566f6ba39b6ec707ea91fa81d0c09201575c10b.44415645",
    "inputAsset": "."
  }
  ```
</ResponseExample>

## Error response

<ResponseField name="cause" type="string">
  Machine-readable error code.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable error message.
</ResponseField>

Possible errors:

* `400 INVALID_PARAMS` — one or more required fields are missing, malformed, or outside the allowed enum values.
* `500 ASSET_NOT_FOUND` — the requested token could not be found.
* `500 MIN_TRADE_AMOUNT` — the trade amount is below the minimum allowed amount.
* `500 MAX_TRADE_AMOUNT` — the trade amount exceeds the maximum allowed amount.
* `500 PROTOCOL_CONFIG` — protocol config loading or validation failed.
* `500 OPERATIONS_CONFIG` — operations config loading or validation failed.
* `500 UNKNOWN` — unexpected builder failure.

<ResponseExample>
  ```json 500 theme={null}
  {
    "cause": "MIN_TRADE_AMOUNT",
    "message": "Trade amount is below the minimum allowed"
  }
  ```
</ResponseExample>
