> For the complete documentation index, see [llms.txt](https://dexhunter.gitbook.io/dexhunter-partners/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dexhunter.gitbook.io/dexhunter-partners/orders/cancel.md).

# Cancel Orders

Cancel pending limit or DCA orders.

{% hint style="warning" %}
**Required:** Include `X-Partner-Id` header with your API key on all requests.

**Base URL:** `https://api-us.dexhunterv3.app`
{% endhint %}

***

## Cancel Single Order

Cancel one order.

**Endpoint**

`POST /swap/cancel`

**Payload**

| Field      | Type   | Required | Description        |
| ---------- | ------ | -------- | ------------------ |
| `order_id` | string | ✓        | Order ID to cancel |
| `address`  | string | ✓        | User's address     |

**Response**

| Field  | Type   | Description              |
| ------ | ------ | ------------------------ |
| `cbor` | string | Transaction CBOR to sign |

{% tabs %}
{% tab title="Example" %}

```javascript
const API_KEY = 'YOUR_API_KEY';
const BASE_URL = 'https://api-us.dexhunterv3.app';
const headers = { 'X-Partner-Id': API_KEY };

const payload = {
  order_id: '6a7b8c9d...',
  address: 'addr1qx2kd28nq8ac5pr...',
};

const { data } = await axios.post(`${BASE_URL}/swap/cancel`, payload, { headers });
const signatures = await wallet.signTx(data.cbor, true);
const { data: signed } = await axios.post(`${BASE_URL}/swap/sign`, { txCbor: data.cbor, signatures }, { headers });
const txHash = await wallet.submitTx(signed.cbor);
```

{% endtab %}
{% endtabs %}

***

## Cancel Multiple Orders

Cancel multiple orders in one transaction.

**Endpoint**

`POST /swap/bulkcancel`

**Payload**

| Field       | Type   | Required | Description         |
| ----------- | ------ | -------- | ------------------- |
| `order_ids` | array  | ✓        | Order IDs to cancel |
| `address`   | string | ✓        | User's address      |

**Response**

| Field  | Type   | Description              |
| ------ | ------ | ------------------------ |
| `cbor` | string | Transaction CBOR to sign |

{% tabs %}
{% tab title="Example" %}

```javascript
const payload = {
  order_ids: ['6a7b8c9d...', '1a2b3c4d...', '9x8y7z6w...'],
  address: 'addr1qx2kd28nq8ac5pr...',
};

const { data } = await axios.post(`${BASE_URL}/swap/bulkcancel`, payload, { headers });
const signatures = await wallet.signTx(data.cbor, true);
const { data: signed } = await axios.post(`${BASE_URL}/swap/sign`, { txCbor: data.cbor, signatures }, { headers });
const txHash = await wallet.submitTx(signed.cbor);
```

{% endtab %}
{% endtabs %}
