> ## 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.

# Cancel order

> Build a transaction that cancels an open order

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>;

export const CollateralsParamField = ({body = "collaterals", note}) => <ParamField body={body} type="string[]">
    Optional collateral inputs. See <a href="/api-reference/transaction-builder/builder-inputs">UTxO input modes</a>. {note}
  </ParamField>;

Builds a transaction that cancels an open order and returns the escrowed assets to the caller.

Pass the order reference as `txHash` plus `index`, then provide `changeAddress` and `utxos`. For `utxos`, use `"splash-wallet"` to let the builder resolve wallet inputs automatically, or pass `string[]` to provide serialized UTxOs yourself. See [UTxO input modes](/api-reference/transaction-builder/builder-inputs) for the difference.

**Auth:** Public

## Request body

<ParamField body="txHash" type="string" required>
  Transaction hash of the order to cancel.
</ParamField>

<ParamField body="index" type="string" required>
  Output index of the order within its transaction, encoded as a string.
</ParamField>

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

<UtxosParamField />

<CollateralsParamField note="If omitted, the builder signs the transaction before returning it. If provided explicitly, the returned CBOR remains unsigned." />

## Response

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

<ResponseField name="cbor" type="string">
  Hex-encoded transaction CBOR. It is signed when `collaterals` are omitted.
</ResponseField>

<ResponseField name="partial" type="boolean">
  Whether the returned transaction is still partial. The current implementation returns `true`.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://builder.snek.fun/cancel \
    --header 'Content-Type: application/json' \
    --data '{
      "txHash": "e2ed9e953ebf98ca701fc93588d73cb9769f87b9d13712474f566a0743963e8b",
      "index": "0",
      "changeAddress": "addr1...",
      "utxos": "splash-wallet"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "cancel-01...",
    "cbor": "84a500...",
    "partial": true
  }
  ```
</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 or have the wrong type.
* `500 SERVER_ERROR` — UTxO lookup, config loading, transaction building, or optional signing failed.

<ResponseExample>
  ```json 400 theme={null}
  {
    "cause": "INVALID_PARAMS",
    "message": "Invalid input"
  }
  ```
</ResponseExample>
