# 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
);
```

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sudo.finance/sudo-sdk/v0.0.6/api-reference/sudoapi/cancel-order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
