> For the complete documentation index, see [llms.txt](https://docs.sudo.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sudo.finance/sudo-sdk/v0.0.6/api-reference/sudoapi/cancel-order.md).

# Cancel Order

The `cancelOrder` function allows users to cancel an existing order.

#### Function Signature

```typescript
cancelOrder(
  orderCapId: string,
  collateralToken: string,
  indexToken: string,
  long: boolean,
  type: string
): Promise<TransactionBlock>
```

#### Parameters

* `orderCapId`: The ID of the order to cancel
* `collateralToken`: The token used as collateral (e.g., "USDC")
* `indexToken`: The token used as the market index (e.g., "BTC")
* `long`: Boolean indicating if this is a long (true) or short (false) position
* `type`: The type of order ("OPEN\_POSITION" or "DECREASE\_POSITION")

#### Return Value

Returns a `Promise` that resolves to a `TransactionBlock` object.

#### Usage Example

```typescript
const tx = await sudoAPI.cancelOrder(
  '0x123...', // orderCapId
  'USDC',     // collateralToken
  'BTC',      // indexToken
  true,       // long position
  'OPEN_POSITION' // order type
);
```

###
